# OpenGL Shader Code Snippets

### Horizon Shader

A non-PBR shader that quickly blends between two colors near the middle of the vertical axis. When applied to large, inward-facing meshes, this material can be used as a sky box or sky dome.

It uses an algebraic sigmoid to map the v coordinate of a vertex (in range [0, 1]) to some value (in the range [0, 1]) defined by the sigmoid function. The resulting value is used to mix or linearly interpolate between two colors. In this case, one is the horizon color and the other is the sky color. If you have access to this website's source code, see the `SkyDome`

3D component for more details about its use.

### Vertex

### Fragment

### Algebraic Sigmoid

The algebraic sigmoid (or S curve) is the function $\frac{ax-b}{\sqrt{c + (ax-b)^2}}$. It's used to to map values in the range [-Infinity, Infinity] common in GLSL to the range [0, 1]. Changing the parameters of the curve changes its shape and has a wide range of applications in graphics. `a`

being `1`

or `-1`

flips the curve over the y axis. `b`

shifts it across the x axis. `c`

being `0`

or `1`

controls the curve's width: closer to `0`

makes it slim, closer to `1`

makes it wide.