Advanced Dynamic Texture for Mesh: CheckUpdate depending on Camera?

Hi,

In my scene I have an ADT attached to a mesh and I have multiple cameras rendering the scene. Checking in the performance monitor on Dev Tools I can see that the ADT render is being called for each camera, which I would like to turn off as the ADT only needs to be rendered once (and it is taking >15ms per render). I can see in the source code that if I have a fullscreen ADT thejn I can prevent the render by using layers so that _checkUpdate returns without rendering however there doesn’t seem to be a way to do this when using ADTs for mesh. The relevant code in ADT._CheckUpdate is

    if (this._layerToDispose) {
        if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
            return;
        }
    }

and _layerToDispose is only set when using a fullscreen ADT.

When I render with subsequent cameras I can call scene.render(false, true) to ignore animations/physics but the ADT still updates. Ideally the ADT would also not update if ignoreAnimations is true but failing that a way to specify whether the ADT should update for the current camera would be good. Is there a way to achieve this? Perhaps removing the ADT._renderObserver and then re-adding it? Or clearing it and replacing it with an observer that checks the camera first then calls _checkUpdate if required? Or is there another way to global prevent ADTs from updating?

Removing the observer and adding your own one that would check the camera before calling _checkUpdate is probably the best thing to do. However, I don’t understand why the ADT would be updated for each camera, because once it is updated for the first camera, the isDirty flags should be reset to false and we should not reach the code that render/update the texture:

private _checkUpdate(camera: Camera): void {
    [...]
    if (!this._isDirty && !this._rootContainer.isDirty) {
        return;
    }
    this._isDirty = false;
    this._render();
    this.update(this.applyYInversionOnUpdate, this.premulAlpha);
}

(the call to this._render() should reset the this._rootContainer.isDirty flag).

Ah, interesting. I will check tomorrow and see if something is triggering isDirty.
Thanks.