What does IShadowVolumeSceneNode do?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
dart_theg
Posts: 68
Joined: Sun Dec 29, 2024 3:13 am

What does IShadowVolumeSceneNode do?

Post by dart_theg »

I think I'm misusing this node. Does it make it so nodes cast a shadow? Or gives them a shadow?
Noiecity
Posts: 363
Joined: Wed Aug 23, 2023 7:22 pm
Contact:

Re: What does IShadowVolumeSceneNode do?

Post by Noiecity »

will generally cause it to produce a shadow cast on the surface of another model or on top of the same model, the other shadows are achieved with gouraud shading and dynamic lighting by default
Irrlicht is love, Irrlicht is life, long live to Irrlicht
CuteAlien
Admin
Posts: 9969
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: What does IShadowVolumeSceneNode do?

Post by CuteAlien »

First it creates a shadow volume. That are polygons which extends the edges of your models away from the lights (one shadow volume per light which is close enough). That works best if the model is "closed" aka - when put water in the model it will stay inside. Which edges are extended depens on setOptimization setting in IShadowVolumeSceneNode - by default it tries to find a silhouette and only extend those. But for models where this isn't working it's also possible to extend every triangle (you'll see if it works or fails - when it fails you get long black lines). Usually the better option is to fix the model, but you might not always be able to do that.

Then in the second step the node renders those shadow volumes to the stencil buffer in a bit specific way. There's 2 algorithms implemented zPass and zFail - you can experiment with both of them. Each has it's areas where it shines and fails I think. For reasons I don't remember it's a bit of a counting thing how many shadow volume polygons are passed at each point and the result has to be odd or even or something like that for a shadow to be drawn. Pretty sure you can find some better info on the web (I learned it once a few years ago, but would have to read up on it again). (edit: Odd number of shadow polygons passed should mean a point is inside the shadow - which will mess up if the camera or light starts inside an object, so that should be avoided)

Then the node tells the scenemanager - I've got stuff in the stencil buffer (SceneManager->requestDrawShadowPassStencilShadow). If that's so the SceneManager will call drawStencilShadow in it's shadow pass (after solids, before transparent stuff). And that's basically adding the shadow color to all the places marked in the stencil buffer.
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
dart_theg
Posts: 68
Joined: Sun Dec 29, 2024 3:13 am

Re: What does IShadowVolumeSceneNode do?

Post by dart_theg »

Great explanation! Thank you
Post Reply