Hi all!
I’m rather new programming with GLSL but I’ve made some simple shaders successfully. My problem now is that the following shader (vertex) doesn’t recognize three of the uniform variables I use: modelview, normalMatrix and invertedCamera.
After some tries, I’ve found out that the only uniform found is that one used in the last line: gl_Position = matrix * vertex;.
I post the two shaders; vertex and fragment:
#version 330
// Attributes per vertex: position, normal and texture coordinates
in vec4 vertex;
in vec3 normal;
uniform mat4 modelviewProj;
uniform mat4 modelview;
uniform mat3 normalMatrix;
uniform mat4 invertedCamera;
// Color to fragment program
smooth out vec3 vertOutTexCoords;
void main(void)
{
// Get surface normal in eye coordinates
vec3 eyeNormal = normalMatrix * normal;
// Get vertex position in eye coordinates
vec4 vertexPos = modelview * vertex;
vec3 vertexEyePos = normalize (vertexPos.xyz / vertexPos.w);
// Get reflected vector
vec4 texCoords = vec4 (reflect (vertexEyePos, eyeNormal), 1.0);
// Rotate by flipped camera
texCoords = invertedCamera * texCoords;
vertOutTexCoords.xyz = normalize (texCoords.xyz);
// Don't forget to transform the geometry!
gl_Position = modelviewProj * vertex;
}
#version 330
out vec4 fragmentColor;
uniform samplerCube textureUnit0;
smooth in vec3 vertOutTexCoord;
void main(void)
{
fragmentColor = texture (textureUnit0, vertOutTexCoord.stp);
}
Thank you!