Reuse defines in bindForSubMesh functions !
Hello,
It's been a long time I wonder why we're doing the same tests in ready and bind functions. Since these two functions are called successively. If the isDirty flag system works fine, we could always do the tests in the isReady function, compute the defines and reuse these defines in the bind function. It would save a few tests per frame, no ? Anything prevent us to do so ?
For instance :
if (scene.texturesEnabled) {
if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled)
would be :
if (defines.DIFFUSE)
I implemented it and I got errors. In Material._markAllSubMeshesAsDirty() function, we return if there's no defines on a subMesh. Why ? If I replace return by continue, everything works great though !
I still will keep the textures enabled test but agree on everything else And the return is obviously a bug;)
Great !
The continue test was implemented ;)