Hello,
I posted about a similar topic around one year ago but have since rebuilt my engine in dx12 (although its agnostic so can work with any API), the idea for managing shader/materials would eventually be to have a custom language that generates a material file for me but for now this is the process.
Write Vertex and pixel shader
Create XML material definition: States, Parameters, vs and ps code.
Engine iterates through Shader folder and creates all shaders/states up front from the material definition file.
So the issue is the C++ side particularly with constant buffers, a lot of hobby engines that sue OpenGL go down the route of having a single cpp called Material with various get and setters for parameters based on there name, Unity actually does this as well: https://docs.unity3d.com/ScriptReference/Material.html However with Constant buffers the previous solution I had was to generate a byte blob with the required size for all the required parameters, I would then offset and set the bytes myself. This means creating a map between the string parameter name (hashed of course) too the byte offset for the start of that particular parameter. The above would work as you can just offset to a specific byte for say a float and set the 4 bytes, or a vector and set the 12 bytes and so on. My issue is the use of a map, its additional space and potentially time to grab the offset in order to get/set a parameter.
So, the question is, does anybody have any insight into how something like unity manages to have a single class that is data driven to set constant buffer data when we can have any variety of parameters defined in xml etc. other then the potential method i have suggested.
Thanks