shadow problem
shadow problem
Hi I am pretty new in designing effects with irrlicht. I have some problems with shadow even I looked at the tutorial about effects where niko shows the dynamic shadow and light.
So I tried it my self with a simple mesh and no dynamic shadow--- and it won't work.
Here are some basic questions:
1. it didn't make any differences wether I created a ILightSceneNode or not? do I have do create a lightscenenode in order to get shadows? if yes do I have to do anything with the lightscenenode besides creating it?
2.Do I have to do anything else than this:
marker->addShadowVolumeSceneNode();
smgr->setShadowColor(irr::video::SColor(220,0,0,0));
to create a shadow? Where do I have to set the position of the shadow if I don't need the light?
3. Do I need that world created in the tutorial around the mesh? Or should I see the shadow even on the pure background color or on an image?
4. If I have done anything right, why won't I see the shadow?
Thanks in advance
So I tried it my self with a simple mesh and no dynamic shadow--- and it won't work.
Here are some basic questions:
1. it didn't make any differences wether I created a ILightSceneNode or not? do I have do create a lightscenenode in order to get shadows? if yes do I have to do anything with the lightscenenode besides creating it?
2.Do I have to do anything else than this:
marker->addShadowVolumeSceneNode();
smgr->setShadowColor(irr::video::SColor(220,0,0,0));
to create a shadow? Where do I have to set the position of the shadow if I don't need the light?
3. Do I need that world created in the tutorial around the mesh? Or should I see the shadow even on the pure background color or on an image?
4. If I have done anything right, why won't I see the shadow?
Thanks in advance
-
- Posts: 37
- Joined: Fri Jul 02, 2004 5:36 pm
- Location: Albany, NY
- Contact:
Yes, you need to create a light - and then, to see the shadow, you're going to have to have whatever's casting the shadow somewhere inbetween the light and some sort of surface for the shadow to be drawn on.
------------------------------------------
A monkey poured coffee in my boots.
------------------------------------------
A monkey poured coffee in my boots.
------------------------------------------
-
- Posts: 360
- Joined: Tue Feb 10, 2004 2:20 am
- Location: Lubbock, TX
What his whole post means is that you have to have one object, take the ground for instance, and another object, say a person, and a light. These objects must be in a row such as light, then a person, then the ground, just as the same if you step outside.What do you mean with "whatever's casting the shadow"?
Now all you need to cast a shadow is import a mesh of the ground (This could really be anything you wanted) then another mesh of a person(This also could be anything you wanted) and then create a light or dynamic light. As long the scene would cast a shadow in real life(This does not mean reflected light and such) then it will cast a scene in Irrlicht if you have it set up to do so. Also you should use directx instead of opengl as I do not believe that shadows work as well in opengl yet as they do in directx.
Ok I did that, but it is not working.
Where is the error?
Code: Select all
int main(){
irr::IrrlichtDevice *device = irr::createDevice(irr::video::EDT_DIRECTX9, irr::core::dimension2d<irr::s32>(512, 384), 16, false, false, 0);
irr::video::IVideoDriver* driver = device->getVideoDriver();
irr::scene::ISceneManager* smgr = device->getSceneManager();
irr::scene::ICameraSceneNode* camera = smgr->addCameraSceneNode(0,irr::core::vector3df(0.0f, 0.0f, -10.0f),irr::core::vector3df(0,0,0));
irr::scene::IAnimatedMesh* MyMesh = device->getSceneManager()->getMesh("figure.ms3d");
irr::scene::IAnimatedMeshSceneNode* mynode= smgr->addAnimatedMeshSceneNode(MyMesh,0,-1,irr::core::vector3df(1,2,0),irr::core::vector3df(0.0f,0.0f,0.0f),irr::core::vector3df(0.05f,0.05f,0.05f));
mynode->setMaterialTexture(0, driver->getTexture("cloth.JPG"));
mynode->setMaterialFlag(irr::video::EMF_LIGHTING, false);
//GROUND
irr::scene::IAnimatedMesh* MyUnderMesh = device->getSceneManager()->getMesh("cube.3ds");
irr::scene::IAnimatedMeshSceneNode* underground = smgr->addAnimatedMeshSceneNode(MyUnderMesh,0,-1,irr::core::vector3df(1,-2,0),irr::core::vector3df(-35.0f,0.0f,0.0f),irr::core::vector3df(0.5f,0.03f,0.1f));
underground->setMaterialTexture(0, driver->getTexture("gr.jpg"));
underground->setMaterialFlag(irr::video::EMF_LIGHTING, false);
//LIGHT
irr::scene::ILightSceneNode* node = smgr->addLightSceneNode(0, irr::core::vector3df(1,1,1),
irr::video::SColorf(1.0f, 0.6f, 0.7f, 1.0f), 800.0f);
irr::video::SLight *lm =&node->getLightData();
lm->DiffuseColor = irr::video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
mynode->addShadowVolumeSceneNode();
smgr->setShadowColor(irr::video::SColor(0,0,0,0));
while(device->run()) {
driver->beginScene(true, true, irr::video::SColor(0,50,50,50));
smgr->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
-
- Posts: 360
- Joined: Tue Feb 10, 2004 2:20 am
- Location: Lubbock, TX
try chaning
to
Code: Select all
underground->setMaterialFlag(irr::video::EMF_LIGHTING, false);
Code: Select all
underground->setMaterialFlag(irr::video::EMF_LIGHTING, true);
I'm fairly sure you also need to enable the stencil buffer for shadows... I could be wrong, but try using the line
(Note the last-but-one parameter is now true)
See the api docs for more info:
http://irrlicht.sourceforge.net/docu/na ... .html#a177
Code: Select all
irr::IrrlichtDevice *device = irr::createDevice(irr::video::EDT_DIRECTX9, irr::core::dimension2d<irr::s32>(512, 384), 16, false, true, 0);
See the api docs for more info:
http://irrlicht.sourceforge.net/docu/na ... .html#a177
mmmh, doesn't work...
in the api it says: Specifies if the stencil buffer should be enabled. Set this to true, if you want the engine be able to draw stencil buffer shadows. Note that not all devices are able to use the stencil buffer. If they don't no shadows will be drawn.
So which device is not able to? because it seems as mine is not...
the other suggestion made the downsite of the underground black but no shadow from the mesh on the underground is drawn on top of the cube.
in the api it says: Specifies if the stencil buffer should be enabled. Set this to true, if you want the engine be able to draw stencil buffer shadows. Note that not all devices are able to use the stencil buffer. If they don't no shadows will be drawn.
So which device is not able to? because it seems as mine is not...
the other suggestion made the downsite of the underground black but no shadow from the mesh on the underground is drawn on top of the cube.
-
- Posts: 360
- Joined: Tue Feb 10, 2004 2:20 am
- Location: Lubbock, TX
not entirely sure what you mean by the sentance above. but did you do this:Anonymous wrote:the other suggestion made the downsite of the underground black but no shadow from the mesh on the underground is drawn on top of the cube.
Code: Select all
underground->setMaterialFlag(irr::video::EMF_LIGHTING, false);
-
- Posts: 360
- Joined: Tue Feb 10, 2004 2:20 am
- Location: Lubbock, TX
Ahhh I think I see the problem. It is this line of code I think:
Correct me if I am wrong but you have set the alpha value, the first value in SColor, to 0 which would make it a completly transparent shadow!
Try something like this
for a nice slightly transparent shadow
Code: Select all
smgr->setShadowColor(irr::video::SColor(0,0,0,0));
Try something like this
Code: Select all
smgr->setShadowColor(irr::video::SColor(180,0,0,0));
-
- Posts: 360
- Joined: Tue Feb 10, 2004 2:20 am
- Location: Lubbock, TX