openGL optimization text2d

Sep 11, 2008 at 12:15am

openGL optimization text2d

Hi All,

If there is a related thread, please just point me there…

Before I go and build this, can someone confirm that if nothing is changing in my gl world, I should have a performance gain by initially rendering each object to a matrix(picture), then for each output frame, adding/mixing each matrix together rather than re-rendering the entire openGL all over again. Currently, rendering swamps my machine.

Thanks!
Brian

This is the short version, some details are:
Multiple long texts with jit.gl.text2d
2ghz macbook, Max 4.6

#39655
Sep 11, 2008 at 9:06am

Hi,

On Sep 11, 2008, at 2:15 AM, Brian Mohr wrote:

> performance gain by initially rendering each object to a
> matrix(picture), then for each output frame,
> adding/mixing each matrix together rather than re-rendering the
> entire openGL all over again.

This depends soo much on the stuff you’re rendering. Can you be a bit
more specific?

Is your text predefined(than perhaps it could be a picture/texture),
or generated on the fly?

> Multiple long texts with jit.gl.text2d

jit.gl.text2d renders every displayed character into a texture, and
then ‘just’ draws the quad with that texture on it.
Whenever you add a character that wasn’t used before, it needs to
generate it’s texture and that’s one bottleneck. Same thing happens
when you change a font or its size, the texture needs to be regenerated.

So one trick is to force jit.gl.text2d into making all textures(for
one particular font&size!), by sending it the matrix with all char
values(jit.expr, jit.noise a few times, jit.gencoord)…

hth,
nesa

#139833
Sep 11, 2008 at 4:34pm

Certainly, it’s an art installation based on narrative text. The artist will write each piece of text, and place in a “space” currently consisting of 3 projections, which for all intents and purposes, can be said to be side by side. The artist will only add or edit one piece of text at a time, so all others would remain constant in content. Any text can be grabbed and moved around the space, or automatically gathered by keyword. I *think* it’s safe to say that all text will be the same font, point type, and simply white on black background.

I think you have partly answered my question already, if gl.text2d is keeping track of changes, and therefor maintaining a texture (rather than creating the texture every frame) then it’s already saving the step I thought I might need to get around. And thanks for the reminder about the first rendering, had forgotten about that, however, my performance drop occurs even when nothing is changing. One thing that interests me, my worst performance was when I accidentally sent a 320×240 matrix to one of the gl.text2d, even though it was mostly empty, my machine was not happy thinking about so many characters, but once it’s rendered to a texture, most of which was probably off screen, why would this slow me up so much?

Also, when you say text2d makes a texture, do you mean for a single character, or the entire text content, that is, for each new unchanged frame, is there a single texture it recalls, or it is recalling a texture for each character and assembling them together into the whole? Not sure that’s clear, but hopefully you follow?

Thanks so much for your insights,
Brian

#139834
Sep 12, 2008 at 11:06am

On Sep 11, 2008, at 6:34 PM, Brian Mohr wrote:
> my machine was not happy thinking about so many characters, but once
> it’s rendered to a texture, most of which was probably off screen,
> why would this slow me up so much?

Well, I don’t know internals of jit.gl.text2d, but probably the object
still needs to draw 320×240 quads, each one moved a bit(because of
kerning and stuff).

> Also, when you say text2d makes a texture, do you mean for a single
> character, or the entire text content, that

A texture per used character.

In theory, you should be able to render almost any gl object to
texture by using @capture attribute, and latter displaying it with a
videoplane.
In practice, this doesen’t work correctly with jit.gl.text2d – more
about this in separate message.

So, if there’s no workaround for @capture, perhaps you could draw the
text using jit.lcd and then draw it with videoplane, but this could be
the world of pain for formatting.

hth,
nesa

#139835

You must be logged in to reply to this topic.