I want to make use of the camera far clipping plane to reduce large terrain drawing distance yet also have exemptions to override any clipping like very distant planets and sun mesh using a 3D plane - so keep them rendered always within the view frustum.
I am using the fixed function pipeline as default.
Can this be done ? and if so how ?
I tried per material to switch off culling for transparent materials (for planet and sun etc) and back on but once switched off would not come back again for solid materials (SetRenderState(D3DRS_CLIPPING,TRUE/FALSE) - even when adding as true in the unset material section.
The last post mentioned if the material was rendered through HLSL then clipping would not occur - is that right ?
Far Clipping Plane & exceptions
Re: Far Clipping Plane & exceptions
It sounds like a problem of render ordering. The problem with transparent materials is that they are drawn last - and you want the distant stuff to draw first.
One trick I sometimes use is having more than one scenemanager. In your case you can put large distance stuff in a second scenemanager and draw all objects in that one first. Then clear the depth buffer (but not anything else) and draw the other scene with stuff closer by.
One trick I sometimes use is having more than one scenemanager. In your case you can put large distance stuff in a second scenemanager and draw all objects in that one first. Then clear the depth buffer (but not anything else) and draw the other scene with stuff closer by.
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
-
- Posts: 14
- Joined: Thu May 24, 2018 6:43 pm
- Location: USA
Re: Far Clipping Plane & exceptions
Actually, it’s just a matter of setting the clipping distance in the vertex shader. Then you can do anything you want in terms of clipping.The last post mentioned if the material was rendered through HLSL then clipping would not occur - is that right ?
-
- Posts: 9
- Joined: Sun Sep 24, 2023 5:48 am
Re: Far Clipping Plane & exceptions
Thanks for the responses - I do prefer to keep all material as FFP however instead of creating a new transparent material in HLSL.
I noticed the skybox and skydome are not clipped as they are drawn before most other things as counted in the ESNRP_SKY_BOX render pass - I thought that this might be this issue actually and was wondering how do I add existing 3d mesh to be drawn as part of this render pass instead ?
I tried using: SceneManager->registerNodeForRendering(node, scene::ESNRP_SKY_BOX); but it seems that when rendering it is trying to run the render code that is suited to the skybox and not the code needed for the actual 3d mesh is that right ?
(I'm not fully sure how the void CFlaceMeshSceneNode::render() part works - yes, this is CopperCube)
I added a new section within the CFlaceMeshSceneNode class to segregate non clipped mesh and try and render them while its in the skybox pass
bool isSkyBoxPass = SceneManager->getSceneNodeRenderPass() == scene::ESNRP_SKY_BOX;
but this didn't work for some reason...
what code would I need to run a separate scene manager for the selected items ?
can you suggest any code snippets at all ?
I noticed the skybox and skydome are not clipped as they are drawn before most other things as counted in the ESNRP_SKY_BOX render pass - I thought that this might be this issue actually and was wondering how do I add existing 3d mesh to be drawn as part of this render pass instead ?
I tried using: SceneManager->registerNodeForRendering(node, scene::ESNRP_SKY_BOX); but it seems that when rendering it is trying to run the render code that is suited to the skybox and not the code needed for the actual 3d mesh is that right ?
(I'm not fully sure how the void CFlaceMeshSceneNode::render() part works - yes, this is CopperCube)
I added a new section within the CFlaceMeshSceneNode class to segregate non clipped mesh and try and render them while its in the skybox pass
bool isSkyBoxPass = SceneManager->getSceneNodeRenderPass() == scene::ESNRP_SKY_BOX;
but this didn't work for some reason...
what code would I need to run a separate scene manager for the selected items ?
can you suggest any code snippets at all ?
Re: Far Clipping Plane & exceptions
Yeah, using ESNRP_SKY_BOX more or less also affects the order. One problem is that it doesn't work with CMeshSceneNode which uses that pass for shadow volumes. But the other is that it still writes to the z-buffer (depth buffer). And if you want to ensure stuff is in the background - you want to reset the z-buffer afterwards so all later things are drawn in the front. You could do that by using own scenenodes and then reset in between with a light-manager, but that's unnecessarily complicated.
Second scenemanger is easy: createNewSceneManager can create a new one from the first one you have (function in ISceneManager). Then just add the far away nodes into that one. And render them both with drawAll() with those with the far away nodes first. And in between the 2 drawAll calls you do a driver->clearBuffers call. Parameters depend on if you use 1.8 or trunk. With trunk it should be driver->clearBuffers(ECBF_DEPTH);
Second scenemanger is easy: createNewSceneManager can create a new one from the first one you have (function in ISceneManager). Then just add the far away nodes into that one. And render them both with drawAll() with those with the far away nodes first. And in between the 2 drawAll calls you do a driver->clearBuffers call. Parameters depend on if you use 1.8 or trunk. With trunk it should be driver->clearBuffers(ECBF_DEPTH);
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