views:

185

answers:

2

As my project gets close to optimization stage, I notice that reducing Vertex Metadata could vastly improve the performance of 3D rendering.

Eventually, I've dearly searched around and have found following advices from stackoverflow.

Using GL_SHORT instead of GL_FLOAT in an OpenGL ES vertex array

How do you represent a normal or texture coordinate using GLshorts?

Advice on speeding up OpenGL ES 1.1 on the iPhone

Simple experiments show that switching from "FLOAT" to "SHORT" for vertex and normal isn't tough, but what troubles me is when you're to scale back verticies to their original size (with glScalef), normals are multiplied by the reciprocal of the scale. Natural remedy for this is to multiply the normals w/ scale before you submit to GPU. Then, my short normals almost become 0, because the scale factor is usually smaller than 0. Duh!

How do you use "short" for both vertex and normal at the same time? I've been trying this and that for about a full day, but I could only go for "float vertex w/ byte normal" or "short vertex w/ float normal" so far.

Your help would be truly appreciated.

+1  A: 

Can't you just Normalise your normals by calling this?

glEnable( GL_NORMALIZE );

Its not ideal because normalising will likely hit the GPU a bit but it really depends on if your bottleneck is caused by the passing data to the GPU or by the GPU doing too much. As with any optimisation you need to figure out which gives the better speed up. I'd suspect you are probably slowed down by passing the vertex data so you WILL get a speed up.

Goz
I've thought about normalizing it but never really tried that because "normalizaing" is generally talked down from every article I've read. But you're right. Plus, there will always be trade off no matter what. I'll give it a shot shortly. Thanks alot.
Xylopia
A: 

Possible things to try:

  • try to counter the scaling by fiddling with the GL_NORMAL matrix
  • use a vertex shader to perform the calculations as you wish
  • don't scale your vertex data down, enlarge your camera matrices instead
UncleZeiv
1.GL_NORMAL matrix sounds good to me. I'll try to compare between that and GL_NORMALIZE. 2)My proj is on fixed render pipe so, no vertex shader. 3) Enlarging my camera matrix...isn't possible either because i'm delivering everything to modelview space directly. :(Thank you for the GL_NORMAL matrix :)
Xylopia
as for 3), you can deal with a bigger "modelview space", unless I am missing something. What I mean is that you should have control at a certain point on how to map the world to the screen coordinates, and you should be able to take advantage of that... again, unless I am missing something.
UncleZeiv