• Breaking News

    Data Driven Material Managment 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: http://bit.ly/2WjT1b5 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 https://ift.tt/eA8V8J

    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: http://bit.ly/2WjT1b5 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

    from GameDev.net http://bit.ly/2IcMjd5

    ليست هناك تعليقات

    Post Top Ad

    ad728

    Post Bottom Ad

    ad728