Jump to content
  • Advertisement
Sign in to follow this  
Nizro

Rotating reflective plane

This topic is 4836 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

I've been working on implementing a reflective water plane, that should reflect using only a single render-to-texture of my reflected terrain - instead of a cubemap. Now, I've got the reflected render-to-texture correct, and I only need to put this on to the water-plane using projective texturing. I've come as far as having an almost correct projection, but one problem still lies: the reflection goes 'upwards' (look here - it's the clean one behind. You should see them going like a 90 degree angle) instead of following the water-plane. How do I correct this? I suggest some sort of rotation, but all my tries have been worthless. Here's my code for reference: VS:
float4x4 matWorldViewProjection;

struct VS_OUTPUT 
{
   float4 Pos:              POSITION;
   float4 TexCoord:         TEXCOORD0;
};

struct VS_INPUT
{
   float3 Pos:              POSITION;
   float2 TexCoord:         TEXCOORD0;
};

VS_OUTPUT vs_main( VS_INPUT In )
{
   VS_OUTPUT Out;

   Out.Pos = mul(float4(In.Pos.x, In.Pos.y, In.Pos.z, 1.0f), matWorldViewProjection);

   Out.TexCoord = (Out.Pos.xyzw + Out.Pos.wwww) * 0.5;

   return Out;
}

PS:
sampler texWater: register(s0);

struct PS_INPUT
{
   float4 Pos:              POSITION;
   float4 TexCoord:         TEXCOORD0;
};

float4 ps_main( PS_INPUT In ) : COLOR0
{
   // Texture component  
   float4 Water = tex2Dproj(texWater, In.TexCoord);

   return Water;
}

Thanks in advance, Nick Bruun

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!