CHAPTER 5 ■ GETTING THE MOST OUT OF VERTICES
503
Pixel Shader: Putting It All Together
Finally, you have all the ingredients available to determine the final color. This code puts them
all together:
float4 waterColor = float4(0,0.2,0.4,1);
Output.Color = waterColor*fresnelTerm + reflectiveColor*(1-fresnelTerm) + specular;
The relation between the deep blue ocean color and the reflective color is given by the
Fresnel term. For almost all the pixels, the combination between these two colors makes up
the final color of the pixel. For a pixel with an extremely bright reflective color, the specular
value will be significantly larger than 0. This will make the final color a lot brighter, giving
very bright specular highlights on the spots of the water ...