Open frenchtoast747 opened 7 years ago
We have to be able to send material information via vertex attributes. There are three strategies:
This is nice because it requires the least amount of information per-vertex. This is bad because you have to put the materialIndex int into a float and compare which is error prone and slow for the GPU. This makes it pretty much a non-option (though we should keep it anyway since it doesn't hurt anything and might be useful for some special cases)
This is great because it's super easy. It's bad because it wastes tons of bandwidth and memory packing the same material info over and over per-vertex.
vec3 diffuse = mat0.diffuse * materialWeight0 + mat1.diffuse * materialWeight1 + ... + mat(N-1).diffuse * materialWeight(N-1);
This is like a mixture of both strategies. You can still send all the material info in via uniforms, but you send a bunch of data about which ones are available so you can avoid conditionals in shader code.
Enable or disable materials via the
MATERIAL_WEIGHT
attribute.@qtip feel free to expand your thoughts on this issue.