Jiri Formanek Sprites are blurred
Posts 26
Added by Jiri Formanek almost 2 years ago

Hello friends,

I have a problem with rendering CCSprite sprite :)
I noticed that some of my sprites are blurred. It is more visible on device. But I found out, that if the sprite is near the center of the display it is perfect. So blurred are only sprites that are near to edges.

I tried find information about this, but I found only one suggestion for cocos2d-iphone - it's autoscale parameter of CCDirector::init() method. But there is no such parameter in cocos2d-x.

Any suggestions?

Thank you very much.

Swap

Zhe Wang RE: Sprites are blurred
Posts 1642
Location Amoy, China
Added by Zhe Wang almost 2 years ago

cocos2d-x has its autoscale mechanism, and it's different between platforms. ( A little ugly, I admit, aha).
A wiki page is here: How does cocos2d-x support multi-resolution
You situation hasn't been reported before, so a screenshot or a photo would explain this stuff better. And an unit test, simply hack helloworld to reproduce this bug will be highly recommended!

Enjoy Coding, Enjoy Life.

Jiri Formanek RE: Sprites are blurred
Posts 26
Added by Jiri Formanek almost 2 years ago

Hello,
thanks for answer.

I've added the test project (simple with 5 sprites) and two screenshots from the simulator.

It is rather different that I wrote before, because now are blurred sprites in the center (the second image). Zoom the screenshot to perfect view of the defect.
The first image is different. There are blurred sprites at the top and the bottom. Centered one is quite good but not perfect.

I was testing only on ios platform without retina display enabled. I used template from cocos2d-x. I am using XCode4.

Swap

blurred-sprites.zip - test project (348.8 kB)

screen.tiff - example 1 (30.7 kB)

screen2.tiff - example 2 (59.3 kB)

Zhe Wang RE: Sprites are blurred
Posts 1642
Location Amoy, China
Added by Zhe Wang almost 2 years ago

I am tracing this bug, but haven't resolved it.
The bad thing is that, cocos2d-iphone has the same problem. cocos2d-x inherit this bug.

I use cocos2d-iphone 1.0.0-rc3. and translate your code to

#define WIDTH 320
#define HEIGHT 480

CCSprite* sprite1 = [CCSprite spriteWithFile:@"something.png"];
sprite1.position = ccp(WIDTH/2, HEIGHT/2);
[self addChild:sprite1];

CCSprite* sprite2 = [CCSprite spriteWithFile:@"something.png"];
sprite2.position = ccp(WIDTH/2,HEIGHT/4);
[self addChild:sprite2];

CCSprite* sprite3 = [CCSprite spriteWithFile:@"something.png"];
sprite3.position = ccp(WIDTH/2,HEIGHT/4*3);
[self addChild:sprite3];

CCSprite* sprite4 = [CCSprite spriteWithFile:@"something.png"];
sprite4.position = ccp(WIDTH/4,HEIGHT/2);
[self addChild:sprite4];

CCSprite* sprite5 = [CCSprite spriteWithFile:@"something.png"];
sprite5.position = ccp(WIDTH/4*3, HEIGHT/4);
[self addChild:sprite5];

No matter running on iphone3 simulator or ipad simulator, it looks the same as your tiff pictures.
I run it on iphone4, and get the screenshot

Enjoy Coding, Enjoy Life.

Jiri Formanek RE: Sprites are blurred
Posts 26
Added by Jiri Formanek almost 2 years ago

Hello,

do you have any solution to workaround the problem? I do not understand that anybody does not find the same problems before. The behaviour seems to be random :-(

Thanks.

Swap

Zhe Wang RE: Sprites are blurred
Posts 1642
Location Amoy, China
Added by Zhe Wang almost 2 years ago

Hi, Jiri, I just learn this from Riq.

  1. edit ccConfig.h
  2. #define CC_COCOSNODE_RENDER_SUBPIXEL 0

This will work for you. Have a try!

Enjoy Coding, Enjoy Life.

Jiri Formanek RE: Sprites are blurred
Posts 26
Added by Jiri Formanek almost 2 years ago

Hello,
thanks fo reply. But I think that there is no effect setting CC_COCOSNODE_RENDER_SUBPIXEL to 0 :(

Swap

Zhe Wang RE: Sprites are blurred
Posts 1642
Location Amoy, China
Added by Zhe Wang almost 2 years ago

oops, :( too

Enjoy Coding, Enjoy Life.

Zhe Wang RE: Sprites are blurred
Posts 1642
Location Amoy, China
Added by Zhe Wang almost 2 years ago

One of my friend met the same problem, and he told me CCDirector::sharedDirector()->setProjection(kCCDirectorProjection2D) will fix this, while the default setting is kCCDirectorProjection3D.

Enjoy Coding, Enjoy Life.

Jiri Formanek RE: Sprites are blurred
Posts 26
Added by Jiri Formanek almost 2 years ago

Hello,
thank you very much. It works perfectly now!!!:)

Laurens Rodriguez RE: Sprites are blurred
Posts 26
Added by Laurens Rodriguez about 1 year ago

Hi, sorry to resuscitate this thread, but I think that

CCDirector::sharedDirector()->setProjection(kCCDirectorProjection2D

only works if the sprite in pixels are even? odd sizes give me blurred images.
I'm doing something wrong? I am using a RenderTexture and sprites from a big texture map.
Thanks!

Steven J RE: Sprites are blurred
Posts 11
Added by Steven J about 1 year ago

This is happening on HD for me. The fixes above may help, and try this: add 0.5 or some similar between-1-and-0 value. This is a known issue with the iPhone trying to render halfway between pixels, not just OpenGL. The iOS manuals may provide some help, but I don't think they'll provide much for you. In the meantime, try to figure out where/why it's doing the half-pixel thingy and adjust the scale/width/size


(1-11/11)