Using OpenGL framebuffer object in custom rendering in Viewport 2.0

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 07 July 2012   #1
Using OpenGL framebuffer object in custom rendering in Viewport 2.0

Hi,

I'm trying to code a draw override for a shape in the viewport 2.0.
Everything works fine until i try to draw into an offscreen framebuffer.
If I bind an offscreen framebuffer (glBindFramebuffer()), it looks like Maya's screen buffer is erased (all black).
I do it in MPxDrawOverride's 'prepareforDraw()' method.
When I tried to use framebuffer in stand-alone program it did not erase screen buffer.
Does anybody know how framebuffers work in Maya? Or more importantly how to draw to a texture in Maya without corrupting what was already drawn on the screen?

I tried to overcome this problem by saving the screen buffer by M3dView::readColorBuffer() and then upload it back after offscreen drawing but it is a bit slow and fails when multisampling is enabled.

Thanks for any advise.
 
Old 07 July 2012   #2
once i tried also to use OPENGL in my own maya plugin. seems since maya itself use OPENGL, the framebuffer would always got influenced with each other between user's framebuffer and maya's....
create a complete new thread will solve this problem(once asked similar question here, got this ) but maybe better not use your own OPENGL in maya?
i myself don't know much about this, hope there are better solution ^_^
__________________
know more:Maitreya's Song
 
Old 07 July 2012   #3
Quote:
Originally Posted by Maitreya
once i tried also to use OPENGL in my own maya plugin. seems since maya itself use OPENGL, the framebuffer would always got influenced with each other between user's framebuffer and maya's....
create a complete new thread will solve this problem(once asked similar question here, got this ) but maybe better not use your own OPENGL in maya?
i myself don't know much about this, hope there are better solution ^_^

Thanks for reply. I think that using OpenGL in Maya is completely valid. For some reason framebuffer object is corrupting Maya's Viewport 2.0. I just found out that it works fine in default viewport so the problem lies in the Viewport 2.0.
 
Old 07 July 2012   #4
Since I'm a frustrated viewport2 user I'll be interested to hear if you eventually work around your problem. Sorry I cant help with the coding though.

I did want to point out that the behaviour you describe with the buffer erasing to black sounds similar to what I get when I use script extra modelPanel/modelEditor setups with viewport2. Closing one panel sometimes causes the other to go black. There are plenty of other issues so it may be for different reasons, but there it is.

I'd love it if you'd drop back every little while and let us know how its going.

cheers
David
__________________
http://www.djx.com.au
 
Old 07 July 2012   #5
So long as you're in 2012+, you might want to have a look at the blastCmd.cpp file. It illustrates usage of some Maya FBO API to render to an offscreen texture and write it out to disk. The purpose of that plug-in is to create your own playblast.

I believe that plug-in might only be shipped on Linux, or perhaps it was just the binary is only precompiled on Linux. I can't recall. I customized it on Linux and it worked mostly, although there was a bug if you wanted to render a size other than the current viewport size. I believe thats fixed in the latest 2013 SP though.

In any case, hope this helps.

Edit: In case this is also an alternative for your needs, another approach is to use MRenderOverrides. This is mostly your typical post-effect script chain. You can set up buffers to render into and reuse them as shader inputs down the line. But of course this has rather limited value depending on what you need your offscreen texture for.

Last edited by Keilun : 07 July 2012 at 07:38 PM.
 
Old 07 July 2012   #6
When I need some manual stuff, I personally prefer not to rely on maya, and to work instead with my own opengl environment. When performance is needed I also setup a fbo (glGenFramebuffersEXT). Also see if you can find something useful in the following discussion:

http://forums.cgsociety.org/showthr...43&page=1&pp=15
 
Old 07 July 2012   #7
Thanks for replies.

I work in Maya 2012.
Unfortunatly I wasn't able to find the blastCmd.cpp file.

Rendering to own opengl context seem interesting, but I don't have much time to test it now.

Anyway, I found out that if I enable shadow mapping in Viewport 2.0, my code works well. But the Maya's shadow map don't work. Maya is probably internally using fbo for shadow mapping so there is something fishy.
I'll probably try to port the code to Maya 2013 if there would be a difference ...
 
Old 07 July 2012   #8
I finally found out where the problem was (the idea came during washing dishes ).

Viewport 2.0 draws not directly to screen buffer, but to some custom framebuffer object (which I did not realize). What I did was that I bound my custom framebuffer, renderer what I needed, and then bound the default screen framebuffer, not the framebuffer Maya was using. That lead to the wierd behaviour I described earlier.

Anyway, thanks for the support. Hopefuly, this thread will help somebody and he would not have to waste many long hours on this problem like I did.
 
Old 07 July 2012   #9
Not to be completely off topic here, but Dave, is your icon the chick from die antwoord..?
__________________

 
Old 07 July 2012   #10
If it's any help than have a look at the gpuCache plugin in the devkit of 2013. i just had a quick look at it and it uses vbo's. there also a viewport 2.0 implementation (gpuCacheGeometryOverride files)
 
Old 07 July 2012   #11
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 07:17 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.