CGTalk > Software Specific Forums > Autodesk Maya > Maya Rendering
Login register
Thread Closed share thread « Previous Thread | Next Thread »
 
Thread Tools Search this Thread Display Modes
Old 10-12-2012, 12:23 PM   #1
anthonymcgrath
Lord of the posts
 
anthonymcgrath's Avatar
portfolio
anthony mcgrath
United Kingdom
 
Join Date: Jun 2002
Posts: 1,695
openEXR - any way to create a matte channel of selected items?

hi guys
I'm working with openEXR file formats. Overall i'm getting some good layers coming out that i can quickly composite together. However i wondered - is it possible to setup a render pass for openEXR that mattes out various bits..

ie in the image below i wanted to separate the hands and arm meshes from the remaining elements around him (car interior). Ideally i'd like the arms to be red, the meshes he's putting his hands in to be blue and the surrounding elements of car interior green. This way i can key them off and use each colour channel separately for a matte?

I guess it wouldn't be too tough to render out a hardware render of the image by just setting up a renderlayer and assigning 3 different surface shaders but just wondered if its possible to set it up as a renderpass at all and include that for openEXR format?

any openEXR guru's around here ?

 
Old 10-12-2012, 01:42 PM   #2
kiryha
Expert
 
kiryha's Avatar
portfolio
Kiryha Krysko
3D artist
Ukraine
 
Join Date: Nov 2002
Posts: 674
Send a message via ICQ to kiryha
I would say its not about EXR, but about render. Which render do you use?
__________________
3D animation blog
 
Old 10-12-2012, 03:17 PM   #3
anthonymcgrath
Lord of the posts
 
anthonymcgrath's Avatar
portfolio
anthony mcgrath
United Kingdom
 
Join Date: Jun 2002
Posts: 1,695
mental ray why?
 
Old 10-12-2012, 04:42 PM   #4
nookie
Know-it-All
 
nookie's Avatar
portfolio
Luca Fiorentini
Lighting Artist
Lucasfilm Animation
Singapore, Singapore
 
Join Date: Jan 2004
Posts: 367
Send a message via MSN to nookie
You can create a new pass in the render global pass (custom color pass) and then use the writeToColorBuffer utility node to write a color to the buffer.
I have attached a simple scene for you to check but the workflow would be

#1 create the new pass (let's call it myRGBpass)
#2 assign the pass to the scene
#3 create a writeToColorBuffer and set it to write to myRGBpass (add)
#4 set the writeToColorBuffer color to RED
#5 connect your arm shader to the evaluationPassThrough on the writeToColorBuffer

repeat #3, #4, #5 for GREEN and BLUE

I don't know if you have to do this for every shader or if you can "group" them and use a single writeToColorBuffer for more than one shader, maybe someone could help you with that
Attached Files
File Type: zip RGB_matte.zip (31.0 KB, 15 views)
 
Old 10-15-2012, 02:06 PM   #5
anthonymcgrath
Lord of the posts
 
anthonymcgrath's Avatar
portfolio
anthony mcgrath
United Kingdom
 
Join Date: Jun 2002
Posts: 1,695
@nookie - absolute legend thankyou good sir - works a treat and openEXR see's it as just another layer - brilliant
 
Old 10-24-2012, 07:00 PM   #6
EdtheHobbit
File read in 0 seconds
portfolio
Ed Whetstone
Lighting Artist
Richardson, USA
 
Join Date: Oct 2007
Posts: 664
Send a message via AIM to EdtheHobbit
Here is a mel script that I wrote that does this very thing. It adds a matte-channel of whatever you currently have selected (a single alpha, not RGB) which will render along with your current render layer.


roughly speaking, this is what it does:

  1. create a pass contribution map of the selected object
  2. create a render pass of type "matte"
  3. assign the pass contribution map to the render pass
Using the PCM method, you maintain transparency on objects, as well.

