PeapBoy Posted March 9, 2017 Share Posted March 9, 2017 Hi everybody ! First of all, I'm not sure if I should begin a new thread or up these ones :http://www.html5gamedevs.com/topic/19285-create-screenshot-with-post-processing/http://www.html5gamedevs.com/topic/17404-babylon-screenshot/ With the new support of WebGL 2 by BabylonJS, I got interested in the multisample render target. Until now, I used my own version of createScreenshotUsingRenderTarget() function which performs MSAA manually (actually, it pixel perfect downscales a 4x bigger renderTargetTexture than the requested size). Now, I would like to rewrite it using the latest available features. What should I do to get an antialiased screenshot using multisample render target ? Just increasing the samples property of the RenderTargetTexture is not enough, I'll always get the following error : [.Offscreen-For-WebGL-098CA170]GL ERROR :GL_INVALID_OPERATION : glReadPixels: Which comes obviously from this line : var data = engine.readPixels(0, 0, width, height); https://github.com/BabylonJS/Babylon.js/blob/master/src/Tools/babylon.tools.ts#L627 Here is a PG where I copy/pasted a lighter version of createScreenshotUsingRenderTarget() function. The only real difference is the sampleCount parameter which is used to increase the samples property :http://www.babylonjs-playground.com/#SDTEU#29 Just press 1, 2, 3 or 4 key to call the createScreenshot() function with 1, 2, 3 or 4 samples. Thanks for your help ! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 9, 2017 Share Posted March 9, 2017 Let me check Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 9, 2017 Share Posted March 9, 2017 And it's fixed PeapBoy 1 Quote Link to comment Share on other sites More sharing options...
PeapBoy Posted March 10, 2017 Author Share Posted March 10, 2017 Hello, I didn't think it was a bug. But 1000 thanks. I love this commit ! GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
PeapBoy Posted March 10, 2017 Author Share Posted March 10, 2017 I just added a "samples" parameter to the createScreenshotUsingRenderTarget() function. I see that the value is already checked in updateRenderTargetTextureSampleCount() and _setupFramebufferDepthAttachments() functions (value in [1, gl.MAX_SAMPLES] range) therefore no need to check it again. So it's a one line change. Or maybe did you intend to create a new screenshot function ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 10, 2017 Share Posted March 10, 2017 this is fine thanks a lot Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.