• Advertisement
Sign in to follow this  

Projective Texturing Artifacts

This topic is 3938 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement