DNESS / cocos2d-iphone

Automatically exported from code.google.com/p/cocos2d-iphone
1 stars 0 forks source link

Precision of v_texCoord in built in shaders is not adequate when using large 4096x4096 spire sheets #1478

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a large sprite sheet with 4096x4096 e.g with TexturePacker or other 
sprite sheet creation tool. Use debug option to create outline of sprites. Set 
also innerpadding of sprites to 2 pixels.
2. Create a cocos2d application and load the sprite sheet 
3. Create CCSprite objects from the cached CCSpriteFrame objects
4. Add sprites to the main scene objects

What is the expected output? What do you see instead?
Expected: sprites displayed correctly and outline of sprites are visible.
Actual: Some sprites are missing the outline on one side i.e. the sprite frame 
is shifted +/- 1 pixel

What cocos2d version / SVN revision are you using ?
2.1-rc1

What iPhoneSDK are you using ?
iOS 6.1

Debug or Release ?
Both

Does this happens on device ? or on the simulator ? or on both ?
This happens only on the device. I've used iPad 4 retina.

Please provide any additional information below.
I've investigated the problem and found that the problem is caused by precision 
loss of texture coordinates when used with large textures (4096x4096).
Since, the built in shaders in coco2d are using 'medium' precision for 
v_texCoord in case of GL_ES +/- 1 pixel shifting of sprite frames can happen.
The solution that worked for me to use 'highp' for v_texCoord both in vertex 
and fragment shaders in cocos2d shaders.

Original issue reported on code.google.com by attila.b...@gmail.com on 30 Mar 2013 at 10:47