Projects > cpp > Issues > Bug #4605

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

Strange behavior with CCRenderTexture, setVertexZ, and Depth Buffers.

Bug #4605 [Closed]
rcbuse 2014-03-30 03:11 . Updated over 10 years ago

I've witnessed a strange behavior using CCRenderTexture that I'm wondering if its a bug or I'm missing something.

I have a whole bunch of batch nodes with sprites using setVertexZ for ordering. All the Z values fall between -1000 and 0. When the batch nodes are attached as children to a CCScene, everything works as expected, things are on top of other things and the sprites alphas are working as well. (See attached A)

Now, when I put those children on a CCRenderTexture with depth buffers, Things get a little strange. Its almost like its using the depth buffer backwards. (See attached B)

I've traced it down to this line in CCRenderTexture::begin():

    kmMat4OrthographicProjection(&orthoMatrix, (float)-1.0 / widthRatio,  (float)1.0 / widthRatio,
        (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1 );

I don't see the expected behavior with my scene until I swap the near and far parameters:

    kmMat4OrthographicProjection(&orthoMatrix, (float)-1.0 / widthRatio,  (float)1.0 / widthRatio,
        (float)-1.0 / heightRatio, (float)1.0 / heightRatio, 1, -1 );

Once I do that, everything renders perfectly on the CCRenderTexture.
Am I missing something or is this a legitimate bug?

Screen Shot 2014-03-28 at 2.11.42 PM.png (27 kB) rcbuse, 2014-03-30 03:11

Screen Shot 2014-03-28 at 2.15.49 PM.png (21.7 kB) rcbuse, 2014-03-30 03:11

rcbuse 2014-04-03 18:45

Just to add to the above. I'm running cocos2d-x 2.2.2 and seeing the issue on both OS X and iOS.

walzer@cocos2d-x.org 2014-10-08 02:49

Redmine issue system is closed, we are using github issue system instead.

This issue was moved to https://github.com/cocos2d/cocos2d-x/issues/8390

Atom PDF

Status:Closed
Start date:2014-03-30
Priority:Low
Due date:
Assignee:-
% Done:

0%

Category:all
Target version:-