Frustum Culling "radar approach": failed first test?

Trying to get at least a very simple part 1 of the Lighthouse3D Radar Frustum Culling tutorial for work ... and I'm completely puzzled that I can't even get this part to work in my renderer.

So, the first step: you check whether the point is in front of the nearest plane or behind the long-range plan, and early rejection if this happens. (If not, then you do additional tests, but I was stuck with this very first part.)

I use the center world-space (x1y2z3) of a 2x2 cube and have a camera that I can move and rotate freely. All of my vector and matrix material should be strong enough, since rendering otherwise works fine. So, here is my trick (in Go) of this first part, a simple "Z vs near-or-far" test:

func (cam *Camera) frustumHasPoint(point *Vec3) bool { var pc Vec3 v := point.Sub(&cam.Controller.Pos) // point minus camPos ref := cam.Controller.dir // take a copy of camDir ref.Z = -ref.Z ref.Normalize() // camDir was already normalized but anyway... pc.Z = v.Dot(&ref) if pc.Z > cam.Perspective.ZFar || pc.Z < cam.Perspective.ZNear { return false } return true } 

Now why am I canceling Z ref? Because in the textbook they write: "Please note that the reference in the picture is not the right hand (as in OpenGL), since the Z orientation has been canceled to make the tutorial more intuitive" - โ€‹โ€‹well, in the GL tutorial, of course, this has the opposite effect ...

Well, if you do the opposite Z, as indicated above, it takes more than should be about 50% of the time; if I donโ€™t, then he โ€œoverfulfillsโ€ about 98% of the time.

What am I missing?

+6
source share
1 answer

Decided. The reason was a brain malfunction ... the textbook clearly writes about getting the x / y / z axes first to describe a truncated cone, one way or another I missed it.

+1
source

All Articles