Introduction
VR Stage Lighting uses a sophisticated shader system built on Unity’s shader pipeline, supporting both the Built-in Render Pipeline and Universal Render Pipeline (URP). The shader system provides realistic stage lighting effects including volumetric rendering, projection mapping, and DMX/AudioLink control.Shader Architecture
The shader system is organized into several key categories:Moving Light Shaders
- Standard Mover - Versatile moving head spotlight with projection capabilities
- Wash Mover - Wide-beam wash light for area illumination
- Basic Laser - Laser beam effects
- Fixture Mesh - Physical appearance of the light fixture
- Projection Mesh - Light projection and GOBO patterns
- Volumetric Mesh - Volumetric light cone rendering
Static Light Shaders
- Static Light Projection - Fixed position projection lights
- Static Light Lens Flare - Realistic lens flare effects for static lights
Control Variants
All main shaders come in two control variants:- DMX Control (
VRSL/...) - Controlled via DMX512 protocol through render textures - AudioLink Control (
VRSL/AudioLink/...) - Driven by audio reactive AudioLink system
Rendering Pipeline
Render Order
Shaders use specific queue orders for proper layering:- Projection Meshes:
Transparent+1 - Volumetric Meshes:
Transparent+2 - Lens Flares:
Transparent+200
Stencil System
All lighting shaders use stencil reference 142 to prevent rendering where depth lights are placed:Key Features
GPU Instancing
All shaders support GPU instancing for efficient rendering of multiple fixtures:Render Pipeline Support
Shaders include dual SubShader blocks:- First SubShader: Universal Render Pipeline (URP)
- Second SubShader: Built-in Render Pipeline
Shader Variants
Common shader variants include:_ALPHATEST_ON- Alpha to coverage rendering_MAGIC_NOISE_ON_HIGH/_MAGIC_NOISE_ON_MED- Volumetric noise quality_USE_DEPTH_LIGHT- Depth-based occlusion_POTATO_MODE_ON- Performance mode_HQ_MODE- High quality mode
Shared Functionality
Include Files
Shaders use shared include files for common functionality:- VRSL-Defines.cginc - Property definitions and uniforms
- VRSL-DMXFunctions.cginc - DMX grid sampling and control functions
- VRSL-AudioLink-Functions.cginc - AudioLink integration
- VRSL-StandardLighting.cginc - Lighting calculations
DMX Grid Sampling
The system uses render textures for DMX control:_Udon_DMXGridRenderTexture- Raw DMX values_Udon_DMXGridRenderTextureMovement- Smoothed movement data_Udon_DMXGridStrobeOutput- Strobe timing_Udon_DMXGridSpinTimer- GOBO rotation timing
Performance Considerations
Quality Modes
The shader system includes multiple quality levels:-
High Quality Mode (
_HQMode)- Enhanced volumetric sampling
- Higher resolution noise textures
- Best visual quality
-
Default Mode
- Balanced performance and quality
- Standard noise sampling
-
Potato Mode (
_PotatoMode)- Disabled noise sampling
- Reduced texture reads
- Maximum performance
Render Modes
Shaders support multiple transparency modes:- Transparent - Standard alpha blending
- AlphaToCoverage - MSAA-based transparency
- HQTransparent - Enhanced transparency for volumetrics
Depth System
The shader system uses Unity’s depth texture for:- Soft particle effects (depth fade)
- Mirror depth correction
- Occlusion testing (lens flares)
- Intersection highlighting
Mirror Support
Built-in mirror depth correction for VRChat mirrors:Next Steps
- Moving Light Shaders - Detailed properties for moving lights
- Static Light Shaders - Static light shader reference
- Volumetric Rendering - Volumetric lighting techniques