Terrain Shadow Casting

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
mistral
Posts: 14
Joined: Mon Jan 23, 2017 9:35 am

Terrain Shadow Casting

Post 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);
 
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Terrain Shadow Casting

Post 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
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
mistral
Posts: 14
Joined: Mon Jan 23, 2017 9:35 am

Re: Terrain Shadow Casting

Post 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?
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Terrain Shadow Casting

Post 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
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Post Reply