Hi
I have a problem conserning the refract function in GLSL. Im going to simulate a water bubble, and thus need to “blend” a sphere.
Some code from texture generation (used in the skybox):
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE,GL_REFLECTION_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE,GL_REFLECTION_MAP);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE,GL_REFLECTION_MAP);
glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_WRAP_T,GL_REPEAT);
glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_WRAP_R,GL_REPEAT);
glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
I disable texture (and texture gen.) when I draw the sphere (glutSolidSphere).
Vertex shader code:
varying vec3 RF;
void main()
{
vec4 eyePos = gl_ModelViewMatrix * gl_Vertex;
vec3 N = normalize(gl_NormalMatrix * gl_Normal);
RF = refract(-E, N, 0.67);
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
0.67 = indices of refraction between water and air.
Fragment shader code:
varying vec3 RF;
uniform samplerCube env;
void main()
{
gl_FragColor = textureCube(env, RF);
}
The cubemap is getting mapped (upside down though), but the sphere is opaque.
I have a NVIDIA GeForce 9600M GT graphics card, if that does matter.