I’m writting a glsl shader under a highly flexible and successful in my opinion library nvFX. But the usage of subroutines in this library is not complete , and in general as it turned out this possibility of a function pointer has a trick in practice.

On compiling my shader I have an error C9999, it happent also in the example OpenGLSimpleEffect_Subroutine library nvFX.

The announcement and implementation of subroutine is added in separate shader (shader object)

FragmentProgram = {ObjectPS, DiffuseFromTexture};

FragmentProgram <“lighting”> = LightingModelSubRoutines;

In this case nothing works , but if we pull part of code with subroutine before the function main, all is well running. For example:

/ /
/ / Subroutine Prototype
/ /
subroutine vec4 sampleTYPE ();

/ /
/ /
/ /
subroutine (sampleTYPE)
vec4 sampleFunc1 () {
return vec4 (1.0);
}

/ /
/ / The array of subroutines
/ /
subroutine uniform sampleTYPE sample;

void main ()
{
color = sample ();
}

Explanation comes to mind only one – the reason is in using ARB_separate_shader_objects extension. If the subroutine within a shader , it works without problems, but if nvFX collects a fragment program from different shaders , then program falls with compilation error .

GLSL Subroutine and C9999 compilation error
Tagged on:         

Leave a Reply

Your email address will not be published. Required fields are marked *