Re: Help with shaders
Posted by
Martin on
Feb 18, 2012; 8:20pm
URL: https://forum.jogamp.org/Help-with-shaders-tp3737063p3756934.html
Hey you saved me weeks of random discovery!
Indeed, not loading the vertex shader makes gl_Color being properly set in the fragment shader context. That's weird the vertex shader"consumes" a read only gl_xxx variable.
As you suggest I modified vertex shader to store gl_Color in a varying, which has the great benefit of being automatically interpolated [1] as you mention in your "no-vertex-shader" tric.
Working code is:
----------------
vertex shader
----------------
varying vec4 transfertColor;
void main(void)
{
...
transfertColor = gl_Color;
}
-------------------
fragment shader
-------------------
varying vec4 transfertColor;
void main(void)
{
...
gl_FragColor = transfertColor;
}
----------
That works and rocks, thank you man :)
[1] In french:
http://www710.univ-lyon1.fr/~jciehl/Public/educ/M2PROIMA/2008/iicm2.pdf