View Full Version : problem to make environnement mapping (not resolved)

09-23-2006, 09:56 AM
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;

09-24-2006, 06:57 PM
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.

10-06-2006, 12:00 PM
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.

10-08-2006, 10:56 PM
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.

10-08-2006, 11:06 PM
ok thanks