Projection textures

Hi.,

Well, i’m still having a problem related with projection textures.,
The thing is, the reflection is perfectly correct when the shader is not active, when the shader is active, the projection seems to come down.
Actually, it’s logic that she comes down, but i’m not looking in another way to do this.
Please, take a look at the shots and the shader.
The projection gets worse as the camera gets near the level of the water

The shader :

uniform sampler2D Texture0;
uniform sampler2D Texture1;
uniform sampler2D Texture2;
uniform float time;
uniform float YY;


void main(void)
{

vec4 normal_map = texture2D(Texture2, vec2(gl_TexCoord[2]) );
vec4 difuse_map = texture2D(Texture1, vec2(gl_TexCoord[1]) );

vec4 newtexcoords;
newtexcoords.x = gl_TexCoord[0].x + normal_map.x;
newtexcoords.y = gl_TexCoord[0].y + normal_map.y;
newtexcoords.z = gl_TexCoord[0].z;
newtexcoords.w = gl_TexCoord[0].w;


gl_FragColor = texture2DProj(Texture0, newtexcoords);

}

The shots,

bad1

bad2

bad3

thanks,
Bruno

Does it help if you do the perspective divide on newtexcoords yourself, before you offset it using the normal map, and then use a non-projective lookup? I.e.:

newtexcoords.x = gl_TexCoord[0].x/gl_TexCoord[0].w + normal_map.x;
newtexcoords.y = gl_TexCoord[0].y/gl_TexCoord[0].w + normal_map.y;
gl_FragColor = texture2D(Texture0, newtexcoords);

– Tom

no luck Tom., doens’t work :frowning:

Don’t you need to expand the normal map?

vec4 normal_map = texture2D(Texture2, vec2(gl_TexCoord[2]) ) * 2.0 - 1.0;

Thanks Humus, that did it., but i’m lost.
Why doing that, fixed the problem ?

Well, effectively you were adding a constant 0.5 + an offset when you really intended to add an offset only.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.