Adding the support for multiple materials/shaders at this point is a titanic task, because:
1) The engine is developed around the current system, and everything must be changed
1) The engine is developed around the current system, and everything must be changed
2) The engine uses instancing, which add a level of complexity (usually there are attributes and uniforms, with instancing we have attributes, instance attributes with the divisor and uniform).
3) The shaders are more complex "thanks" o the deferred rendering
3) I don't want to force the developer to manually add the attributes/uniforms in c++, so I want to automatize the system to automatically recognize attributes/uniforms.
This is really an huge amount of work, and I'm not even sure that I will be able to get everything done... I have a lot of confusion in mind because, while I know how the single features in the engine work, the big picture is quite blurry, and its pretty painful to think about all the consequences that this big rebuilding will have.
Today I wrote a function to get info about the attributes in the current shader. GLSL stores everything as a 4 byte value (not really true, just to get the idea), there are no shorts or bytes.
So if I query for the type of a color, I get that each component is a GL_FLOAT...which is not ideal because I used to pass just 4 bytes, which where then converted in the gpu. So there is litterally no clean way to tell if something should be a vector of floats or it could be stored in bytes.
Since I really want to save that extra bandwidth, I decided to give a convention to the attributes names in the shader:
This is really an huge amount of work, and I'm not even sure that I will be able to get everything done... I have a lot of confusion in mind because, while I know how the single features in the engine work, the big picture is quite blurry, and its pretty painful to think about all the consequences that this big rebuilding will have.
Today I wrote a function to get info about the attributes in the current shader. GLSL stores everything as a 4 byte value (not really true, just to get the idea), there are no shorts or bytes.
So if I query for the type of a color, I get that each component is a GL_FLOAT...which is not ideal because I used to pass just 4 bytes, which where then converted in the gpu. So there is litterally no clean way to tell if something should be a vector of floats or it could be stored in bytes.
Since I really want to save that extra bandwidth, I decided to give a convention to the attributes names in the shader:
- the first letter of the name is the type (f, b, s, i)
- the second letter tells if the attribute is a number, a vector or a matrix (n, v, m)
- the second letter tells if the attribute is a number, a vector or a matrix (n, v, m)
- the third letter is a number representing the size of the vector/matrix
This is not a clean solution, but it's the only way to pass useful informations from the gpu to the cpu that I know of. With this system I can send bytes instead of floats when, for example, needing a color.
Nessun commento:
Posta un commento