Frustum culling - getting the "d" component of the frustum planes

Started by
5 comments, last by JoeJ 1 month ago

I have a camera, the normals of every 6 frustum planes, and their center position, I'm new to frustum culling, and got everything I know from this video:

But the video doesn't explain how to properly calculate the “d” component of the planes, just a brief explanation about what it represents, any help is appreciated.

Advertisement

d likely means the distance of the plane to the origin, which is all you need to describe it's position.

If we have a point p (e.g. one arbitrary point on the frustum pyramid adjacent to the plane),
and a direction n (the normal of the plane), we can describe the plane in two ways:

p and n, requiring two vec3.

Or just n and the distance of point p to the origin along the direction given by n, requiring only one vec4.

Assuming n is a unit vector, we can calculate the distance simply by:

float d = dot(n, p)

But depending on convention, people often use:

float d = -dot(n, p)

The plane is then usually written as:

vec4(n, d)

The video says that d * n must be (0,0,0), but I don't get this result calculating d the way you suggested, as I said I have the central point of the planes, and I used it as the “p” when visualizing these values in the output I get:

(these values are from only one of the planes)
Normal = -0.33765435218811035, -0.9396908283233643, 0.054503630846738815
Plane point = -955.7437133789062, 7.733208656311035, -10.713802337646484
d = 314.8602600097656
d times n = -106.31393432617188, -295.8713073730469, 17.161027908325195

when d times n should be 0 according to the video, does this affect anything when detecting objects inside and outside the frustum (with the method described at the end of the video)? Btw is everything in that video correct?

p02 said:
The video says that d * n must be (0,0,0)

This would mean that d must be zero. Without watching the video and lacking context, this makes little sense.

At what time does he say this?

p02 said:
Btw is everything in that video correct?

Looking at the code he shows to check a sphere, it seems correct.

Ok, just the last part of the video with what you said, I think I interpreted the video explanation wrong, but it's working with your solution, I made my code print true when X object is inside the viewport, and false when outside, just had to make

float d = -dot(n, p)

as you said, it's printing correctly so thank you!

Btw how do I mark an answer as the solution in this forum? I'm new here.

p02 said:
Btw how do I mark an answer as the solution in this forum? I'm new here.

There is no such mark here. Only Mods can close topics manually eventually.

This topic is closed to new replies.

Advertisement