View Full Version : Texture interpolation with vertex buffers

06-24-2008, 09:34 AM

is there anybody who can help me please?? I'm developing terrain engine. It uses 4 TUs for interpolating textures and finaly modulating result fragmets with primary color, which is calculated as a "slope lightning". CLOD and culling algorithm is disabled. By normal way, rendering polygon by polygon, everything works fine.

Now i have decided for performance boost, as the power will be needed for hand gesture recognition in my project.

Vertex array with color array alone (without textures) boosted my FPS almost 3 times, as i expected. The original way how i did interpolation was setting alpha of GL_TEXTURE_ENV_COLOR and used GL_INTERPOLATE mode for TUs. But the problem is, that there is no way how to change GL_TEXTURE_ENV_COLOR with vertex arrays, one value per polygon (or even vertex).

So i have decided to render 2 triangles per one GL_TEXTURE_ENV_COLOR change, rendered by glDrawElements. I expected some performance fall - from 60 fps with arrays, *without* textures, to 30 fps *with* textures. Instead of performance fall, performance disaster came, slowing down to 3 fps.

So the question is:

Why the rendering procedure, 20 lines of code, no math, with arrays, runs at 2 fps, where rendering with 150 lines full of math (calculation of tex coords, vertex position from heightmap...) runs much faster?

Is there any way how to use arrays, or even buffer objects, together with interpolation of textures?

Thank you very much for any hints,

best regards

J. Bastek

06-24-2008, 12:53 PM
I have no idea what are you doing and where is your problem, but my advice is a universal one: use shaders instead of that irritating texture combiner stuff :)

Ilian Dinev
06-24-2008, 01:52 PM
The texture combiners can't be controlled from an array:
So, your only way is to use shaders.
With arrays, you can't really set per-polygon data, btw (unless you make a geometry shader). So, get ready for a lot of vertex duplication just to change an attribute, shared between 3 vertices.

06-25-2008, 01:15 AM
Hello Ilian Dinev,

I was afraid of this, i hoped that there is some trick. I think i still don't have explored OGL enough to start doing with shaders.

For now i will try to optimize some other things and will hope, that implementing CLOD and culling will be enough for my project.

Thank you very much for your reply.

J. Bastek