I have noticed that there are duplicated codes for binding shader defines, attributes, and samplers in multiple renderers.
Furthermore, the problem is that this code needs to be written to fulfill all the specifications of the engine, and it seems prone to errors due to human mistakes.
For example, in the OutlineRenderer
, there is no code to set the uniform and attribute for BakedVertexAnimation, so it causes issues with rendering meshes that use BakedVertexAnimation.
BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Rendering/outlineRenderer.ts
According to the implementation of the standardMaterial, these binding codes are required.
BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Materials/standardMaterial.ts#L1791
Although there is a code in the MaterialHelper
class for binding, it seems that there are classes where the same code is duplicated without utilizing this method yet.
BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Materials/materialHelper.ts
For example, the DepthRenderer
and ShadowGenerator
classes have almost identical code for binding bone-related parameters, as shown below:
To solve this issue, it seems that something like an “automatic binding object” that removes the duplication of binding codes would be necessary. Is there any plan for refactoring in this regard?