Babylon.js icon indicating copy to clipboard operation
Babylon.js copied to clipboard

Reuse defines in bindForSubMesh functions !

Open NicolasBuecher opened this issue 9 years ago • 3 comments

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 !

NicolasBuecher avatar Jul 31 '17 14:07 NicolasBuecher

I still will keep the textures enabled test but agree on everything else And the return is obviously a bug;)

deltakosh avatar Jul 31 '17 14:07 deltakosh

Great !

NicolasBuecher avatar Jul 31 '17 14:07 NicolasBuecher

The continue test was implemented ;)

deltakosh avatar Aug 23 '17 18:08 deltakosh