cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.2k stars 7.06k forks source link

FrameBuffer multisampling support #16820

Open IgorMats opened 7 years ago

IgorMats commented 7 years ago

Can someone please add multisampling support for experimental::FrameBuffer and render target to texture!? I think it's really awesome feature for post processing. I have tried to do it by myself but always get opengl error 0x0506.

Can please someone help me?

dumganhar commented 7 years ago

Yes, we need this feature. Currently, we even don't have a test case for FrameBuffer class although it's in experimental namespace.

Could you share your work about multisampling? I will be glad to check it out why it causes the opengl error 0x0506.

IgorMats commented 7 years ago

@dumganhar Do you know is it true that GL_TEXTURE_2D can't be multisampled like described here so I can use multisampling only with RenderTargetRenderBuffer not RenderTarget?

IgorMats commented 7 years ago

It seems to be true so I have achieved this by create 2 frame buffers, one with render buffer target and another one with texture render target and then transfer render buffer to the texture of second frame buffer by calling glResolveMultisampleFramebufferAPPLE so I can't make pull request because this solution is not cross platform solution.

Maybe somebody can help me with Android?

Thanks.

dumganhar commented 7 years ago

Yes, I figured that GL_TEXTURE_2D_MULTISAMPLE isn't supported in OpenGLES, RenderTarget (which means rendering to texture target in cocos2d-x) probably will not work with multisampled feature.

It seems to be true so I have achieved this by create 2 frame buffers, one with render buffer target and another one with texture render target and then transfer render buffer to the texture of second frame buffer by calling glResolveMultisampleFramebufferAPPLE so I can't make pull request because this solution is not cross platform solution.

Good to know it works on iOS/Mac now. Yep, glResolveMultisampleFramebufferAPPLE is an apple specific gl extension function, we can't use it for other platforms. Could you upload test code which works on iOS/Mac to your github branch? I guess someone will help you to port it to other platforms.

IgorMats commented 7 years ago

@dumganhar I will try to support another platforms by myself and then will make pull request. If anyone can or would like to help me please write some message so we will can collaborate :) Thanks!