Login  Register

Re: Help with shaders

Posted by Demoscene Passivist on Feb 18, 2012; 4:52pm
URL: https://forum.jogamp.org/Help-with-shaders-tp3737063p3756640.html

>Do you think I miss an option/setting?

My memory of the fixedfunction pipeline -> GLSL mapping is a bit rusty I must admit, so give me some rope here ...

Its a bit tricky coz gl_Color is available both in the vertex and fragment shader. The gl_Color in the vertex shader is equal to gl_FrontColor (what comes from the material spec in ur application), BUT the gl_Color in the fragment shader comes from the vertex shader and is interpolated.

So if u are explicitly specifying a vertex- AND fragment-shader u have to do the mapping/interpolation urself (e.g. as varying) or gl_Color will be black in the fragment shader (what ur are experiencing).

The other option is to only specify a fragment shader while compiling the GLSL program and let the driver autogenerate a vertex shader (as I'm doing e.g. here: GL2_BasicFragmentShading.java) The autogenerated vertex shader automatically does the fixedfunction pipeline color value interpolation. So everything is fine and gl_Color has the interpolated gl_FrontColor value in the fragment shader.

Hope the "strange" behaviour ur experiencing makes a little more sense now