CCRenderTexture rendering artifacts

Hello,

Here is a simple project which just creates a CCRenderTexture and renders some text into it: https://github.com/pfedor/cocos2dx-bug

Here is what the output looks like on my iPad: http://i.imgur.com/nGElz.jpg (file also attached.)

Notice that the fourth row of characters has a horizontal line of weird artifacts striking across it. There are also two similar vertical lines, though they’re harder to see, one going down from the third “1” in the top row and the second one starting at the last-but-one “9” in the top row.

I’ve observed this problem both in the Simulator and on the device, with or without enableRetinaDisplay(), on iOS 5.1 and 6.0, with Xcode 4.4.1 and 4.5.

The problem is not limited to rendering of text, I’ve observed similar fault lines when drawing lines into a CCRenderTexture.

The problem seems specific to CCRenderTexture since when I rendered the exact same text just by creating a CCLabelTTF and adding it to the layer there were no such artifacts.

Looking forward to hearing your thoughts.

Thanks,

Aleksander


nGElz.jpg (707.8 KB)

This occurs because the default projection is set to 3D. The artifact is a result of using the alias setting on the texture. When the projection is set to 3D, even if there is no explicit scaling set on the object, the quad is rendered either slightly scaled up or down.

You can fix this by either enabling anti-alias on the texture within CCRenderTexture, however this will cause your texture to become blurry. The alternative solution is to set the default projection to 2D.

1 Like

Thank you William, that was very helpful!

Best regards,

Aleksander