Why does needDepthPrePass cause onEffectCreatedObservable to fire on every frame?

im trying to scene.render() only when an effect is created. in the below example pressing the t key will swap in a new texture and render the scene once. for our usecase we dont want the renderer to be rendering when the scene is idle so this is a small cross section of the kind of events we’re watching for to trigger rendering. one such trigger is to look for onEffectCreatedObservable events and set the render flag then. this is necessary for texture updates and other shader updates. however we noticed this event fires every frame when needDepthPrePass=true.( you have to set that flag in the pg example) Not exactly sure whats going on under the hood here but if there is a better logic to handle this situation id be curious.

pg:

needDepthPrePass=true is particular in that a mesh is rendered two times, with two variations of the material: in the first one, color writing is disabled, and in the second one it is enabled. So, there are two effects involved when rendering meshes with such materials.

Here’s a way to handle it, albeit a bit hackish: