Game Development Reference
In-Depth Information
We assigned four color values to each vertex. But, each vertex corresponds to each
fragment (pixel on our screen). Hence, the magic happens in the rendering pipeline.
We assign a color value to each vertex, and WebGL interpolates it by taking the
corresponding calculated color for the vertices surrounding the corresponding
fragment (pixel). Hence, you see a gradient from blue to red, green to white, and
so on, as shown in the following diagram:
The in-between colors are interpolated values by the GPU.
Learning more about colors
In the preceding example, we learned about how to color a simple object by
providing a color for each vertex, but in a game, to color an object, we do not
generally use vertex colors, but we add a material to an object instead. A material
can be modeled by defining parameters such as textures and color. In this chapter,
we will model our materials only with color. Material colors are usually modeled as
triplets in the RGB ( Red , Green , and Blue ) space.
However, the material does not solely decide how the object will appear in your
game. The final color of a fragment is defined by how the object is oriented in the
scene and lights in the scene. A light is defined by parameters such as direction,
position, and colors. Hence, the final color of a fragment is decided by material,
orientation (normals), and light intensity.
 
Search WWH ::




Custom Search