WebGL - How to make fog

In this episode, I discuss how to draw fog in WebGL.

Fog factor = (end point - distance from eye point) / (end point - starting point)

Where starting point less than distance from eye point less than end point
if fog factor == 1, then object is completely shown; if fog factor == 0, object completely hidden

fragment color = surface color * fog factor + fog color * (1-fog factor)

* https://github.com/davidwparker/programmingtil-webgl/tree/master/0080-fog-part-1

© programmingtil.com