Wrong 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
Greeg
Posts: 11
Joined: Wed Nov 25, 2015 11:57 am

Wrong shadows

Post by Greeg »

Incorrect shade. Moreover, the shadows do not always work. That arise and disappear at different rotations of the camera.

Code: Select all

 
 IrrlichtDevice *device = createDevice(video::EDT_OPENGL,
 core::dimension2d<u32>(screenW,screenH),32, false, true); 
 
     device->getCursorControl()->setVisible(false);
 
    video::IVideoDriver* driver = device->getVideoDriver();
 
    scene::ISceneManager* scenemgr = device->getSceneManager();
 
    gui::IGUIEnvironment* env = device->getGUIEnvironment();
 
    scene::ISceneNode* skydome=scenemgr->addSkyDomeSceneNode(driver->getTexture("media/sky.png"),32,16,0.95f,16.0f);
 
    device->setWindowCaption(L"Hello World!");
 
        scene::IAnimatedMeshSceneNode* node = scenemgr->addAnimatedMeshSceneNode(
        scenemgr->getMesh("media/Scene.3ds"));
        //scenemgr->getMesh("media/Box.3ds"));
        ILightSceneNode *light = 0;
    if (node)
    {
        node->setMaterialTexture(2, driver->getTexture("media/wall.jpg"));
        node->setMaterialType(video::EMT_LIGHTMAP_LIGHTING);
        node->setMaterialFlag(video::EMF_LIGHTING, false);
        node->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false);
        node->addShadowVolumeSceneNode();   
    }
    light = scenemgr->addLightSceneNode( 0, irr::core::vector3df( 12000.0f, 20000.0f, 1700.0f) , SColorf( 1.0f, 1.0f, 1.0f, 0.0f ), 200000.0f );
if( light ) {
   //light->setDebugDataVisible( EDS_BBOX );
   light->enableCastShadow( true );
   //light->setVisible( true );
}
     scenemgr->setShadowColor( SColor( 150, 0, 0, 0 ) );
 
Image
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Wrong shadows

Post by CuteAlien »

Yeah shadows have a problem when the camera light and object are in a line. Not quite sure right now if it was camera behind light or light behind camera. Also note that this kind of shadows only works for closed object (the kind where you could keep water inside).
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: Wrong shadows

Post by Mel »

It was when the camera was inside the shadow volume, there is a parameter that fixed this though, the "useZfailMethod", the third parameter of "addShadowVolumeSceneNode". By default is set to false, try setting it to "true"
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Greeg
Posts: 11
Joined: Wed Nov 25, 2015 11:57 am

Re: Wrong shadows

Post by Greeg »

Thanks for your help. Already better. I was setted "useZfailMethod" in false. Now shadows like 3d object. But safe few problems(p).
p1- With 2-sides faces. I can,t take control on this process in my big model. I wish use 2-sided material (if it work in shadow mapping) or I may be can flip normals in run cycle. How flip normals? BACK_FACE_CULLING not work for this purpose. May be it will help me.
p2 - How make closed object? I'm use 3ds models. May be created object as "solid" in 3ds . Or I mast use another format of model for this. (Welding don't help me)

And, me liked idea of making shadows like mesh. Before, I think use rendered shadow ))
and p3 - Ambient light. How make it? I't is may be? ))

Thanks for your help.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Wrong shadows

Post by Mel »

For irrlicht a good recomendation is that you always use closed meshes so there are always faces to feed the shadow volumen creation.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Post Reply