Projective Texturing Artifacts

Started by
-1 comments, last by WinstonPennypacker 16 years, 9 months ago
Hey all, I'm using projective texturing to reflect the world about my water plane in it's shader. In the pixel shader I perturb the reflection by adding the the bumped Normal value to the projected texture coordinates. When it renders, though, if the window clips any of the reflected geometry, it wraps around to the other side. I'm sure this is due to to adding the bumped normal value to the tex coords, but I really don't know how to solve this. Here's some of my code- Vertex Shader - ( HPosition is the vert position transformed to homogeneous clip space )

    OUT.TexProj.x = 0.5f * ( OUT.HPosition.w + OUT.HPosition.x );	
    OUT.TexProj.y = 0.5f * ( OUT.HPosition.w - OUT.HPosition.y );	
    OUT.TexProj.z = OUT.HPosition.w;	

Pixel Shader ( Nn is the final bumped normal )

    float2 projTexCoord = ( IN.TexProj.xy / IN.TexProj.z );
    float4 planeReflect = tex2D( ReflectionSampler, projTexCoord + Nn.y  );

This all works fine and does a perfect reflection if I don't add in the Normal value, but I can't figure out what to clamp or change to make this behavior go away. Mostly I'm confused about what is contained in the 'w' coordinate of the HPosition, as I didn't write the projective texturing algorithm. Any help is greatly appreciated.

This topic is closed to new replies.

Advertisement