🎨 Shader
Quick Summary
A Shader is a small GPU program that determines how surfaces, lights, and effects are rendered — defining the visual appearance of everything from character skin to water reflections to atmospheric fog.
![]()
What Shaders Do
Shaders run directly on the GPU (not the CPU) and execute in parallel for every pixel or vertex being rendered. There are two primary types:
| Shader Type | Purpose |
|---|---|
| Vertex Shader | Transforms 3D geometry positions into 2D screen coordinates |
| Fragment/Pixel Shader | Determines the final color of each pixel, applying textures, lighting, effects |
Common Shader Languages
- HLSL (High-Level Shader Language): DirectX/Windows ecosystem; used in Unreal Engine
- GLSL (OpenGL Shader Language): Cross-platform OpenGL
- Metal Shading Language: Apple platforms
- ShaderGraph / Shader Forge: Visual node-based shader editors (no code required)
Shader Effects in Practice
- Toon/Cel shading: Borderlands, Genshin Impact — achieving stylized cartoon look
- Water shader: Animated normal maps + Fresnel equations for realistic water
- Grass wave shader: Wind effect on foliage via vertex shader
- Post-process shaders: Bloom, vignette, color grading, depth of field
PBR (Physically-Based Rendering)
Modern game shaders typically implement PBR — a standardized approach where materials are defined by real-world physical properties (metallicity, roughness, base color) that respond correctly to any lighting setup.