# 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 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

Code:

/* 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

## Create an account

Register a new account

1. 1
Rutin
22
2. 2
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633306
• Total Posts
3011287
• ### Who's Online (See full list)

There are no registered users currently online

×