mercredi 27 septembre 2017

Multi-Rendering API Engine shader file management

I am developing a 3D engine that is designed to support the implementation of any given graphics API. I would like your feedback on how I'm planning to manage the shader files:

I thought about creating a struct that contains 3 string variables, the directory and the file name (both vertex and fragment), something like this:

class ShaderFile : public SerializableAsset
{
    std::string nameID; //Identifier
    std::string directory;
    std::string vertexName;
    std::string fragmentName;
};

The user would be able to set these variables in the editor. Then, my engine would load the shader files in like:

void createShader(RenderAPI api)
{
    ShaderFile shaderFile //Get it from some place
    std::string vertexPath = shaderFile.directory + shader.vertexName + api.name + api.extension;
    std::string fragmentPath = shaderFile.directory + shader.fragmentName + api.name + api.extension;
    //Create shader...
}

Which would create something like: Project/Assets/Shaders/standardVulkan.spv.

Am I thinking in the right direction or is this a completely idiotic approach? Any feedback

Aucun commentaire:

Enregistrer un commentaire