tags:

views:

385

answers:

2

I have a Spotlight source in OpenGL, pointing towards a texture mapped sphere.

I rotate the lightsource with the sphere, such that if I rotate the sphere to the 'non-light' side, that side should be dark.

The odd part is, the spotlight seems to be shining through my sphere (it's a solid, no gaps between triangles. The light seems to be 'leaking' through to the other side.

Any thoughts on why this is happening?

Screenshots:

Front view, low light to emphasize the problem

Back view, notice the round area that is 'shining through'

+1  A: 

Its really hard to tell from the images, but:

Check if GL_LIGHT_MODEL_TWO_SIDE is being set (two sided lighting), but more importantly have a look at the normals of the sphere you are rendering.

Edit: Also - change the background colour to something lighter. Oh and make sure you aren't rendering with alpha blending turned on (maybe its a polygon sorting issue).

Justicle
+1  A: 

OK, I'm a nob - I was specifying my normals, but not calling glEnableClientState(GL_NORMAL_ARRAY). Hence all normals were facing one direction (I think that's the default, no?)

Anyway - a lesson learned - always go back over the basics.

Chaos