Code:
global proc createMatte(){ string $promptResult = `promptDialog -title "matte name" -message "name of matte"`; string $matteName = `promptDialog -query -text`; string $curLayer = `editRenderLayerGlobals -q -currentRenderLayer`; string $pcmNode_def = `createNode -skipSelect passContributionMap`; string $pcmNewName = $matteName + "_pcm"; string $rpName = $matteName + "_mat"; string $pcmNode = `rename $pcmNode_def $pcmNewName`; renderLayerEditorAssocContMap("RenderLayerTab", {$curLayer}, $pcmNode); string $listSel[] = `ls -sl -fl`; for($thisGeo in $listSel) { alterNodeContMapConnection($thisGeo, $pcmNode, "dagObjects", 1); } string $rpNode = `createNode -name $rpName renderPass`; setRenderPassType -type "MATTE" -numChannels 1 $rpNode; setAttr ($rpNode + ".frameBufferType") 256; setAttr ($rpNode + ".numChannels") 1; string $owners[] = `listConnections -d off -s on -plugs 1 ($rpNode + ".owner")`; if(!stringArrayContains(($curLayer + ".renderPass"), $owners)) connectAttr -nextAvailable ($curLayer + ".renderPass") ($rpNode + ".owner"); $owners = `listConnections -d off -s on -plugs 1 ($pcmNode + ".renderPass")`; if(!stringArrayContains(($rpNode + ".message"), $owners)){ connectAttr -nextAvailable ($rpNode + ".message") ($pcmNode + ".renderPass"); } };


This is the fastest, easiest, and most efficient way to make multiple mattes from selections in Maya.

Last edited by EdtheHobbit : 10-24-2012 at 07:01 PM. Reason: legibility
 
Old 10-24-2012, 07:04 PM   #7
EdtheHobbit
File read in 0 seconds
portfolio
Ed Whetstone
Lighting Artist
Richardson, USA
 
Join Date: Oct 2007
Posts: 664
Send a message via AIM to EdtheHobbit
Let me know how this works for you, I wrote it for myself and haven't tested much "in the wild"
 
Old 10-25-2012, 02:19 PM   #8
anthonymcgrath
Lord of the posts
 
anthonymcgrath's Avatar
portfolio
anthony mcgrath
United Kingdom
 
Join Date: Jun 2002
Posts: 1,695
hi Ed I will try it out over the weekend - I quickly copy/pasted it at work and did a quick test scene and it seemed to work a treat tho hopefully it'll work with my more complex scene at home - i'll post pics to show you what i get

thanks!
ant
 
Old 10-25-2012, 03:00 PM   #9
ristopuukko
Earthling
 
ristopuukko's Avatar
portfolio
Risto Puukko
Senior fx td
FrameStore
London, United%2BKingdom
 
Join Date: Nov 2003
Posts: 809
my two cents....

One show I was attending used assets which were not bound shaders per geometry so I was afraid, that I need to go through the hell of mixing layers with new shaders which then would trigger the evaluation of the custom color passes and yadda yadda...until I realized that one can bind ( or layer with add/whatever nodes and then bind ) geometry directly to the custom write node.

Try connecting your shape node's message - attribute to the writeToXXXXXbuffer and see for yourself.

It seems that one can create all kinds of bizarre node networks which float ie. are not bound to any geometry, and then just decide from where, geo or shading node, you trigger your custom pass evaluation.

/risto
__________________
- Oh no, it's me -
 
Old 11-07-2012, 12:17 AM   #10
InfernalDarkness
Madness. Madness, I say!
 
InfernalDarkness's Avatar
portfolio
Sho Pi
CG arch/viz
Seattle, USA
 
Join Date: May 2008
Posts: 5,572
Hello EdTheHobbit,
I tried your script today to make a matte pass of some particular flowers which are buggin' me, to isolate them in Photoshop. It didn't seem to do anything, nor did it cough up an error. I'm not sure what I'm doing wrong?

