Jump to content
  • Advertisement

find point between two points which intersects with plane

Recommended Posts

I want to split view frustum for shadows mapping ( CSM/PSSM ). I need to get corners of each frustum split. I already have 8 corners of view frustum and view frustum planes. So I thought that maybe I don't need to create new invViewProj matrix and get corners using clip space method, it is too expensive ( for each split )

To get center of two point/vector we use this: center = ( V1 + V2 ) * 0.5

So, using same information could give us splitted frustum corner by this:

newNearTopLeft = ( nearTopLeft + farTopLeft ) * ( near / planeDistance ) /* this plane is between far and near points */
/* repeat this for each 8 corner  */

Does the math correct? If it is correct then this will save my engine from many calculations

Edited by recp

Share this post

Link to post
Share on other sites

I think I found it! Here the code it may help someone else who don't want to use re-extract new frustum corners to split frustum.

v                       = normalize(Far - Near)
d                       = distance(Far, Near)
size                  = d * C / Far
newCorner.    = nearCorner + v * size


/* this is for one point between NEAR and FAR planes, others get calculated same */

vec3  corner;
float dist;

dist = glm_vec_distance(corners[j + 4], corners[j]);
glm_vec_sub(corners[j + 4], corners[j], corner);
glm_vec_scale_as(corner, dist * C / f, corner);

glm_vec_add(corners[j], corner, subFrustum.corners[j + 4]);


Edited by recp

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • 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!