I've created an issue on GitHub: Issue #16894
I spent the last couple days just working on this issue. I thought it was my code, but after writing a test in a fresh Cocos project, I now think its a bug (or unsupported feature?) with Cocos2d-x. Happens in cocos v3.11.1 v3.3. So maybe RenderTexture has never supported Sprite3D?
I don't have a good understanding of depth buffers, so my usage of
GL_DEPTH24_STENCIL8 could be incorrect. Maybe I'm missing something simple and it does work somehow?
I'm pretty bummed out this doesn't work. I'm using RenderTextures for post-process effects and replays. My current workarounds are to either stop using Sprite3D or to stop using RenderTextures.
Finally, thank you for building a great engine! Earlier this year I used it to ship Astro Duel on Steam and have bigger and better games on the horizon.
(Reposting from Issue #16894)
RenderTexture does not work with Sprite3D.
By default, RenderTextures don't create a depth buffer and so a Sprite3D is rendered without a depth test. The create method on a RenderTexture can accept a depthStencilFormat.
When supplying depthStencilFormat,
GL_DEPTH24_STENCIL8 for example, the
RenderTexture internally creates and attaches a depth buffer. However the RenderTexture results are mostly blank and glitchy.
Full Code Gist