Jump to content
  • Advertisement
Sign in to follow this  
supagu

back projections - clipping planes

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

how do i extract planes for plane clipping for my projective textures in OGL? i guess glClipPlane is in world space?

Share this post


Link to post
Share on other sites
Advertisement
okay, here's the new problem:

http://mathewstwins.customer.netspace.net.au/temp/leftPlane.JPG

the red line show where the left clip plane should be, as you can see the left plane is bent out left more.

i used the plane extraction from here:
http://www2.ravensoft.com/users/ggribb/plane%20extraction.pdf

i double checked these values, so im wondering if its my lights transform is screwey possibly?

just to show you (the right clip plane is correct):

// the following are plane extractions from matrices
// http://www2.ravensoft.com/users/ggribb/plane%20extraction.pdf
void ExtractLeft(Matrix4& transform)
{
p[0] = transform[3] + transform[0];
p[1] = transform[7] + transform[4];
p[2] = transform[11] + transform[8];
p[3] = transform[15] + transform[12];
}

void ExtractRight(Matrix4& transform)
{
p[0] = transform[3] - transform[0];
p[1] = transform[7] - transform[4];
p[2] = transform[11] - transform[8];
p[3] = transform[15] - transform[12];
}




and this is how i setup my projective texture:

void ShadowLight::SetTextureProjection()
{
Camera& camera = *Engine::GetInstance()->GetRenderMgr()->GetActiveCamera();

Matrix4 mBias(0.5, 0.0, 0.0, 0.0,
0.0, 0.5, 0.0, 0.0,
0.0, 0.0, 0.494, 0.0, //offset bias so we dont need polygonfill offset
0.5, 0.5, 0.5, 1.0);

glMatrixMode(GL_TEXTURE);

mBias.Set();

gluPerspective(45.0f, 1.0f, 1.0f, 6.0f);

Matrix4 trans = GetTransform();
trans.SetM();

Matrix4 temp;
temp.LoadCurrent(GL_TEXTURE_MATRIX);
SetClipPlanes(temp);

Matrix4 cam = camera.GetTransform();
//cam.Inverse(); //Transpose();
cam[12] = 0;
cam[13] = 0;
cam[14] = 0;
cam.Transpose();

glTranslatef(camera.GetPosition()[0], camera.GetPosition()[1], camera.GetPosition()[2]);
cam.SetM();

glMatrixMode(GL_MODELVIEW);
}

void ShadowLight::SetClipPlanes(Matrix4& transform)
{
// http://www2.ravensoft.com/users/ggribb/plane%20extraction.pdf

Plane left, right, top, bottom, farp, nearp;
left.ExtractLeft(transform);
right.ExtractRight(transform);
top.ExtractTop(transform);
bottom.ExtractBottom(transform);
farp.ExtractFar(transform);
nearp.ExtractNear(transform);

left.Normalize();
right.Normalize();
top.Normalize();
bottom.Normalize();
farp.Normalize();
nearp.Normalize();

left.BindClipPlane(1);
right.BindClipPlane(0);
top.BindClipPlane(2);
bottom.BindClipPlane(3);
farp.BindClipPlane(4);
nearp.BindClipPlane(5);
}

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.

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!