rohit.gonsalves Posted July 28, 2021 Share Posted July 28, 2021 Hello There, I using following code to render a specific node on my RenderTarget. I need node should be render on transparent target so I can use it for further processing. Probably renderNode method internally flushing the render target with opaque black first? But node is rendered on opaque black. How may I achieve the other areas as transparent? May there is way using GBuffers? RenderState::saveState(); RenderState::clearStates(); RenderState::setBlendFunc(RenderState::BLEND_SRC_ALPHA, RenderState::BLEND_ONE_MINUS_SRC_ALPHA, RenderState::BLEND_OP_ADD); RenderState::flushStates(); m_objTextureRender->bindColorTexture(0, textureOutput); m_objTextureRender->enable(); RenderState::setBufferMask(0, RenderState::BUFFER_ALL); //This red never shows up as internally target is flushed with opaque black. RenderState::clearBuffer(RenderState::BUFFER_ALL, vec4(1.0f,0.f,0.f,1.0f)); m_objTextureRender->flush(); if (m_objIDNode != nullptr) { m_objViewport->renderNode(m_objPlayer->getCamera(), m_objIDNode); m_objTextureRender->flush(); } m_objTextureRender->disable(); m_objTextureRender->unbindColorTexture(0); RenderState::restoreState(); Please suggest. Rohit Link to comment
sweetluna Posted July 28, 2021 Share Posted July 28, 2021 Hi, You can use renderTexture2D to render node to the specified texture w/o needing of creating own render target. Regarding alpha channel, you can set this flag for your viewport m_objViewport->setNodeLightUsage(Viewport::USAGE_WORLD_LIGHT); The only thing to consider this will render environment with 0 alpha sky. 1 May RenderDoc/Nsight Graphics/Intel GPA bless you Link to comment
rohit.gonsalves Posted July 29, 2021 Author Share Posted July 29, 2021 Thanks @sweetluna, This solved my issue. Prior to this I was trying it with Auxiliary. But Alpha blend things were not working with Auxiliary. This render node by setting skip flags gave me the correct result. I chose to define render target as BG color is of choice for generating different masks. Rohit 1 Link to comment
Recommended Posts