2024
Rendering HLSL Stylized Art

Stroke-Based Rendering

Painted 3D Aesthetics • Stroke-Based Lighting • Custom Texture Tools

02

Stroke-Based Lighting

The Technique: Instead of calculating lighting per-pixel, I sample it per "stroke center." In traditional painting, a single brush stroke usually has a consistent color/value. By locking lighting calculations to stroke centers, the shader mimics this effect, avoiding smooth gradients within individual strokes.

Lighting technique diagram
03

Encoded Brush Tool

To support this, I developed a custom tool that generates encoded stroke textures. It paints random strokes onto a canvas, but instead of RGB color, it encodes the center position of each stroke into the texture data for the shader to read.

Custom brush tool interface
04

Implementation

The shader reads the "center position" texture, calculates lighting for that specific point in world space, and applies that single lighting value to the entire stroke shape. This creates a stepped, painterly look that reacts dynamically to lights.

Shader implementation details