Colors - Lighting Basics - Shader Learning

Lighting Basics

Colors

Task

Given a cube, bind the texture from iChannel0 to the object and calculate the color perceived by an observer. The light color is (1.0, 1.0, 0.0).


Here you can learn how to bind a texture to an object: texture coordinates


Theory

The color of an object we see in real life is not the color it actually has, but is the color reflected from the object. The white sunlight is a collection of all the visible colors and the object absorbs a large portion of them. It reflects only those colors that represent the object's color, and we perceive their combination.



If we remove from the light the components that are reflected from the illuminated object, the color of the object perceived by the observer will change.




In shading, we simulate this interaction by doing a component-wise multiplication between the light and object color vectors:

$ \text{Reflected}{RGB} = \text{Light}{RGB} \cdot \text{Object}_{RGB} $

This operation represents how much of each light component (red, green, blue) is reflected by the surface.