Rendering 100s of text causes memory overhead.

Hi,
I added few thousands of text object with different height. When text height goes beyond 100 the application consume huge amount of memory.
I tried to set scale of the AIS label by setting SetLocalTranformation and reduce the height. But scaling doest have any impact on the text size. Is there any way to render text with height above 100 without memory overhead ?

gkv311 n's picture

AIS_TextLabel relies on textured fonts, which are created for each combination of font and height metrics. This approach provides best results for small-to-medium sizes of a text displayed pixel-exact on a screen. But indeed, for a very large heights it might become too expensive - OCCT doesn't yet implement rendering approaches based on signed distance field (with a special texture and shading program), which work good for large and dynamic scales.

Instead, you may use StdPrs_BRepTextBuilder + StdPrs_BRepFont to create a B-Rep geometry from specified font and text, and then display this TopoDS_Shape as a usual geometry (e.g. AIS_Shape) with or without transformation persistence flags and desired tessellation detail. This should work best for medium-to-large scale text and zoomable text.

In Draw Harness these approaches are available via vdrawtext (textured font) and text2brep (B-Rep font) commands.

image

Attachments: 
Sathiya nathan's picture

Thanks a lot for your detailed explanation. I tried creating text shape with fixed height using StdPrs_BRepTextBuilder and scale it.
It works like normal shape, able to zoom as well with less memory.
Does OCC support LOD(Level of details) to avoid painting a text when fully zoom out ? Thus rendering performance can be improved some extent
when 1000s of text to be rendered.

gkv311 n's picture

I would suggest first to check if you have a performance issue related to text rendering. If you would like a zoomable text not to be rendered, when it becomes too small - then you may play with distance (perspective camera) or size (orthographic camera) culling options within Graphic3d_ZLayerSettings in the Viewer.

Sathiya nathan's picture

As you suggested I tried to create a layer with CullingSize and set the layerID on the AIS_Text.
It works. Thanks. I am trying another way of extending OpenGL _Text and override the Render function where I will check the
projection matrix and text size to discard painting.

Luke jk's picture

when i use this method.the text is still rendering.can you tell me how did you solve it.thanks a lot