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.

In my Ogre 3d scene I have an empty box, and within that there are three small cubes. The camera is also within the box, facing the three small cubes. The user can move and rotate the camera with the mouse.

There is only one (spot) light source, attached to the same node and facing the same direction as the camera. The idea is that the light should always spot the same direction as the camera, like a flash light (with a narrow light cone).

The problem now is that the light emitted by the spot light used in this scene is not reflected by the sides of the empty box correctly. When I face the camera perpendicular to a side of the box, then no light is reflected at all. Only when I move/rotate the camera so that it spots the box "walls" from a specific angle some light is reflected. The problem only occurs with the box sides, the small cubes within the box are reflecting the light correctly.

In this first screenshot you can see what happens when I look to the edge/corner of the box. You can see a wooden texture on the box sides, and those three cubes in the box. The blue-ish box in the middle is exactly on the border of the light cone, so that only the left side is within the cone and reflecting the light.

enter image description here

That seems like the correct behaviour. Now when I move the camera so that I looks exactly top-down to the same cube within the box, then only that cube is reflecting the light, but not the side of the box. It then looks like as the empty box would not be there at all, as you can see on the second screenshot. (Note also a second small cube on the top of the screenshot, which is again exactly on the border of the light cone.)

enter image description here

I am pretty sure the texture/material is not the problem. Because when I use the same blue-ish material for the box sides as I use for the small cube, then the cube is still correctly reflecting the light, whereas the box side is again not reflecting the light at all.

Any ideas what I am doing wrong here?
I am completely out of ideas here :(

share|improve this question
    
crosspost: ogre3d.org/forums/viewtopic.php?f=2&t=77762 –  Philip Allgaier May 10 '13 at 22:10

1 Answer 1

up vote 1 down vote accepted

From looking at your screenshot, I guess Ogre is using per-vertex lighting. This means it calculates the lighting only at the corners of your box, then it just blends (interpolates) across the box sides. When you look directly at a box side, all 4 corners are outside the narrow spotlight, so all 4 corners are black.

One solution is to tesselate your box sides. Instead of one big square (2 big triangles), replace each side with a bunch of tiny squares, like a checkerboard. By adding more vertices like this, the lighting will look somewhat better (although still not great).

The best option for visual quality would be to configure per-pixel lighting in Ogre for the box. I haven't done that myself, but here's a thread about it: http://ogre3d.org/forums/viewtopic.php?f=2&t=77052

share|improve this answer
    
Ohh wow that's great, at least theoretically it makes perfect sense. I will check in that direction and let you know then. Thanks! –  Matthias May 11 '13 at 10:18
    
Thank you very much Eric, that (tessellation) was exactly what I was looking for. –  Matthias May 11 '13 at 13:08

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.