Log in or register to post comments

Shader not compiling

July 23, 2012 - 11:29am #1

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

October 8, 2012 - 2:52am #2

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)

- use floating point notation for numbers that are meant to be float, i.e. use "50.0" instead of "50"

Beside the above, I don't see any other obvious reasons for your code not to compile... 

Log in or register to post comments