"If" with Vertex shader

If i have understood the documentations, it seems to be impossible to use “if”,“else”… with the ARB_Vertex_program extension (?)

Do i have to use GLSL if i want to use “if” in a vertex shader ? (using ARB extension only)


Often you can multiply the result of a code segment by 1 or 0 where that operand is derived from the parameter you want to branch on.


Yes, when it comes about math you can emulate branching by using SGE and SLT instructions combined with things like x1=x and x0=0.

And if you want more advanced branching, you can take a look at the GL_NV_vertex_program2_option (only supported on NVIDIA hardware for now).