Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] Add framebuffer back to the BGL wrapper #536

Closed
HG1-Public opened this issue Jul 18, 2017 · 14 comments
Closed

[Request] Add framebuffer back to the BGL wrapper #536

HG1-Public opened this issue Jul 18, 2017 · 14 comments

Comments

@HG1-Public
Copy link

Dalai Felinto has added framebuffer to the BGL wrapper. But after the has fished his offscreen patch he has removed it from the BGL wrapper.
I need it back, because I need more control over the frame buffer (eg. glReadPixels).
Basically I need to bind the buffer with glBindFramebuffer.
commit d3a1b465ba61f0577dec2615e332a686ec3032fb
revert commit 18d5ac5b55cba40835a9b513347b87f658d9bad5

It would be also useful, if there would be attribute which would return the actual framebuffer ID.
Actually I use GL_READ_FRAMEBUFFER_BINDING to get the actual framebuffer ID. Which is not 100% save if you use multiple framebuffer.
readFboId = Buffer(GL_INT, 1)
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, readFboId) # for backwards compatibility, GL_FRAMEBUFFER_BINDING is equivalent to GL_DRAW_FRAMEBUFFER_BINDING

@solhrdulik69
Copy link

Yeah, and speed up for glReadPixels

@panzergame
Copy link
Contributor

@HG1-Public, hrm, i could not find the commit hash in the latest blender/master...

@HG1-Public
Copy link
Author

Somebody has deleted the branch so the patch is not available any more. But I found a backup on Google http://bf-blender-cvs.blender.narkive.com/45UvaV0h/d3a1b46-framebuffer-bgl-gl-3-0-methods-framebuffer-related.

I updated the path for the UPBGE.
BGL GL 3.0 methods (Framebuffer related)2.diff.zip

@solhrdulik69 you can't speed up glReadPixels it self. The only way is to use a PBO to speed up the reading.

panzergame added a commit that referenced this issue Jul 28, 2017
@panzergame
Copy link
Contributor

Could you test again in master ?

@HG1-Public
Copy link
Author

I can't test every function call. I modified my sound shader example (glBindFramebuffer) and works fine.
https://blenderartists.org/forum/showthread.php?434833-Music-from-sound-shader

I also tested it with my FBO example https://blenderartists.org/forum/showthread.php?396018-FBO-hack-using-OpenGL-Wrapper-with-deferred-rendering-shader.
Actually I only get an black image. I think it is because I can't generate an empty texture glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width+viewport[0], height+viewport[1], 0, GL_RGBA, GL_UNSIGNED_BYTE, None) # I can't pass an empty pointer here.
But I don't get an error. So I think the other function calls are also working.

Tested:
glCheckFramebufferStatus
glGenFramebuffers
glBindFramebuffer
glFramebufferTexture2D
glGenRenderbuffers
glBindRenderbuffer
glRenderbufferStorage
glFramebufferRenderbuffer
glDrawBuffers
glDeleteFramebuffers
glDeleteFramebuffers

@panzergame
Copy link
Contributor

Could you debug with apitrace or at least send a trace please ?

@HG1-Public
Copy link
Author

The Api trace is not very use full here. The shortest call trace that I was to produce is 22 MB big https://www.dropbox.com/s/sl701v4h9xeu0b3/Framebuffer1.2.blend?dl=0.
And the error log only prints out only the default Blender OpenGL errors after start. If I run the script no new errors will be logged.

I am pretty sure that the black screen is no BGL related issue.

  1. I don't changed Dalai's modifications.
  2. I also get a black screen if I use the original version with in the UPBGE. So It must be some other issue. Looks like that it is caused by the shader (version 120, in/out problem).

@panzergame
Copy link
Contributor

I got this result:

2017-08-01-012736_1280x1024_scrot

Is it what is wanted ?

@HG1-Public
Copy link
Author

Ups. Wrong link. This was my test file (G-Buffer test).
Here is the link to the trace file https://www.dropbox.com/s/v77l9knlc28osmz/blender.6.trace?dl=0

Is it what is wanted ?

No. The final image should look like as the screenshot in https://blenderartists.org/forum/showthread.php?396018-FBO-hack-using-OpenGL-Wrapper-with-deferred-rendering-shader.

@HG1-Public
Copy link
Author

The framebuffer calls are working. The issues are caused by the changes in the UPBGE (render timing and viewport).

  1. Some changes in the shaders are needed because of the different openGL version.
  2. The framebuffer now need to enabled in the pre_draw to get the images rendered.
  3. If I enable the framebuffer the viewport will be drawn over the render plane (I moved it outside to see the rendering result).

@panzergame
Copy link
Contributor

panzergame commented Aug 2, 2017

@HG1-Public : As i understand you want to bind a framebuffer to get the scene rendered to it ? If this is the case it should never works because we bind a FBO internally for rendering.

@HG1-Public
Copy link
Author

As i understand you want to bind a framebuffer to get the scene rendered to it ?

Yes that is what this example will do.

Could you test again in master ? #post 7

I don't need to get this example working in UPBGE. I only used this example to test that the new API is working correct.

@panzergame
Copy link
Contributor

Can i close this issue if all back to normal ?

@HG1-Public
Copy link
Author

Yes. Can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants