Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have a simple scene with only one empty box. Within that box I have the camera attached to a scene node, which the user can move (translate/rotate). Additionally a spotlight is attached to the camera's scene node, facing into the same direction as the camera. So when the camera is moved, then the light moves as well.

m_pCamera = m_pSceneMgr->createCamera("Camera");
m_pCamera->setNearClipDistance(0.01);
m_pCamNode->attachObject(m_pCamera);

Light* spotLight = m_pSceneMgr->createLight("spotLight");
spotLight->setType(Light::LT_SPOTLIGHT);
spotLight->setDiffuseColour(1, 1, 1);
spotLight->setSpecularColour(1, 1, 1);
spotLight->setSpotlightRange(Degree(50), Degree(100));
spotLight->setSpotlightNearClipDistance(0);
spotLight->setDirection(m_pCamera->getDirection());
m_pCamNode->attachObject(spotLight);

So, this basically works fine. There is one problem though: As soon as the user moves the camera very close to a side of the box, then suddenly all is black, I can't see anyting. I am sure the camera is NOT moving through the box's side, it is still within the box.

So the problem seems to be that the light does not "work" when it is too close to an object, as if the object (the box side in my case) is not reflecting the light any more.

Any ideas?

share|improve this question
    
crosspost: ogre3d.org/forums/viewtopic.php?f=2&t=77461 –  Philip Allgaier May 1 '13 at 16:33
    
@PhilipAllgaier: Correct. I am sorry, but is it considered as bad practice to post a question here and another forum as well? –  Matthias May 1 '13 at 17:04
    
usually it is considered slightly impolite (especially without bi-directional links) since people might invest time to solve your question here, without knowing that others already solved or at least partially solved in in another forum. so at least put links in to make sure everyone is on the same page. –  Philip Allgaier May 1 '13 at 17:11

2 Answers 2

It's probably the near clip distance of the camera. So your camera is outside of the box but the near clipping plane sees through it.

Usually you fix this by making sure the collision on whatever is moving with the camera is larger than the near clipping plane so that you can't physically get close enough to the world to see through it.

share|improve this answer
    
Thanks for your answer, but it seems that does not cause the problem. I have set the near clip distance of the camera to 0.01 (and updated my original posting accordingly). Or have I misunderstood your reply? –  Matthias May 1 '13 at 16:03
    
Yes you understood what I was getting at. You say it's .01, but what is the distance it starts to fail at? –  Tetrad May 1 '13 at 16:06
    
When I calculate the difference between the current camera position and the plane or box side I move the camera towards, then my described problem occurs at a distance of around 60. When I move the camera back again, then I can see the plane or box side fine again. –  Matthias May 1 '13 at 17:01
up vote 0 down vote accepted

It seems the problem is with per-vertex lighting vs. per-pixel lighting.
More details in this thread: Ogre: Light not reflecting correctly

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.