one last item that I need to resolve and then I can wrap all of this up neatly into a nice scenenode class.
using the camera frustum instead of the camera bounding box helps tremendously with the speed so I want to keep that, however, the grass meshes that I use are actually 'patches' of grass that are randomly rotated to help cover larger area with less calls. Since the camera frustum is exactly the same as the view by definition, there is some popping at the near plane as the patch 'origin' is outside of the frustum but the patch bounding box is not. To prevent this I am wanting to get a copy of the frustum and use it to calculate which patches are visible (working great) but I need modify the frustum copy to 'reposition' the near plane a bit back, thus preventing the culling of the grass patches that break that barrier.
I have spent a good part of today trying to realize this but apparently have no clue how to calculate what the near plane would be if it were moved back behind the camera some amount.
can you point me in the right direction?
framerate issues
Re: framerate issues
Basically move all planes a bit to the outside:
edit: Alternative, which is slower but doesn't work with a fixed offset (in case you got objects with different sizes and don't just want to use the radius of the biggest object for all of them), would be to subtract the plane.normal * object.radius from your object center directly where you do the checks against the planes.
Code: Select all
// making sure you got the updated camera, or you'll be one frame behind
camera->updateAbsolutePosition();
camera->updateMatrices();
scene::SViewFrustum origFrustum = *camera->getViewFrustum();
scene::SViewFrustum extentedFrustum = origFrustum;
irr::f32 offset = 10.f; // use here the maximal radius of your grass
for ( int i = 0; i < scene::SViewFrustum::VF_PLANE_COUNT; ++i )
{
extentedFrustum.planes[i].recalculateD(extentedFrustum.planes[i].getMemberPoint() + extentedFrustum.planes[i].Normal * offset);
}
extentedFrustum.recalculateBoundingBox();
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: framerate issues
perfect! I was hoping to wrap it all up today and post the new scenenode, but I wont have time. I am off on vacation for the next month but will pick it all back up when I return. thanks again for the assistance! I am very pleased with how this it turning out.