Shadows on Terrain

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
themartian
Posts: 2
Joined: Thu Oct 06, 2016 6:50 pm

Shadows on Terrain

Post by themartian »

So I started with the samples, put a sun in a scene, clouds, terrain, and then dropped the little animated viking dude on the terrain and noticed there was no shadow being cast from him onto the terrain.
If I look at the shadow sample (it uses a plain instead of terrain) it works there.

I have since been through every sample I could find, google, forums, website trying to get an animated model that runs around on the terrain to cast a shadow on the terrain. no luck.

Does someone have an actually working code sample that works, where a model (like a player that walks across the terrain) that will cast a shadow on the terrain? would be nice to not be a hack where you just put a blob shadow down, but
and actual shadow that you can see on the terrain?

Thank you in advance!
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Shadows on Terrain

Post by Mel »

If you're using Direct3D, the stencil shadows are disabled, use OpenGL instead, or use a shadow mapping technique.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Foaly
Posts: 142
Joined: Tue Apr 15, 2014 8:45 am
Location: Germany

Re: Shadows on Terrain

Post by Foaly »

What? Since when are stencil shadows disabled for d3d?
AReichl
Posts: 268
Joined: Wed Jul 13, 2011 2:34 pm

Re: Shadows on Terrain

Post by AReichl »

I am guessing now, but i think Mel means the Demo that comes with Irrlicht - there you don't have shadows with d3d ( OpenGL works ok ).
But the problem must be somewhere inside the demo code, because 'SpecialFX' has working shadows with d3d and OpenGL.
Foaly
Posts: 142
Joined: Tue Apr 15, 2014 8:45 am
Location: Germany

Re: Shadows on Terrain

Post by Foaly »

You're right, shadows are messed up with d3d for some reason.
In a test application, they also make the hud disappear for some reason.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Shadows on Terrain

Post by Mel »

The stencil shadows have some problems yet to be solved, namely the adjacency calculations producing random "infinite shadow projection" artifacts (those large streaks that appear randomly on the shadows, they disappear when the adjacency calculations aren't used), and some bias on the ZBuffer that cause cracks to appear on the shadows themselves. As for the HUD disappereances, that is mostly due to how the stencil shadows are drawn, after the stencil buffer is calculated, a screen aligned quad is drawn using a material which performs a stencil test: any pixel that has a value greater than 1 in the stencil buffer is drawn, and the rest are left untouched.

Ah, my bad, indeed, the special FX example has stencil shadows enabled. I don't know why they aren't working on the demo. Maybe they don't enable the stencil buffer when creating the D3D device?...
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
themartian
Posts: 2
Joined: Thu Oct 06, 2016 6:50 pm

Re: Shadows on Terrain

Post by themartian »

still haven't had much luck, even using the opengl options

Image

tried all sorts of settings not only to light the dwarf, but to try and cast a shadow on terrain.
Post Reply