10 October 2011 | |
![]() |
|
Frequenter
portfolio
Matthias Mittelmeyer
3D Generalist / Lighting TD
Sydney - atm,
Germany
|
Script to connect all mia_materials in a Scene with Colorbuffers
Hello everyone,
yesterday i looked for scripts wich can create 21 Custom Color Buffers, name them (add_result, refl_level, refr_level...) and connect them to WriteToColor Nodes. Because i didn't find any i tried it on my own. I'm not a coder and don't have any experiences with mel, but i could realize this first step by recording/and copying the commands. The next and maybe more difficult step would be, to connect all Materials in the scene (type Mia_material_x_passes) or at least named like this "Mia_material" with the right colorbuffers. So that i can use a lot of Mia_Material_x_passes in my scene, after that scan the entire scene for them and connect for example "indirect_raw" to the colorbuffer "Indirect_raw_buffer" for all of them. The recorded command is: connectAttr -f mia_material_x_passes3.indirect_raw indirect_raw_buffer.color; connectAttr -f mia_material_x_passes3.indirect_raw indirect_raw_buffer.evaluationPassThrough; But of course it only works for the material named "mia_material_x_passes3". And that is what i'm trying to achieve. select -r "mia_material*"; string $miaNode[] = `ls -selection`; connectAttr -f $miaNode.indirect_raw indirect_raw_buffer.color; connectAttr -f $miaNode_x_passes3.indirect_raw indirect_raw_buffer.evaluationPassThrough; Of course it's not that easy :-/ Today i found a great (closed) thread with the same topic but with an different approach. http://forums.cgsociety.org/showthr...31&page=1&pp=15 I think my problem could be, that i only have this one variable ($miaNode) right now?? I would be really happy, if you can show me how to solve this problem. Thank you! Best wishes Matthias __________________
3D Artist - Generalist and Lighting TD au.linkedin.com/in/matthiasmittelmeyer www.Matthias-Mittelmeyer.de https://vimeo.com/81268127 |
10 October 2011 | |
![]() |
|
Altruist
portfolio
Robert Schroeder
Animator / FX-Artist
Berlin,
DE
|
try this :
hope this helps... cheers! ![]() rob |
10 October 2011 | |
![]() |
|
Frequenter
portfolio
Matthias Mittelmeyer
3D Generalist / Lighting TD
Sydney - atm,
Germany
|
Hey! Thank you, immediate neighbor :-D
I will try it right now! ![]() Greetings, Matthias Edit: Super! Das sieht jetzt wirklich schon sehr vielversprechend aus! Auf der nächsten Mediaworks party geb ich dir dann ein Bier aus! ;-) __________________
3D Artist - Generalist and Lighting TD au.linkedin.com/in/matthiasmittelmeyer www.Matthias-Mittelmeyer.de https://vimeo.com/81268127 Last edited by B3liar : 10 October 2011 at 12:26 PM. |
10 October 2011 | |
![]() |
|
Frequenter
portfolio
Matthias Mittelmeyer
3D Generalist / Lighting TD
Sydney - atm,
Germany
|
So, generally it works great! There's only one problem left. After the first Mia_material _x_passes was connected to the colorbuffers, the others won't connect. No errors or anything. It seems like he stops doing it after the first mia $node has been connected.
Is there something like for each? Or $nodes? I think it would be nice to have a thick book about mel! :-D __________________
3D Artist - Generalist and Lighting TD au.linkedin.com/in/matthiasmittelmeyer www.Matthias-Mittelmeyer.de https://vimeo.com/81268127 |
10 October 2011 | |
![]() |
|
Altruist
portfolio
Robert Schroeder
Animator / FX-Artist
Berlin,
DE
|
i'm not completely sure what you're trying to do ... but could it be that every material needs it's own raw buffer nodes? ... if that's the case you could do something like this:
that would create & connect a writeToColorNode for every x_passes shader ... if you need more help maybe UL the scene or an example scene ... guess i could help you with the code, but i'm not to much into the shading stuff. - sry .. beer sound good, though ![]() cheers! |
10 October 2011 | |
![]() |
|
Frequenter
portfolio
Matthias Mittelmeyer
3D Generalist / Lighting TD
Sydney - atm,
Germany
|
Just some minutes ago i had the same thoughts.. could it be, that it needs a color buffer for every material.. and yes, so it is. :-D
That's really a mess! Thank you for the new code! I will try it tomorrow! ![]() In 3dsmax it's possible to select all these renderpasses (diffuse_level, refl_raw, relf_result..)directly in the passes window and thats it. All Mia_Materials become splittet into these pre-defined color buffers and you can comp them together with a maximum of flexibility. In Maya it's not that easy. You can only generate Custom Color buffers (name them diffuse_level for example) and WriteToColor Nodes. Now it's possible to connect the Mia Materials_x_passes with this Write to Color buffers and write the informations from the shader directly in the Custom color buffers. So you need 21 Custom Color Buffers to write the Informations (reflection_raw, refraction_raw, indirect_raw etc.) from the Material_x_passes shader in the colorbuffer. I think and hope the code works for this ![]() It's easy to imagine what kind of mess you get with 20 mia_material_x_pass Materials * 21 Colorbuffers. But with a script, it would be easier than doing this stuff by hand. I have to go know. I hope i have success with your script! ![]() Greetings, Matthias __________________
3D Artist - Generalist and Lighting TD au.linkedin.com/in/matthiasmittelmeyer www.Matthias-Mittelmeyer.de https://vimeo.com/81268127 Last edited by B3liar : 10 October 2011 at 09:11 PM. |
10 October 2011 | |
![]() |
|
Frequenter
portfolio
Matthias Mittelmeyer
3D Generalist / Lighting TD
Sydney - atm,
Germany
|
I tried your code and it seems to work but i think there is one problem left.
$buffer = `rename $buffer ("indirect_raw_buffer_" + $node)`; After renaming the buffer for example refl_level_buffer_2 he needs also to know in wich pass to write. I think it's something like this?? connectAttr "indirect_raw.message" "indirect_raw_buffer_.renderPass"; Of course it's not that easy and it doesn't work this way.. :( I don't have a example scene. I only use 2 Spheres, 2 Mia Shader add those 21 Renderpasses and 21 WriteToColorbuffer with a script, take your third script to connect the Mia to buffers, render and try out if he split the shader informations correctly. I took some screenshots to show you what i want to do and wich "scripts" i have for the first two steps (Renderpass generation, renaming) and Wirte To Colorbuffer renaming and connecting to the Framebuffer. http://www.b3liar-3d.de/B3L_Anderes...criptablauf.jpg I hope its kind of "easy" to do. :-) Greetings, Matthias __________________
3D Artist - Generalist and Lighting TD au.linkedin.com/in/matthiasmittelmeyer www.Matthias-Mittelmeyer.de https://vimeo.com/81268127 |
10 October 2011 | |
![]() |
|
Altruist
portfolio
Robert Schroeder
Animator / FX-Artist
Berlin,
DE
|
ok, i looked a bit more into this render pass stuff in general to understand what you're trying to do. and from this plus your posted Scriptablauf.jpg i think i figured out what you're after and how it can be solved
![]() to split your materials into separate passes, every shader will need just as many buffer nodes as you have passes (e.g. a scene with 3 shaders & 4 passes will need 12 buffer nodes). at first you need to create a custom color scene pass and associate it with a render layer. to feed stuff into this scene pass you will have to split up your shaders into buffer nodes and the buffer nodes need an input connection from the scene pass. here's a little procedure that does all that for you:
it creates all render passes defined in the $passes array (so you can add more, read comments in script for details) and splits up all mia_material_x_passes shader into these passes. hope that's what you're looking for ![]() |
10 October 2011 | |
![]() |
|
Frequenter
portfolio
Matthias Mittelmeyer
3D Generalist / Lighting TD
Sydney - atm,
Germany
|
Wow, thats awesome! Really great work! Thank you very much!
I think this script could be interesting for a lot of maya 2011/2012 users! It's impressive how a few lines of code can save several hours per scene or just make it possible to do those stuff! I think i should start with learning the basics of MEL or Python! :-) I hope someday i can return the favor! Best wishes, Matthias __________________
3D Artist - Generalist and Lighting TD au.linkedin.com/in/matthiasmittelmeyer www.Matthias-Mittelmeyer.de https://vimeo.com/81268127 |
10 October 2011 | |
![]() |
|
Altruist
portfolio
Robert Schroeder
Animator / FX-Artist
Berlin,
DE
|
you're welcome - glad i could help!
![]() ... and yes, knowing how to script stuff can speed up your workflow exponentially. i for one want to look more into python since it seems more flexible & efficient plus it gives you access to the maya api. but still, knowing some MEL can't hurt if you're working with maya ![]() __________________
myBlog Last edited by procanic : 01 January 2012 at 10:50 AM. |
10 October 2011 | |
![]() |
|
Expert
|
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 |
«
Previous Thread
|
Next Thread
»
|
|
|