Depth Error when render to image

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
xxelysion
Posts: 1
Joined: Tue Jun 06, 2017 8:51 am

Depth Error when render to image

Post by xxelysion »

Hi,
I use IMeshSceneNode to load a model and use function drawVertexPrimitiveList() in another ISceneNode named CRingSceneNode to draw a circle around the model. It works when rendering in main scene. But when I try to save it in a image, the circle seems always to be always on top.
These two sceneNode are managed by another node named CMainSceneNode and I invoke saveToFile function once to save the main scene in OnAnimate().
CRingSceneNode is set to be ESNRP_TRANSPARENT_EFFECT and material is EMT_TRANSPARENT_VERTEX_ALPHA. IMeshSceneNode's material is set to EMT_TRANSPARENT_ALPHA_CHANNEL_REF. (I tried EMT_SOLID but also didn't work.)

Code: Select all

int CMainSceneNode::saveToFile()
{
    irr::video::IVideoDriver* driver = getSceneManager()->getVideoDriver();
    irr::scene::ISceneManager* smgr = getSceneManager();
    rt = driver->addRenderTargetTexture(core::dimension2d<u32>(750, 1108), "RTT1");
    irr::core::rect<s32> preView = driver->getViewPort();
    driver->setRenderTarget(rt, true, true, video::SColor(0, 0, 0, 255));
    driver->setViewPort(recti(0, 0, 750, 1108));
    m_sceneMgr->drawAll();
    driver->setRenderTarget(0, true, true, 0);
    driver->setViewPort(preView);
    IImage* image = driver->createImage(rt, irr::core::vector2d<irr::s32>(0, 0), irr::core::dimension2d<irr::u32>(750, 1108));
    driver->writeImageToFile(image, "a.png");
    return 1;
}
 
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Depth Error when render to image

Post by CuteAlien »

Sounds strange. Can you give us a full example to reproduce the problem?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply