Jump to content

[SOLVED] Create screenshot using WebGL 2 MSAA and RenderTargetTexture ?


PeapBoy
 Share

Recommended Posts

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 ! :)

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...