I am writing a space trading simulation, and want to create an effect where the light always eminates from the position of the sun.
Basically, I have a skybox, depicting the starfield etc, and planets/ships inside the clipping plane, which should be lightsourced.
I want the starfield to not be affected by the lighting, so I switched off lighting before I drew the skybox…only to find the skybox now has a lovely red hue… ( if anyone can explain why I would appreciate it! my brain hurts when I start thinking of reasons why )
To recap:
I want the skybox to be full intensity,and unaffected by the lightsourcing.
I want the ships and planets to be affected by a diffuse light source, eminating from the direction of the sun.
What is the correct order of lighting operations to achieve this effect?
If anyone can give me a gentle nudge, I’m sure my brain will start working again.
dd
p.s
I’m implementing game logic in parallel to the graphics engine, hence the brain-ache.
>>I want the skybox to be full intensity,and unaffected by the lightsourcing.
You probably use GL_MODULATE and the lighting or the Gouraud shading with the current color (reddish?) add to the texture colors.
Use GL_DECAL for the skybox texture and every other coloring effect is replaced by the texture color. Switching off lighting might add performance. Depends on how many faces the skybox has.
Maybe you are setting the light position in the wrong place. If you need a light that is in a specific point in the world, you need to set it after you set the modelview matrix. The light position is also modified by the modelview matrix. If you set it before the modelview matrix is set, you get a lightposition that is relative the viewpoint.
The planets are lightsourced, and there is a dark side and a light side.
I now move the ship to the dark side of the planets,stop and orientate towards the planet, and the lighting level increases…
i.e darkness becomes light…