tsherif/picogl.js

Renderbuffer support

martinleopold opened this issue · 4 comments

First: Love your approach with this library!

The only thing I was missing going over the API Docs was a Renderbuffer class.

Main use case would be multisampled render targets, I guess.

Would require some changes to Framebuffer as well, to be able to attach renderbuffers (instead of textures) as color/depth/stencil buffers.

Thanks :) Would be happy to do this or accept a PR for it. I like to build new features around example cases though. Could you point me to some documentation about that multisampling use case you mentioned?

Maybe we could make some basic MSAA example? Just rendering to some multisampled framebuffer, adding some post processing (to justify using an intermediate framebuffer), and pushing it to the screen.

That is a pretty normal use case I would imagine. On the other hand, I personally don't have much use of multi-sampling support as of now.

I reckon post processing is very common in this day and age. The simplest use case is maybe color grading, grayscale, contrast etc.
Here is a non-exhaustive list: https://en.wikipedia.org/wiki/Video_post-processing#Uses_in_3D_rendering

From the top of my head, I can think of two reasons for using a renderbuffer attachment instead of a texture:

Oh and, coming from the outside I had expected pico.gl to provide the full set of WebGL 2 features ;)

There's already an API that supports the full WebGL 2 feature set. It's called WebGL 2 ;)

Postprocessing requires rendering to a texture, so that's already supported (many of the techniques in the list you linked to are currently in the PicoGL examples). Since you can't sample from a renderbuffer, you can't do any postprocessing on it unless you copy it into a texture (as is done in Shrek's MSAA example).

That said, I wouldn't mind building something around Shrek's MSAA example, probably with a check box to enable/disable the MSAA so people can see the difference. To my mind this would require creating a RenderBuffer class that takes width, height, internal format in the constructor. FrameBuffer would have to be updated to accept RenderBuffer targets. And we'd need a framebufferBlit method on the App class.

Would be happy to accept a PR for this if someone wants to take a crack at it.