prepassRenderer failed to enable when camera changing and render target rendering in one frame

Not sure if this is a bug as it is in a really unusual case.

Basically I have a postprocess that need prepass renderer’s position sampler, so I just display the sampler in the pg.
And I will get up-down depth using another camera when user want, so I call it settimeout 1000. For some reasons I cant init the texture in advance.
After capture camera should be set back to the origin one and I call it settimeout 2000.

I went through the code and find the reason. PrepassRenderer will update when t2 is rendered, and as active camera is changed, the boolean enablePrePass in PrepassRenderer._update will be false, so the update just disable the prepass renderer and did not enable agagin. I have to call _update again after set active camera back(And I’m curious why just call _enable not work).

cc @sebavan

I think setting the prepass as being dirty would be better in this case https://playground.babylonjs.com/#JAVY4F#43 and not use anything internal :slight_smile:

Regarding the missing part I guess we should flag as dirty on active camera changes to be safe ? @Evgeni_Popov could confirm ?

I just notice I forget to add noPrePassRenderer to t2, so my problem can be solved by setting that, however the bug still exists in a more unusual case :joy:, so I will keep the thread open.