Problem to make environnement mapping (not resolved)

Hi,
I have a grey background under shader designer.
this is the shader :

vertex shader :

 varying vec3 refletedVector ;
varying vec3 normal ;

void main(void)
{
  
   normal = normalize((gl_NormalMatrix * gl_Normal));
   
   gl_Position = ftransform();
   
   vec3 incidentVector = vec3(gl_Position.x - gl_ModelViewMatrixInverse[3][0],
                         gl_Position.y - gl_ModelViewMatrixInverse[3][1],
                         gl_Position.z - gl_ModelViewMatrixInverse[3][2]);
   
   refletedVector = reflect(incidentVector, normal);
   
   gl_TexCoord[0] = gl_MultiTexCoord0;
} 

fragement shader :

varying vec3 refletedVector ;
varying vec3 normal ;//rajouter l'éclairage ensuite
uniform sampler2D textureMap;
uniform samplerCube environmentMap;

void main(void)
{
   vec4 envTextureColor = textureCube(environmentMap, refletedVector.xyz);
   vec4 textureColor = texture2D(textureMap, gl_TexCoord[0].st);
   vec4 k = vec4(0.4, 0.4, 0.4, 1.0);//coefficient d'interpolation linéaire
   vec4 finalColor= vec4((vec4(1)-k)*textureColor + envTextureColor*k);
   gl_FragColor = finalColor;
}   

You are getting your matrix rows and columns confused, and your understanding of coordinate spaces, particularly as they apply to OpenGL, is a shambling mound.

My recommendation? Read the gl/glsl specs and bone up on the math.

i would need a little more help for my problem :
i looked here http://www.opengl.org/discussion_boards/ubb/ultimatebb.php?ubb=get_topic;f=11;t=000238#000000

and i don’t find why my matrix rows and columns are confused.

Try gl_FragColor = vec4(0.0, 0.5, 1.0, 0.5);
See what you get - if it’s still grey background then it’s not the shader.

ok thanks

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.