Failed to render Sprite3D to RenderTexture

Just as my title described, I render the orc.c3b to a newer created RenderTexture,nothing happend but a black screen as the result.However,when I render a normal 2D sprite,it works perfectly.My code is like followings:
auto renderTexture = RenderTexture::create(width, height, Texuture2D::PixelFormat::RGBA8888);
renderTexture->setPosition(screenWidth / 2, screenHeight / 2);

renderTexture->begin()
auto orc = cocos2d::Sprite3D::create(“Sprite3DTest/orc.c3b”);
orc->setPosition(width / 2, height / 2);
orc->visit(Director::sharedDirector()->getRenderer(), Mat4::IDENTITY, 0);
renderTexture->end()

addChild(renderTexture)

Could any one help me?Thanks a lot.

I tried to envoke saveToFile, and found that a black png file generated,so that means there is nothing renderd to the newer created framebuffer.
Hope heros come out to solve the problem…

A new great discovery:

This time I toggle some breakpoints and I found that the orc 3d mesh rendered just before the RenderTexture's onBegin envoking,so this implies the mesh render one frame to the main framebuffer,and nothing to do with the newer created one.

So it seems like a bug in this way.

After that, I found a way to render it out.I set the RenderTexture’s begin command and end commands’ _is3D field to true to make them in the same render command queue,and also make their _isTransParent field to false in case of command be ignored.However, the rendered sprite seems a little strange and I found out that I did not create the framebuffer with depth,so I change the initialization like this:
auto renderTexture = RenderTexture::create(width, height, Texuture2D::PixelFormat::RGBA8888. GL_DEPTH24_STENCIL8)
renderTexture->beginWithClear(0, 0, 0, 0, 1, 0);
And…ops…the problem is still there,seems like depth test does not work at all;

At last my problem got solved!The problem is that RenderTexture will multiply an orthographic matrix to the projection matrix in default manner,I don’t know why but it really mess up the model’s z coordinate and make it such like a depth test problem! So I call renderTexture->setKeepMatrix(true) to avoid this multiplication.

reload0236, hi!

Can you please share a working code? Because I can’t make it works :frowning:

works with 3.15

test case RenderTextureWithSprite3DIssue16894