Page 1 of 1

Strange shadows

Posted: Mon Jun 26, 2017 9:22 pm
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

Re: Strange shadows

Posted: Mon Jun 26, 2017 11:43 pm
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.

Re: Strange shadows

Posted: Tue Jun 27, 2017 3:35 pm
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.

Re: Strange shadows

Posted: Tue Jun 27, 2017 8:14 pm
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?