ColinGilbert / noobwerkz-engine

My happy playground of programmer fun.
Apache License 2.0
20 stars 3 forks source link

Data-driven shaders #56

Open ColinGilbert opened 8 years ago

ColinGilbert commented 8 years ago

Currently shaders (even the user ones) are encoded as rather sloppy combinations of C++ objects and runtime file dependencies. Those are packed into a boost::variant and then sorted out at runtime.

Contrast that with a data-driven model: Shaders are essentially data and can/should be treated as such:

In vertex and fragment shaders, rename all inputs/outputs to shared names.
In the engine, create a new kind of shader object, that can modify and return the values of shader inputs/outputs, accept a bgfx shader file, handle drawcalls, etc.
Carefully replace old shader code with new shader code.
Profit.