CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 07-03-2012, 03:36 PM   #1
Muhe
New Member
portfolio
Tomas
Prague, Czech Republic
 
Join Date: Jul 2012
Posts: 4
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-06-2012, 01:52 AM   #2
Maitreya
Frequenter
 
Maitreya's Avatar
portfolio
arioso
Hangzhou, China
 
Join Date: Nov 2007
Posts: 142
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-06-2012, 09:42 AM   #3
Muhe
New Member
portfolio
Tomas
Prague, Czech Republic
 
Join Date: Jul 2012
Posts: 4
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-06-2012, 10:59 AM   #4
djx
Where's my pony?
 
djx's Avatar
David Johnson
vfx & creature td
Melbourne, Australia
 
Join Date: Jun 2003
Posts: 3,464
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-06-2012, 07:35 PM   #5
Keilun
Expert
Keilun
Canada
 
Join Date: Aug 2005
Posts: 738
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-06-2012 at 07:38 PM.
 
Old 07-07-2012, 02:09 PM   #6
zoharl
A newbie
 
zoharl's Avatar
portfolio
Zohar
Wellington, New Zealand
 
Join Date: Mar 2009
Posts: 1,821
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-07-2012, 07:03 PM   #7
Muhe
New Member
portfolio
Tomas
Prague, Czech Republic
 
Join Date: Jul 2012
Posts: 4
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-10-2012, 01:04 PM   #8
Muhe
New Member
portfolio
Tomas
Prague, Czech Republic
 
Join Date: Jul 2012
Posts: 4
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-10-2012, 07:23 PM   #9
mlager8
Lord of the posts
 
mlager8's Avatar
portfolio
Matthew Lager
3D artist
Oceanside, USA
 
Join Date: Nov 2008
Posts: 875
Not to be completely off topic here, but Dave, is your icon the chick from die antwoord..?
__________________

 
Old 07-11-2012, 08:33 AM   #10
suyati
hüüüüüür
 
suyati's Avatar
yukio
td
Switzerland
 
Join Date: Feb 2004
Posts: 21
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-11-2012, 08:33 AM   #11
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 06:23 PM.


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