Hello
I want to flip the normals in a custom shader but I’ve some trooble making it work. I’ve try some tutorials but from my understanding each engine handle glsl differently. So here is the code.
The fragment shader
varying vec2 vUv0;
uniform sampler2D uDiffuseMap;
varying mat4 matrix_model;
varying vec4 verpos;
varying float effect;
void main(void)
{
gl_FragColor = vec4(0.0);
vec4 color = texture2D(uDiffuseMap, vUv0);
color = vec4(color.x+ ((verpos.y*0.0009) * (effect - 0.9) * 2.0), color.y+ ((verpos.y*0.0009) * (effect - 0.9) * 2.0),color.z+((verpos.y*0.0009) * (effect - 0.90) * 2.0),1);
gl_FrontFacing = false;
gl_FragColor = color;
}
The Vertex shader
attribute vec3 aPosition;
attribute vec2 aUv0;
varying vec2 texCoord;
uniform mat4 matrix_model;
uniform mat4 matrix_viewProjection;
uniform float scale;
varying float effect;
varying vec2 vUv0;
varying vec4 verpos;
void main(void)
{
effect = scale;
vUv0 = aUv0;
verpos = vec4(aPosition ,scale);
gl_Position = matrix_viewProjection * matrix_model * vec4(aPosition ,scale);
}
[the link I followed] (http://stackoverflow.com/questions/28160756/normals-are-inverted)
I’ve a compilation error on the gl_FontFacing = false;. Is there any other way I can access this function.
I tried to find some documentation about it but couldn’t find one wich actually work on playcanvas. Is it beceause it is on web gl?
that’s a lot of questions and i’m a bit noob in shader programming. If anyone can link me to a documentation that would be great
thanks!