[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Strange problem calculating refraction using arbvp1/arbfp1



Heya people,



I'm having a weird problem using shaders to calculate some simple refraction. For the test, I'm using a cube map that is the same as my skybox, with no dynamic objects rendered, just the background really (i.e., static textures). The cube map is in world space, so I'm calculating the refracted look-up vector in object space and then transforming it by the model matrix - since it's only the direction I'm interested in, I just use the rotation part of the matrix.

The problem is that, for instance, when the simulation begins, I'm looking down at the -z axis (default OpenGL eye orientation, +y as up vector, +x as right vector), I can see the skybox in the background ok, and the object being used for the effect is right in front. The refracted portion of the background looks as if it's been rotated 180 degrees! I can notice this perfectly because even if I use an eta reatio of 1.0 / 1.0 (using the Cg standard library function "refract") I see this "rotation", when there's no refraction occurring.

I'm not at work right now, but I can post the shader code later, if it's needed, though I believe that this has something to do with the cube map, and no the shaders. Are there any "catches" when specifying/creating the cube map? The images on the rendered object show the correct background image, but again, they're rotated 180 degrees. Any clues?



Thank you for your attention,
Miguel A. Osorio.
www.somniumstudio.com