Closed BobbyBao closed 5 years ago
Hi, could you please describe your question in more detail?
How extensible should your material system be? This sounds like a question about the typical issue of so called "Uber-Shaders" where you have all material effects inside a single (and commonly large) shader.
Or is this a question specifically about LLGL?
A Material class, like Urho3D engine and Unity Engine, material contains a vector of ShaderParaments, each shader parament set value by name,LLGL dx11 renderer should implement ShaderUniform interface or provide a reflection API
The ShaderUniform
interface is only for the older shader versions of GLSL to set individual uniforms,
like this:
uniform int param0;
uniform float param1;
In modern shaders you typically use Uniform Buffers (OpenGL) or Constant Buffers (Direct3D), like this:
// GLSL
layout(std140) uniform Parameters {
int param0;
float param1;
};
// HLSL
cbuffer Parameters : register(b0) {
int param0;
float param1;
};
Take a look at the constantBuffer
field in Tutorial02.
I kown, but ConstantBuffer shoulder privider reflection API. In a extensible material system, when you add a new shader, you only need to change a material config, instead of change the ConstBuffer struct in cpp source code.
The only shader reflection for constant buffers LLGL supports right now are the ShaderProgram::QueryConstantBuffers
function and ConstantBufferViewDescriptor
structure.
But individual members of a constant buffer can not be queried.
So you need to know your shader structures and map them 1:1 into C++.
Even if I add this functionality at some day, I would not use the ShaderUniform
interface, but I would extend the ConstantBufferViewDescriptor
structure to support it.
However, I currently don't know when I have time for this.
This thread is quite old now, but might be related this new ticket.
How to implement a extendible material system on dx11, use ConstBuffer?