Page 1 of 1

Terrain Shadow Casting

Posted: Sun Feb 26, 2017 8:52 pm
by mistral
Hi,

Thought I'd found some threads on this before but not finding now.

Is there a way for an ITerrainSceneNode to cast shadows? Even if this means having to copy out the mesh (e.g. what best method?)


Usually I just use something like:

Code: Select all

 
        o->addShadowVolumeSceneNode();
        o->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
 

Re: Terrain Shadow Casting

Posted: Mon Feb 27, 2017 12:12 pm
by Mel
For any (animated) mesh you can attach a shadow volume scene node to it. Irrlicht will calculate a shadow volume for each face of the mesh each frame, and using the stencil buffer, will render a shadowed version of the scene.

The point is what are you trying to do? to generate the shadows of the terrain?, or that the models cast shadows over the terrain? :?

In the first case, you can calculate the shadow volume of the terrain by yourself, and provide it as shadow volume to the terrain, in the second case, you can just attach a shadow volume to every node you want to cast shadows, and that should do it

Re: Terrain Shadow Casting

Posted: Tue Feb 28, 2017 4:09 pm
by mistral
Hi and thanks,

I am after the actual terrain to cast shadows on itself.

I tried simply casting the terrain to an animated mesh and enable the shadow volume, which compiled but promptly crashed when run.

How would one achieve this "you can calculate the shadow volume of the terrain by yourself" please?

Re: Terrain Shadow Casting

Posted: Fri Mar 03, 2017 10:29 am
by Mel
I would pick each triangle of the terrain facing the light and generate an extrusion to it, and then, i would provide this set of extrusions to the shadow node as a single mesh. Pro: it doesn't have to be calculated each time, con, it only works on a single light direction and not with the geomipmap terrain, whose mesh is dynamic (there is a terrain primitive though that would work perfectly with this approach) If you want shadows casted on a geomipmapped terrain, you could do use shadow maps instead of shadow volumes