I have trouble trying to use some varying variable to pass info from the vertex shader to the fragment shader.
My modification to the CubeShaders is as follow:
varying vec2 clipdist;
uniform mat4 modelViewProjectionMatrix;
uniform vec4 clipPlane;
void main()
{
gl_Position = modelViewProjectionMatrix * vertexPosition;
normal = vertexNormal;
texCoord = vertexTexCoord;
clipdist[0] = clipPlane[0];
}
";
?
static const char* cubeFragmentShader = "
precision mediump float;
varying vec2 texCoord;
varying vec4 normal;
varying vec2 clipdist;
uniform sampler2D texSampler2D;
void main()
{
if (clipdist[0] > 50) discard;
gl_FragColor = texture2D(texSampler2D, texCoord);
}
";
The message is telling me of problems when compiling the fragment shader, without more details. The problem comes from the use of clipdist[0], If I use if (55 > 50) it works; but I can't figure what is wrong. Have also tried with a float instead of a vec2, but the problem is still there.
Can somebody help me ?
Thanks in advance
I have also
Shader not compiling
Hi, in case you have not yet figured out a solution for this, maybe try and check the following:
- use clipdist.x instead of clipdist[0] (although clipdist[0] should be correct, but just to check if you GPU driver has any issue with arrays notation)