# Diffuse light on a sphere

I created a sphere which acts as a planet, and I’m using a diffuse light to immitate a sun. My problem is this:

As the diffuse light seems to be a inifinitive small point, it’s always smaller than my sphere. Thus, my ‘sun’ won’t ever light more than half of my ‘planet,’ right?

in ascii-art:
‘sun’ (diffuse light) ·<O (sphere) ‘planet’

the sunrays have to expand (symbol < ) to cover the planet, which means more than half of my planet will always be in the dark.

I actually want my ‘sun’ to be bigger than my planet, like this:

‘sun’ O>· (same sphere as before) ‘planet’

How do I do this? I was thinking of using two diffuse lights, kind of like this:

‘two suns’ :>· (sphere) ‘planet’

The problem with this is that if one of the ‘suns’ gets blocked, half my planet goes dark

How do I fix this? Ideally, I’d like to increase the size of the diffuse light, but I don’t know if this is even possible.

I’m sorry for the kind of childish explanation, but I started OpenGLling yesterday, still have to learn the big words

Help much appreciated!

[This message has been edited by Guus (edited 05-10-2003).]

I do not think it is possible to do with traditional OpenGL lighting. There is (as far as I know) a limit of 8 lights at any time. And, it may give an approximation but I am not sure how good of one. If you are willing to look into vertex programs or other more advanced topics you could probably do it that way. I’ve never done it, and I am no expert. But, you could try the 8 lights set up at the perimiter of the circle of the sun which is perpindicular to the line between centers of sun and planet. It may not look too bad??? Just a thought. But, if it is way too slow, you could also try a lightmap of some sort with multitexture???

I don’t like the idea of using more than one lightsource to simulate the sun, although I don’t see another approach at this time. I’ll use it as a last resort.

I’m going to look into this “lightmap of some sort with multitexture” you mentioned (I don’t have a clue what it means, but I’ll find out eventually ). Thanks!

Basically, you have a second texture which I guess would be shades of gray or luminance (which is basically the same thing) and multitexture combines the other texture with your other texture if there is one. Otherwise you could just use texture mapping if you do not have another texture. Like I said, I’ve never done it, so I am not positive that is the best way or even a way, but it seems correct. So, basically, your lightmap would probably be the same always but it would be rotating around your sphere or at least rotating to remain facing sun in same way.

Perhaps if someone with more expertise comes along, or you could post a new message asking about light maps. Hope you are able to get it.

For some reason my brain is mush today

I think I get it
You suggest using another texture on the dark side of the planet to make that side darker. Can I mix two textures (or one texture and one color) or would one of the two be on top? If I can mix, I’d use a gray to invoke ‘shadow.’ … sounds good

Somehow, this reminds me of painting with my fingers when I was a kid

[This message has been edited by Guus (edited 05-10-2003).]

Hmm, drawback: last mentioned method would have a quite harsh border between shadow and sun, instead of the nice twilight-zone I get when using diffuse lighting.

Actually, if you have a texture say of the moon and the sphere is mapped with that then you get what you had - half or a little less than half lit. But, a second texture used as a lightmap (probably with lighting disabled - I dunno) whereby you have a square texture with a gradually decreasing brightness until it is black. Of course, to do it, some of the corner or edge ares would have to be lighter so that more than half of the sphere is lit.

Edit:
Actually, probably a rectangular texture like 128 x 64 (diameter for longitude by radius for latitude). Only problem is you have part a spherical lit area which extends beyond the edges and must be continued on corners… FUN

Edit2:
You could also use environment mapping using cube map. Again, never done it, just read about it but wasn’t ready to use it.

[This message has been edited by shinpaughp (edited 05-10-2003).]

[This message has been edited by shinpaughp (edited 05-10-2003).]