2

Due of tilting the rectangular polygon with texture, its edges become sharp. But inner edges (inner cut parts) still smooth.

Sharp edges of polygon

Texture has antialiasing enabled.

glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );    

It looks like antialiasing works just inside the bounds of polygon, but doesn't on edges. Is it possible to enable antialiasing on edges, so they look smooth like the inner edges in the picture? Used Cocos2d-x v3.3.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Petro Shm
  • 339
  • 2
  • 10
  • Quick workaround: add a 1px border to the texture with the background color/transparent. – Colonel Thirty Two Jan 15 '15 at 01:33
  • But if I use part of existed texture. Is it requires to copy this part to bigger texture with 1 px additional size? – Petro Shm Jan 15 '15 at 11:04
  • 1
    One option is to enable MSAA (multi-sampled anti-aliasing). Not sure how that's done with the tool you are using. I wrote an answer to a question here that explains it for OpenGL ES on Android: http://stackoverflow.com/q/27035893/3530129. – Reto Koradi Jan 15 '15 at 22:55
  • MSAA helps. Thank you! It is not perfect, but looks better. – Petro Shm Jan 17 '15 at 19:59

1 Answers1

2

Multi sampling enabled makes edges more smooth. It is not perfect solution, but on retina display looks nice. There is almost no difference between number of sampling 2 or 9 for this example.

enter image description here

Here is code how to set multi sampling in Cocos2d-x:

// In AppController.mm  

// Init the CCEAGLView
CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
                                     pixelFormat: (NSString*)cocos2d::GLViewImpl::_pixelFormat
                                     depthFormat: cocos2d::GLViewImpl::_depthFormat
                              preserveBackbuffer: NO
                                      sharegroup: nil
                                   multiSampling: YES
                                 numberOfSamples: 2 ];
Petro Shm
  • 339
  • 2
  • 10