I selected the objects, then ran the script. No contribution maps or render passes were created, however. I'm using Maya 2012 still though, is this a Maya 2013 thing, perhaps?
__________________
Commodore 64 @ 1MHz
64KB RAM
1541 Floppy Drive


"Like stone we battle the wind... Beat down and strangle the rains..."
 
Old 11-07-2012, 12:45 AM   #11
faultymoose
Know-it-All
 
faultymoose's Avatar
portfolio
Boon Cotter
Lighting & Rendering
Sydney, Australia
 
Join Date: May 2004
Posts: 491
I wrote a utility to create matte passes from selected objects. It creates each matte as a single channel within the EXR. Probably a bit late to the party, but it might help in the future.

http://www.booncotter.com/maya-ment...e-pass-creator/

__________________


Last edited by faultymoose : 11-07-2012 at 12:57 AM.
 
Old 11-07-2012, 12:56 AM   #12
EdtheHobbit
File read in 0 seconds
portfolio
Ed Whetstone
Lighting Artist
Richardson, USA
 
Join Date: Oct 2007
Posts: 664
Send a message via AIM to EdtheHobbit
Hey Infernal -- it shouuuuuld work... did you run the createMatte procedure after copy/pasting/running the script?
 
Old 11-07-2012, 01:36 AM   #13
InfernalDarkness
Madness. Madness, I say!
 
InfernalDarkness's Avatar
portfolio
Sho Pi
CG arch/viz
Seattle, USA
 
Join Date: May 2008
Posts: 5,572
No, I just ran the script on my selected objects. I'm new to pass contribution maps. What I'm trying to do is have my main render, my z-depth pass, and a mask pass for one set of flowers render out. I'm using .tif files (.exrs don't work great in Photoshop, last I tried), and the z-depth pass works fine. I'll admit I don't know what I'm doing.

After trying your script, I manually set the flowers to a matte pass contribution map, and so I have two associated passes : depth and matte. I also associated the PCM (with only the flowers) with the matte pass, but upon rendering, the PCM didn't actually affect anything. Everything rendered in both the z-depth and the matte pass.

Am I doing this all wrong? How would I add or remove objects from the PCM? I can't find anywhere that will list this connection... Didn't find anything in Hypergraph either. I feel stupid.


@Faultymoose: looks pretty cool! Would it only work with .exr files, though? I need to learn what I'm doing manually first, methinks, before trying something more automated.
__________________
Commodore 64 @ 1MHz
64KB RAM
1541 Floppy Drive


"Like stone we battle the wind... Beat down and strangle the rains..."
 
Old 11-07-2012, 01:46 AM   #14
faultymoose
Know-it-All
 
faultymoose's Avatar
portfolio
Boon Cotter
Lighting & Rendering
Sydney, Australia
 
Join Date: May 2004
Posts: 491
Yes I believe my script will only work with OpenEXR, unless there is another native format which supports arbitrary channels? I'm not sure, I'm afraid.

What my script is doing is more or less the same as what you're doing now: You select some objects, click a button, and it adds those objects to a pass contribution map (either an existing map, a new one, or multiple new maps depending on the options you've selected) and creates a matte pass for the render layer.

You can do it manually, but it's fiddly, for the reasons you've mentioned. Finding the objects associated to a PCM is not all that intuitive (I think you can right-click > select members and right-click > Add / Remove just like you can with render layers).

But you're right, learning to do it manually is important!
__________________

 
Old 11-07-2012, 02:59 AM   #15
EdtheHobbit
File read in 0 seconds
portfolio
Ed Whetstone
Lighting Artist
Richardson, USA
 
Join Date: Oct 2007
Posts: 664
Send a message via AIM to EdtheHobbit
Infernal -- run the script, then type

"createMatte;"

in the MEL bar. The script above only builds the procedure, you still need to run it.
 
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 04:28 PM.


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