Shader Tricks

Anti-Aliased Grid Shader

This shader provides a convenient way to visualize the level set of any value using anti-aliased lines. It uses screen-space partial derivatives to automatically compute the correct line width and falloff.

View demo...

Screen Space Curvature Shader

This shader implements a screen-space curvature effect. It uses the screen-space normals of neighboring pixels to automatically compute curvature.

View demo...

Lightmap Generation

This example dynamically generates a combined ambient occlusion and direct illumination lightmap on the GPU. Ambient occlusion refers to the shadows caused by a uniformly lit hemisphere enclosing the model, which approximates the light arriving from the sky.

View demo...

Fast Rounded Rectangle Shadows

This demonstrates a shader I came up with for constant-time single-step rounded rectangle drop shadows on the GPU.

View demo...