Strange shadows

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
alt+255
Posts: 2
Joined: Mon Jun 26, 2017 7:41 pm

Strange shadows

Post by alt+255 »

Hi,
I will be fast (because I'm not english :D ), I have a small program where I load a .3ds file, and I add a light. The render was good, but there are no shadows on the ground, so I have added a shadow volume scene node in my mesh node. This time, the render is very disturbing, the shadows are distorded, they seems to invert themselves, and seems to "follow" the camera...
I give you an example of simplified code :

Code: Select all

 
irr::IrrlichtDevice *device = irr::createDevice( irr::video::EDT_OPENGL, irr::core::dimension2d<irr::u32>( 768, 512 ), 32, false, true, true, 0 );
irr::video::IVideoDriver *driver = ...
irr::scene::ISceneManager *sceneManager = ...
 
irr::scene::ICameraSceneNode *camera = ...
 
irr::scene::IAnimatedMeshSceneNode *myMesh = ...
    myMesh->addShadowVolumeSceneNode();
 
irr::scene::ILightSceneNode *myLight = sceneManager->addLightSceneNode( myMesh, irr::core::vector3df( 4, 5, 1 ), irr::video::SColorf( 1, 0.1, 0.1, 0 ), 100 );
 
while( device->run()){
    driver->beginScene( true, true, irr::video::SColor( 255, 182, 216, 255 ));
    sceneManager->drawAll();
    driver->endScene();
}
 
This is a very easy code, so I don't understand where is the problem, or if I forgot something...
Thanks for any help
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Strange shadows

Post by CuteAlien »

The kind of shadows which are used by default need a closed volume for the objects which throw the shadows. Closed meaning - you fill in water - it won't drop out.
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
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Strange shadows

Post by Mel »

Sometimes, the adjacency information used to speed up the shadow volumes creation isn't accurate enough, so some volumes end up "reversed" Truth is, the original model doesn't need to be closed because when the shadow volume gets built, the triangles away from the light are culled but the adjacency calculation method should be reviewed so it always provided accurate enough info. Disabling the adjacency gets correct shadow volumes, but, obviously, slows down the whole process.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
alt+255
Posts: 2
Joined: Mon Jun 26, 2017 7:41 pm

Re: Strange shadows

Post by alt+255 »

So if I have understood, I should try to disable adjacency, but after searching, I absolutly don't know how to do that. And for the 3d model, I have tried with many differents and it has never worked. After, I tried to just copy the code of one of the examples, but the program crash at line :

Code: Select all

 
scene::IVolumeLightSceneNode* n = irr::scene::ISceneManager->addVolumeLightSceneNode( 0, -1, 32, 32, video::SColor( 0, 255, 255, 255 ), video::SColor( 0, 0, 0, 0 ));
 
I don't know if it has a link with my main problem of shadows, but theorically, if this line work I must have a program with corrects shadows. (you see me coming :) ) Can you explain to me how to disable this adjency, or how to repair my copy of example?
Post Reply