Closed bjornbytes closed 1 year ago
i've got more around somewhere, but here's the aabb-frustum test i use in my games https://github.com/excessive/ludum-dare-43/blob/master/src/math/Intersect.hx#L41
lovr.graphics.frustum
to render a frustum? Mostly for debugging probably.
lovr.graphics
can just frustum cull primitives internally because it knows the camera and knows the AABBs of its primitives (can also use AABBs of Models/Meshes when they are provided). It needs to be configurable in case you have a weird vertex shader. Not sure if culling each primitive individually as it's about to be drawn isn't too slow/awful compared to something more fancy.
But also the new physics stuff will also have some kind of Frustum object in case you want to do custom tests/culling/clustering. Headset still ought to expose getFrustum that returns data for one of these objects.
LÖVR should give you the tools you need to do frustum culling (without actually trying to do it for you).
This is an interesting problem for VR because there are two cameras and each one has a frustum. Some magic math will need to be used to combine the two frusta into a single one. That combined frustum can be exposed by lovr.headset. I'm not sure what format is best to represent a frustum: mat4? 6 planes? How are planes represented?
From there, there's probably something in lovr.math like
mat4:contains
orlovr.math.testFrustum
that is able to test things against frusta. You could use your own or the one returned from lovr.headset.When doing the actual tests, need to think about: