-2

I am rendering some interactive scene in 3D and I am wondering: How do I add sunlight to it? I'll try to explain the best how I have it setup now.

scene

What you see right now is that the directional light (the sun) is denoted by the yellow dot, which I want to replace with a realistic sunlight.

The current order of drawing is:

  • For all objects:
    • Do a light depth pass for the shadow.
  • Then for all objects:
    • Do a draw pass for the object itself, using the light depth texture.

Where would I add adding a realistic sunlight? I have a few ideas though about it:

  • After the current drawing order, save the output into a texture, and use a shader that takes the texture and adds sunlight on top of it.
  • After the current drawing order, use a shader that adds the sunlight simply to what has been drawn so far, such that it will be drawn after everything is on the screen.
  • Or maybe draw the sunlight before the rest of the scene gets drawn?

How would you deal with rendering a nice sunlight that represents a real life sun?

skiwi
  • 66,971
  • 31
  • 131
  • 216
  • 1
    If you add some ambient light, you will get a more realistic look. What you can do in addition to this, depends on your scene. E.g. for a room scene, you might add small lights in the windows. Then there are more advanced techniques like ambient occlusion, radiosity, path tracing... Not all of those are suitable for rendering. Btw, the lighting quality depends heavily on the normals. Your normals do not fit to the model. That's another factor that makes it unrealistic. – Nico Schertler Mar 09 '14 at 15:49
  • Don't know. Not from me. Maybe because the question is pretty broad and unspecific. – Nico Schertler Mar 12 '14 at 17:04

1 Answers1

2

To realistically simulate sunlight, you probably need to implement some form of global illumination. A lot of the lighting we see on objects comes not directly from the light source, but from light bounced off of other objects. Global illumination simulates the bounced light.

[Global Illumination] take[s] into account not only the light which comes directly from a light source (direct illumination), but also subsequent cases in which light rays from the same source are reflected by other surfaces in the scene, whether reflective or not (indirect illumination).

Another techniques that may not be physically accurate, but gives "nice" looking results is Ambient Occlusion:

ambient occlusion is used to represent how exposed each point in a scene is to ambient lighting. So the enclosed inside of a tube is typically more occluded (and hence darker) than the exposed outer surfaces; and deeper inside the tube, the more occluded (and darker) it becomes.

user1118321
  • 25,567
  • 4
  • 55
  • 86