From: Terry Welsh (mogumbo++at++gmail.com)
Date: 06/28/2005 06:21:35
It looks like you need to transform reflVec from view space to world
space before you use it to access your cube map. To do this, you can
pass the inverse view matrix to your shader as a uniform and multiply
reflVec by it. In fact, you only really need the upper-left 3x3 of
that matrix, since translation doesn't matter in this case.
-- Terry Welsh - mogumbo 'at' gmail.com www.reallyslick.com | www.infiscape.com | www.vrsource.org> hi, > > I try to make a program using GLSL in Performer. > My shader is used to generate a water reflection using > cube texture. > > The problem is when I change the camera position in > the viewer using view->setEye(xyz, hpr), the > reflection does not change. > > Here my vertex shader: > > vNormal = normalize(gl_NormalMatrix * gl_Normal); > vec4 worldPos = gl_ModelViewMatrix * gl_Vertex; > vViewVec = normalize(worldPos.xyz); > gl_Position = gl_ModelViewProjectionMatrix * > gl_Vertex; > > > and this is my fragment shader: > > vec3 reflVec = reflect(vViewVec, vNormal); > vec4 refl = textureCube(envMap, reflVec.xyz); > gl_FragColor = refl; > > > Is there anyone can help me? > > Thanks in advanced
This archive was generated by hypermail 2b29 : Tue Jun 28 2005 - 06:22:05 PDT