Jump to content
  • Advertisement
Sign in to follow this  

Clip plane problem

This topic is 2797 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'm currently working on creating a reflection map for the water, and I'm using a clip plane so that I can only draw into the texture the geometry above the water.
Here's is my code:

D3DXPLANE refractionClipPlane;
D3DXVECTOR3 point(0.0f, 6.0f, 0.0f);
D3DXVECTOR3 normal(0.0f, 1.0f, 0.0f);
D3DXPLANE outRefraction;
refractionMap->beginScene(); //refraction map is a renderTarget
gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xff000000, 1.0f, 0);
gd3dDevice->SetClipPlane(0, outRefraction);
drawReflectedByWater(); //draw geometry
refractionMap->endScene(); //render target ends

I have this problem, if I only move the camera's position DirectX draws the scene perfectly:
[IMG]http://img842.imageshack.us/img842/1033/clipplaneproblem1.jpg' alt='clipplaneproblem1.jpg'> Uploaded with ImageShack.us[/img]

But if I change the camera look vector, for instance, if I aim the camera to the sky the clip plane moves along with te camera too:
[IMG]http://img696.imageshack.us/img696/6255/clipplaneproblem2.jpg' alt='clipplaneproblem2.jpg'> Uploaded with ImageShack.us[/img]

As you can see from my code, I've taken into account that if you are not using the fixed pipeline the plane has to be in clipspace coordinates.
Anyone knows what can I do in order to avoid this problem (plane moving along with the camera)?

Share this post

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

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!