Projection matrix not correctly reset

Hi,

I’ve made a class (derivated from Layer) to allow the use of a global shader on a whole layer (as postprocessing).
The idea is to render all the objects of a layer in a texture, this texture is then used by a sprite (which have the same size and position than the layer) and rendered on screen using a shader on the whole texture.
It allows nice effects on a whole scene without having to manually setup the effect per sprite.
The effect (shader) can be enabled/disabled on the fly.

My class used to work properly (for my use case) when I used it as a whole screen layer effect. My layer had the same size as the screen. In that specific case the class works fine.
Now I wanted to use it on a layer which has a different size than the screen and I noticed it didn’t work.
Tracing the produced GL code, I noticed the projection matrix was not correctly reset to the layer’s parent when applying the final sprite (the one with the offscreen texture).
I tried many thinks to force an update of the uniforms, without luck, and it looks more like a hack than anything else.

Could someone from the cocos team (or anybody else) could take a look at the attached zip file.
It contains everything to reproduce the issue, as well as my ShaderLayer class, by simply creating a new cocos3.6 project and replacing the files.
The class could then be added to the cocos core, if you wish.

The project starts with the shader disabled on the layer, it’s correctly placed in the middle of the screen. Clicking on the sprite will enable the shader, and you’ll see the rendered sprite move away from it’s correct position (but it’s only the rendering, clicking again on the middle of the screen where the sprite was, will disable the shader and the sprite will go back to it’s correct position).

Thanks for any help fixing this class for any layer size.

TestShaderLayer.zip (575.2 KB)