Overview
VRSL’s lighting system is 95% shader-based, with nearly all computation happening on the GPU. This architecture enables hundreds of individually-controlled fixtures to render simultaneously with minimal performance impact.The shader architecture uses GPU instancing and batching to render multiple fixtures in a single draw call while maintaining per-fixture properties.
Shader Types
VRSL provides shaders for different fixture components:Moving Lights
Volumetric Mesh - Renders light beams and fog effects/Runtime/Shaders/MovingLights/VRSL-StandardMover-VolumetricMesh.shader/Runtime/Shaders/MovingLights/VRSL-WashMover-VolumetricMesh.shader
/Runtime/Shaders/MovingLights/VRSL-StandardMover-ProjectionMesh.shader/Runtime/Shaders/MovingLights/VRSL-WashMover-ProjectionMesh.shader
/Runtime/Shaders/MovingLights/VRSL-StandardMover-FixtureMesh.shader/Runtime/Shaders/MovingLights/VRSL-WashMover-FixtureMesh.shader
Static Lights
Static Light - Fixed-position spotlights and washes/Runtime/Shaders/StaticLights/VRSL-StaticLight-ProjectionMesh.shader/Runtime/Shaders/StaticLights/VRSL-StaticLight-LensFlare.shader
Specialty
Lasers - Laser beam effects/Runtime/Shaders/MovingLights/VRSL-BasicLaser-DMX.shader
/Runtime/Shaders/Basic Surface Shaders/VRSL-StandardSurface-Opaque.shader
Shader Includes Architecture
Shaders are modular, sharing common functionality:GPU Instancing
VRSL uses Unity’s GPU instancing to render multiple fixtures efficiently:Instanced Properties
Accessing Instanced Properties
Vertex Shader Operations
Vertex shaders perform all geometric transformations:Pan/Tilt Rotation
Vertex Color Masking
VRSL uses vertex colors to control which vertices are affected by transformations:Cone Width Calculation
Cone meshes use UV.x (0-1) to represent distance from fixture origin. This enables smooth scaling along the beam length.
Fragment Shader Operations
DMX Fragment Shader
Culling for Performance
Fixtures are culled in the vertex shader if off or invisible:Volumetric Rendering
Volumetric beams use several techniques:Blinding Effect
Intensifies beams when looking directly at the fixture:Noise Textures
Adds realistic fog/haze texture:Depth Fade
Prevents hard intersections with geometry:Projection Rendering
GOBO projections use screen-space ray marching:Ray Setup
Mirror Depth Correction
Render Texture Pipeline
VRSL uses custom render textures for advanced effects:DMX Interpolation
DMXRTShader-DMXInterpolation.shader - Smooths DMX values to reduce jitter from compression artifactsStrobe Generation
DMXRTShader-StrobeTimings.shader - Converts DMX strobe values to phase DMXRTShader-StrobeOutput.shader - Generates binary on/off from phaseSpin Timer
DMXRTShader-SpinnerTimer.shader - Accumulates rotation for GOBO spinShader Keywords
VRSL uses shader variants for different modes:- DMX-only builds exclude AudioLink code
- AudioLink-only builds exclude DMX code
- Volumetric/projection variants optimize for specific mesh types
Performance Best Practices
Batching
- Use GPU instancing for all fixtures
- Group fixtures by material to maximize batching
- Avoid per-fixture material changes
Culling
- Fixtures auto-cull when off/dark
- Use occlusion culling for fixtures behind walls
- Disable fixtures far from players in large worlds
LOD Strategy
- Reduce cone length for distant fixtures
- Disable volumetrics beyond certain distance
- Use simpler shaders for background/ambient lights
Texture Sampling
- DMX grid uses point sampling (no filtering)
- Noise textures use trilinear filtering
- GOBO textures use mipmaps
Related Topics
DMX System
How DMX data is read by shaders
AudioLink Integration
Audio-reactive shader features