Open silwings opened 9 years ago
@dabingnn @super626 is there any reason we should call render separately with camera? multiple viewports?
@silwings and @darkdukey Thanks.
The camera has effect on the render texture. I am thinking better way to use render texture.
The reason we call Renderer::render()
early is that one object can be seen by many cameras, these cameras can have same viewport or different viewports.
Because the render command we push during visit is pointer, we should render it after single visit routine. It may be modified by the second camera otherwise.
@super626
Another workaround that doesn't have to change cocos2d-x would be to insert RenderTexture's begin()
and end()
at the start and end of a node's visit()
. It may render the node and all its children to the FBO. I will give it a try.
Ok, thanks.
On Wed, Dec 3, 2014 at 3:10 PM, Wang Cong notifications@github.com wrote:
@super626 https://github.com/super626 Another workaround that doesn't have to change cocos2d-x would be to insert RenderTexture's begin() and end() at the start and end of a node's visit(). It may render all the node and its children to the FBO. I will give it a try.
— Reply to this email directly or view it on GitHub https://github.com/cocos2d/cocos2d-x/issues/9329#issuecomment-65364295.
Add to unplanned roadmap because we're redesigning the render queue in v3.7
Calling
Renderer::render()
right afterScene::visit()
inScene::render()
may cause problem under below scenario:Assuming we need to render all the scene graph into a
RenderTexture
for post processing or screen capturing. A common way would be register twoEventListener
, one forEVENT_AFTER_UPDATE
and one forEVENT_AFTER_VISIT
.Then call
RenderTexture::begin
andRenderTexture::end
in these two listeners' callback.But during runtime,
Renderer::render()
will be called beforeRenderTexture::end()
, then theRenderer
will consume theGroupCommand
inserted byRenderTexture::onBegin()
, causingRenderTexture::onEnd()
, which is on the new insertedRenderQueue
, never be executed.Currently, a simple workaround is to comment the
Renderer::render()
inScene::render()
at Line 146 and Line 159 in CCScene.cpp. Although not been thoroughly tested, it seems harmless both in logic and actual running, becauseRenderer::render()
will be called shortly afterScene:render
at Line 306 in CCDirector.cpp