Shadow Casting Issue

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
KrisG
Posts: 6
Joined: Wed Jul 16, 2014 9:23 pm

Shadow Casting Issue

Post by KrisG »

So I've been playing around with Irrlicht for a while, just trying to get a simple animation of a tennis ball on a tennis court. I've just added a shadow to the ball, but for some reason, it looks like the shadow is going through the mesh. I'm not sure why this is. I've played around with the material flags and all, and the ball shadow itself looks correct. I just need to get rid of the line. A screen shot is below:

Image

The code attached is the part that deals with creating and animating the ball, and one part of the mesh. Any help would be appreciated!

Code: Select all

 
  scene::IAnimatedMesh* ball_node = smgr->addSphereMesh("ball", 6.7);
  scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(ball_node);
  //scene::ISceneNode * node = smgr->addSphereSceneNode(6.7);
 
  //scene::ISceneNode * node = smgr->addSphereSceneNode(.067);
  if (node)
  {
    node->setPosition(core::vector3df(12, 5.485, 1));
    node->setMaterialTexture(0, driver->getTexture("C:/Users/kgalane/Desktop/fun with meshes/tennisballjpg.jpg"));
    node->setMaterialFlag(video::EMF_LIGHTING, false);
    node->addShadowVolumeSceneNode();
    node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
    core::array<core::vector3df> animation_points;
 
    for (std::vector<BallPoint>::iterator iter = points.begin(); iter != points.end() ; iter++)
    {
      animation_points.push_back(core::vector3df((*iter).X, (*iter).Y, (*iter).Z));
    }
 
    ITimer * timer = Device->getTimer();
    timer->setSpeed(15.0);
    scene::ISceneNodeAnimator* anim = smgr->createFollowSplineAnimator(Device->getTimer()->getTime(), animation_points);
    if (anim)
    {
      node->addAnimator(anim);
      anim->drop();
    }
  }
 
  scene::IAnimatedMesh* north_mesh = smgr->getMesh("C:/Users/kgalane/Desktop/fun with meshes/Court_Grass_North_ALT.obj");
  if (!north_mesh)
  {
    Device->drop();
    return 1;
  }
  scene::IAnimatedMeshSceneNode* north_mesh_node = smgr->addAnimatedMeshSceneNode(north_mesh);
 
  if (north_mesh_node)
  {
    north_mesh_node->setMaterialFlag(video::EMF_LIGHTING, true);
    north_mesh_node->setMaterialTexture(0, driver->getTexture(".../fun with meshes/tex/Court_North_Grass.png"));
    north_mesh_node->setMaterialType(EMT_SOLID);
    north_mesh_node->setMaterialFlag(EMF_BACK_FACE_CULLING , false );
    north_mesh_node->setMaterialFlag(EMF_NORMALIZE_NORMALS, true);
 
  }
 
 
CuteAlien
Admin
Posts: 9929
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Shadow Casting Issue

Post by CuteAlien »

This happens usually when the model is not closed. Which is strange for a ball - but maybe check that first.
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
LunaRebirth
Posts: 385
Joined: Sun May 11, 2014 12:13 am

Re: Shadow Casting Issue

Post by LunaRebirth »

This is exactly what problem I'm currently having so I've disabled shadows as this was frustrating.
Couldn't figure it out, though. Nothing I can see wrong. Just an Irrlicht bug.
KrisG
Posts: 6
Joined: Wed Jul 16, 2014 9:23 pm

Re: Shadow Casting Issue

Post by KrisG »

CuteAlien wrote:This happens usually when the model is not closed. Which is strange for a ball - but maybe check that first.
Strange was my first thought too. I'm not sure what you mean by checking if the model is closed though. Could you elaborate? I'm still kinda new to Irrlicht.
CuteAlien
Admin
Posts: 9929
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Shadow Casting Issue

Post by CuteAlien »

Basically means that if you would fill water into your model it should not leak out anywhere.
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
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Re: Shadow Casting Issue

Post by BlindSide »

Hey mate,

This is a drawback of volume shadows, you can try shadow mapping as an alternative. Google shadow mapping or check out the link in my sig if you want a relatively easy to use library.

Cheers,
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Post Reply