This is a mockup for a scheme shader DSL. The main idea here is to conceptualize shaders as being a dependency resolution problem instead of a mess of procedural code. So instead, we define some named data structures. These structures can name other structures as “dependencies”. Data members follow the form of a name, an optional value, and zero or more tags to specify type. Type is optional, but if the struct is under-specified, evaluating it will throw an error.
The variant macro can be used to provide polymorphism (maybe the macro should just be “polymorph”).
Lastly, the vertex and fragment shader macros can take any number of structs as dependencies, but in this case, they only need “model”. The rest will be pulled in automatically.
This lets us do a number of things:
- C structs and helper APIs can be easily generated automatically from the struct and variant macros.