Just wondering; does it make any practical difference which order a
GLSL and 3D Transformation patch are nested:
I mean, should I nest the GLSL patch inside the 3D Transformation
Patch, or vice versa, or does it not matter either way?
The 3D Transformation patch modifies the OpenGL ModelView Matrix,
while the GLSL patch modifies the current GLSL vertex/fragment
program. GLSL's vertex shader depends on the ModelView Matrix
(ftransform() or gl_ModelViewProjectionMatrix * vertex), but it
doesn't use that value until you give it vertex data (which would take
place after the 3D Transformation patch did its thing). So I suppose
it shouldn't matter which order. Some simple tests could probably
verify this. I've used various combinations of TrackBall, 3d
Transformation, and GLSL, and haven't hit any landmines myself.
I recently read somewhere GPUs generally do not implement branching
conditional properly, and will actually evaluate both cases, then
choose between the results.
Is this the case, and if so, is there some way to force only certain
parts of a GLSL shader program to be executed? I realise this is
probably a more general GLSL-related question, but someone on the
list may have come across this issue...
I'm not sure what functional difference there is whether it executes
both branches or not (since there's no dynamically allocated memory/
pointers, there's no state corruption like you'd have in C if you
executed all the functions in both conditionals). It's likely that
your CPU does this to some degree as well (branch prediction makes
mistakes etc.), but the output is what you expect either way. I may
be mistaken on this point for GPU's, but I think this is the case here
as well. Do you want to skip portions of the shader for performance
reasons? In that case it might be reasonable to just require a card
that supports branching.