Making a Shading Language for My Offline Renderer
3 days ago
- #Offline Rendering
- #Shading Language
- #Graphics Programming
- The author, a graphics programmer, developed Tiny Shading Language (TSL) for their CPU-based offline renderer, SORT, over four months in spare time, motivated by learning compiler design and avoiding dependencies like OSL.
- TSL was designed to be simple, C-like, and integrated with tools like Flex (lexical analyzer), Bison (syntax analyzer), and LLVM for compilation, enabling one-person development within a few months.
- Key design differences from GPU shading languages include per-thread execution without synchronization, a closure tree output for deferred BXDF evaluation, support for call stacks, and shader group templates that act as material graphs.
- TSL shaders are compiled into JITed machine code, executed via shader instances that are thread-safe and integrate with the renderer through global constants for per-execution data like texture coordinates.
- Improvements over OSL include making shader group templates behave as shader unit templates for nested material graphs, simplifying asset authoring, and offering a lightweight, dependency-free library with multi-threaded compilation.