Hallelujah! 1.5 is out! But now I’m stuck in the whirling cloud of confusion and inner turmoil, I want to get straight into coding with shaders, tweening, and parameters, but… I have no clue how. The tweening and parameter libraries are fabulous and easy to use, I just need to learn their syntax, but shaders…
I am experimenting with making a super simple shader, a shader to convert an image into grayscale. I am only messing with fragment shaders for now. But my code seemed to be doing what I wanted till I added in division of floats.
//
// A basic fragment shader
//
//Default precision qualifier
precision highp float;
//This represents the current texture on the mesh
uniform lowp sampler2D texture;
//The interpolated vertex color for this fragment
varying lowp vec4 vColor;
//The interpolated texture coordinate for this fragment
varying highp vec2 vTexCoord;
void main()
{
//Sample the texture at the interpolated coordinate
lowp vec4 col = texture2D( texture, vTexCoord );
lowp float a = (col.r + col.g + col.b);
//a /= 3.0;
//Set the output color to the texture color
gl_FragColor = vec4(a, a, a, col.a);
}
Uncomment the //a/=3.0;
and it stops working. I have no clue why or how. So I want to make a few requests…
- An output window for shader lab, so I can see variables.
- Window gestures for shader lab (swiping left-right to move the cursor, + 2 fingers for up-down).
- Someone please post a link to a decent and simple GLSL tutorial.
Thanks, and good job on the AMAZING update! You guys are fantastic!