Lighting a Sphere

I’m really enjoying OF => there has been some tremendous work put into it, and it shows.

I’m building a solar system model for a class. It works great, but the sun (which has the main, point light source) is dark. I assume because the light is emanating from it. If the image shows up below you can see what I’m talking about.


[The sun is the dark object in the middle. The others are planets with correct shading]

How would you go about lighting the sun? With two spotlights on it? Or is there a better way?

Thank you

Hi. Good to know you’re enjoying OF. :smiley:

There are several methods, from fancy raymarching, raytracing or using open GL materials and such, although I would choose the simplest one, which is faking it. Considering that the sun, as a light source should be a more or less homogeneous you can simply put a white 3D sphere with the illumination off. Make sure you put ofEnableDepthTest() before rendering the shperes and ofDisableDepthTest() after rendering these, so the overlaps look correctly.

you can set the emissive value of the sun so it emits light, that light won’t light up other objects but the object itself will appear lighten up

Oh, true. Thanks for noting it :slight_smile:
Although this implies using ofMaterial. I think there are no examples for how to use ofMaterial, right?

That was super-helpful guys. Got it. Thanks for your reply.

2 Likes

which approach you used?