hey, sorry for raising the same problem that already was on the forum…but it looks like i’m damned when it goes to glsl.
i’m trying to do reflection of cubemap i’ve got from framebuffer;
so the problem is if i rotate camera or move it - “reflected” image…of course, does move too. if i rotate camera left or right, texture moves in inverse direction, over-compensating camera movement. rotating camera up-down makes it move in same direction, but “faster” than needed, so again, it overcompensates camera rotation. same with camera movement. also reflection scale is a bit bigger than it should.
V:
#version 110
attribute vec3 Tangent;
varying vec4 Add;
varying vec4 ld;
varying vec4 eye;
varying vec4 N;
void main()
{
vec4 V = gl_ModelViewMatrix * gl_Vertex;
gl_Position = gl_ProjectionMatrix * V;
gl_TexCoord[0] = gl_MultiTexCoord0;
vec4 T = -normalize(vec4(gl_NormalMatrix * Tangent, 1.0));
N = normalize(vec4(gl_NormalMatrix * gl_Normal, 1.0));
vec4 B = vec4(cross(N.xyz, T.xyz), 1.0);
mat3 TBN = mat3(vec3(B.x, T.x, N.x), vec3(B.y, T.y, N.y), vec3(B.z, T.z, N.z));
ld = normalize(vec4(TBN * (gl_LightSource[0].position - V).xyz, 1.0));
eye = normalize(vec4(TBN * (-V).xyz, 1.0));
gl_TexCoord[7] = V;
Add = gl_Color;
}
F:
#version 110
uniform sampler2D colorMap;
uniform sampler2D bumpMap;
uniform samplerCube Refl;
uniform vec4 Ambient;
uniform vec4 Material;
uniform vec4 Cam;
varying vec4 Add;
varying vec4 ld;
varying vec4 eye;
void main (void)
{
vec4 Spec = Add + Ambient;
vec4 Color = texture2D(colorMap, gl_TexCoord[0].st);
vec4 bump = (texture2D(bumpMap, gl_TexCoord[0].st) * 2.0) - 1.0;
float Lambert = dot(ld, bump) * gl_LightSource[0].position.w;
float Nhalf = pow(max(dot(reflect(-ld, bump), eye), 0.0), Material.x) * Material.z;
Spec = (Nhalf * gl_LightSource[0].diffuse) + Spec;
vec4 Diffuse = Ambient + ((Lambert * gl_LightSource[0].diffuse) * gl_LightSource[0].diffuse.w);
vec4 RCoord = reflect(gl_TexCoord[7], bump);
vec4 Ref = textureCube(Shadow, RCoord.xyz);
gl_FragColor = Ref;
}
I’ve tried solutions found on this forum and others, but they just made things worse. I think, there’s something wrong outside shaders, in my program. Or why else i was forced to switch TBN axes and inverse tangent for normal mapping. I did it by brute-force, would love to read what can cause weird reflections\switched TBN.
My weakness: Matrices/Transformation spaces, matrix stack management. -Really hight chances i screwed up there.