How to get sharp light/dark boundary on a lit sphere?

Hi,

I am using gluSphere with purely diffuse lighting from far away. How can I make the light/dark boundary very sharp?

The light source and sphere material use diffuse (1, 1, 1), ambient et al (0, 0, 0).

Increasing the tesselation (sphere slices & stacks) doesn’t help.

When you look at images of Earth from space, the boundary is much sharper than what I am getting… how to achieve this?

Any help appreciated!

Mean Fox

Real lighting doesn’t provide for very sharp light/dark boundaries.

When you look at images of Earth from space, the boundary is much sharper than what I am getting… how to achieve this?

The reason for that is that Earth isn’t a hard object; light gets scattered by the atmosphere a great deal. The simple OpenGL lighting model assumes a hard object.

I would suggest looking into either applying a light texture to get the precise effect you want, or using a vertex shader to approximate the effect and recreate that look.

Here’s a simple solution. Enable specular lighting, and set the specular exponent to a very small value.

Thank you - adding a little specular does indeed sharpen up the boundary.

Cheers -

Mean Fox

Thank you - adding a little specular does indeed sharpen up the boundary.

Cheers -

Mean Fox

A method I’ve always liked is to enable GL_NORMAL_MAP texture coordinate generation mode, and use the texture matrix to collapse your outgoing 3D texture coordinate into a 1D texture, where that 1D texture basically defines your light response as a function of cosine of angle to the light. You can do toon shading if the texture is in GL_NEAREST mode, even. You can do the same thing for specular with GL_REFLECTION_MAP coordinate generation.