Lighting in 3D Graphics

Most YG scenes will have a light () node at the very top. If you leave that out, the scene is plunged into almost total darkness. The light node actually lets you create a variety of different lighting effects, which can have a powerful influence on the way the scene looks. No matter how fancy the models in a scene are, without lights you won't see them at all. Lighting does a lot to define the mood of a scene - the same environment can appear mundane, mysterious, soothing, or threatening depending on the type of lights you use. Simulating the effects of light is an incredibly complex problem - 3D rendering software using techniques like ray tracking or radiosity models can take hours to render a single image. To create interactive, realtime graphics, we use a number of shortcuts and rough approximations in the way that lights are simulated, meaning that lights in YG will not behave exactly the same way that they would in the real world, or even in a rendering program like Maya.

Lighting Terminology

Some lighting terms in 3D graphics come from theater and film lighting; others are purely mathematical.
To begin with, we divide light into three parts: ambient, diffuse, and specular, each of which has a different way of applying illumination to objects.


Ambient light is light that doesn't seem to come from a specific source, but is just there. Look under the desk - it's pretty dark, but there's some light there. In the real world, this is caused by stray photons bouncing around and occasionally ricocheting under the desk. Ambient light is basic, minimal amount of light in the whole scene. Adding too much ambient light makes a scene look washed out. Since the light doesn't come from anywhere, all sides of an object are illuminated equally, and it won't have any shading on it.

Diffuse light is even, directed light coming off a surface. For most things, the diffuse light is the main lighting we see. Diffuse light comes from a specific direction or location, and creates shading. Surfaces facing towards the light source will be brighter, while surfaces facing away from the light source will be darker.

Specular light refers to the highlights on reflective objects, like diamonds, billiard balls, and eyes. Specular highlights often appear as bright spots on a surface, at a point where the light source hits it directly. Ambient, Diffuse, and Specular are called the three components of a light source. Each one is given a color, which, when added together, create the final color of a light. For most lights, the main overall color of the light is defined by the Diffuse color. Sunlight or lightbulbs would be white, while moonlight would be a darker blue, and a candle would be yellow. You can use the ambient color to adjust the overall color range of the light source; or, you can get a slight tint to shadows by making the diffuse component yellow and the ambient a slight blue. In many lights, the ambient color is left at black, meaning that it won't have any effect. Specular components are often left at white, but you can make them different colors to get interesting effects. Most of the time you can completely ignore the specular and diffuse settings on a light, but just be aware that the way you set the color is by specifically setting the diffuse color. The final color that an object appears to be is a combination of the light hitting it and the color of the surface.

Types of Lights

In 3D graphics, there are 4 basic types of simulated lights. Rendering programs also have a host of other, more sophisticated light types, but YG and most other realtime 3D engines only have the 4 basic ones.

Ambient: as above, light that doesn't come from any direction. Illuminates all surfaces everywhere in the whole world evenly regardless of where they are and which way they're facing. In YG, there is not a specific ambient light node - you create ambient light by just setting the ambient color of a light.

Directional Light: a light that has a specific direction, but no location. It seems to come from an infinitely far away source, like the sun. Surfaces facing the light are illuminated more than surfaces facing away, but their location doesn't matter. A Directional Light illuminates all objects in the scene, no matter where they are.

Point Light: a light that has a specific location and radiates equally out in all directions. Examples of point lights would be candles or bare lightbulbs. Surfaces close to the point light are brighter than those which are far away. Point lights have attenuation, which controls how quickly the light intensity drops off as you move away from it. Lights with high attenuation are very localized, while lights with low attenuation will spread farther.

Spotlight: a light with both location and direction. A spotlight sends out a cone of light defined by the spotlight angle, and illuminates only objects within that cone. Spotlights also have attenuation, as well as a parameter that controls whether the spot of light is sharply defined or has smooth edges. These 4 types of lights are listed in order of computational complexity; the more lights you have, the more work the computer has to do. Generally it's a good idea to use directional lights whenever possible, since they're the cheapest, and use pointlights and spotlights sparingly.

Differences between 3D graphics lights and real lights

Shadows: simulated lights don't normally cast shadows. And, they also pass through solid objects - so a light inside a closed box would actually illuminate things outside the box as if the box were transparent. The shading on objects is only calculated based on the angle of the surface.

Bounce light: Simple lighting situations have a single light, called a key light, illuminating one side of an object. This creates strong shading and definition of the volume of the object. However, a 3D light will often make the contrast too great - the dark side of the object is completely black since no light is hitting it. In reality it would still be lit a little, just not as much as the brightly lit side, because of light bouncing around the room and hitting the dark side of the object. In realtime 3D, bounce light is not calculated, so you have to create it yourself. Either add a little ambient color, or put a second, less bright directional light pointing the opposite direction to give a little light to the shadows.

Reflections: shiny objects will have specular highlights, but won't actually reflect the scene around them. creating actual reflections is very time consuming, requiring computationally intensive ray tracing. A shortcut for getting effects like chrome and water surfaces is to use Environment Maps.

Per-Vertex lighting: as a shortcut, light intensities on a surface are only actually calculated at each vertex, and the color of each polygon is created by making a gradient between each of the vertices. This can make subtle lighting effects, particularly spotlights, not look right on objects with large polygons. One particularly weird side effect is that when a point light gets very close to a surface, the surface can still appear dark if it's in the middle of a polygon and therefore far away from the individual vertices!

<-- Previous: Grouping and Hierarchy] Debugging

AltStyle によって変換されたページ (->オリジナル) /