Chaos Corona Forum
Chaos Corona for 3ds Max => [Max] I need help! => Topic started by: cjwidd on 2020-02-13, 02:23:12
-
Is there already a way to store all rendered masks into the alpha channel of 32-bit .EXR (or 16-bit .TIFF) automatically in Corona / 3ds Max?
It sounds like this user is requesting something similar (https://forum.corona-renderer.com/index.php?topic=26966.0) for Corona in C4D(?)
EDIT: if not, does anyone have a tasty PS script they could share(?)
-
I am using wirecolor mask, and randomize wire color script for objects
-
Link to resources?
-
Link to resources?
http://www.scriptspot.com/3ds-max/scripts/random-wire-color-tools I use this one, pretty hefty little script.
-
Isn't every RGB mask saved with its own alpha channel? For example if you save to EXR and open it in PS with the EX-io plugin?
-
@GeorgeK I read over the scripts description, but it sounds like what this script is doing is essentially *generating* masks based on wire color. However, my question is about how to compile all masks that are included as render elements (in Corona) in the alpha channel of the beauty pass of an .EXR.
@Maru Yes I think this is true, for example if you have three objects, you can assign each one to the R,G, and B channels of a mask, but I think you are limited to only those three channels - only three objects or sets of objects.
It's definitely not as sophisticated, but my current workflow is to just generate one mask per object (or object set) that requires one and then save everything into an .EXR, e.g. beauty, translucency, shadows, alphas, etc. The issue is that I have to copy / paste all the masks into the alpha channel individually.
-
The issue is that I have to copy / paste all the masks into the alpha channel individually.
The question is: why would you like to have them there? Is it about the convenient Ctrl-Click to get a selection? Or to keep the document tidy? I have recorded myself a simple ps action for that purpose, all I need to do is to select a (b&w) mask layer and press a hotkey.
To record: have a layer visible and selected, start recording, Alt-Click on the layer visibility icon (so that it's the only layer which is visible now), change to channels, Ctrl-click on the RGB channel, go back to layers, Alt-Click on the visibility icon again, stop recording. Then assign the action to any hotkey.
Now you can just select a layer, press the hotkey and you have a selection to use as mask. No more Ctrl-A, Ctrl-C, Q, Ctrl-V, Q which would be another option to be recorded - for some reason I've chosen the above one, don't know why anymore.
Good Luck
-
@Frood Yes, it is 100% about the convenience of performing different selections on the masks, e.g. Ctrl+click, Ctrl+shift+click, Ctrl+shift+alt+click.
-
Yes, reason enough. Especially when it comes to shift/alt clicks. Personally I would have a look at these
https://www.adobe.com/content/dam/acom/en/devnet/photoshop/pdfs/photoshop-cc-scripting-guide-2019.pdf
https://www.adobe.com/content/dam/acom/en/devnet/photoshop/pdfs/photoshop-cc-javascript-ref-2019.pdf
and would try to write a script which converts the currently selected layers to channels of the same name. I think this is what you were asking for in your 'Edit' in the OP. Would be useful for sure...
Good Luck
-
Yeah I'm working on a .js script that will basically take all the open documents after the focused document, copy the document (i.e. mask), close the document, paste into alpha channel, write the pasted document name to the alpha channel label, then iterate through that loop for all open documents.
-
So you are working with multiple files usually? We use layered exr/cxr almost exclusively. I could not resist to try myself now (because yes, it's something to streamline) and I made "Layers to Channels" which you can find as a menu item in "File" -> "Automate" after throwing it into the scripts folder. It detects if RGB channels are equal or not for a layer and splits it into different channels if necessary. No masterpiece (never js-scripted PS before), but despite the fact that the api hmm. "surprised" me a bit with it's "simplicity" it works ok for me :)
Good Luck
Edit: corrected typo in archive
-
Hey Frood, this looks like exactly what I was trying to do. I will check this out and report back in a bit.
-
@Frood
Your script is fantastic and it so happens that it is exactly what I was trying to achieve. Thank you so much for sharing, I really, really appreciate it :)
In your case, you are loading packed RGB masks - not mono masks - into the layered .EXR and then running the script on a single layer, i.e. the script does not loop through all layers, only the selected layer?
@GeorgeK
The Random Wire Color Tools script is really great for its intended use case, i.e. assigning wire colors to objects in the scene. How are you using it in conjunction with masking in your workflow? For example, are you using packed RGB masks or mono masks? In the case of the former, obviously you can use CMasking_WireColor, but this produces a single RGB mask that would have to be color selected in PS, which may require additional clean-up to generate a clean mask.
There is another script on the forums (https://forum.corona-renderer.com/index.php?topic=8195.0) (2015) that will generate mono masks based on ALL scene materials, which when used in conjunction with @Frood's script, basically implements the workflow I had imagined. However, unless you keep a VERY tidy scene you are going to generate a bunch of masks you don't need (i.e. materials that are on hidden objects, HDRIs, rayswitch, etc.).
I'm looking through the script (.ms) now to see if there is a way to condition the mask generation loop on only selected objects or based on wire color instead of material.
-
In your case, you are loading packed RGB masks - not mono masks - into the layered .EXR and then running the script on a single layer, i.e. the script does not loop through all layers, only the selected layer?
Those RGB masks or "packed" ones as you call them are just CMasking_Mask render elements from Corona with RGB mode activated - they are already in the EXR ("Automatically Add/Remove Render Elements from Render Dialog" ticked in the OpenEXR Configuration). I do not manually load anything into the document in the first place. The layers you can see in the screenshot are those written by Corona, it's just a random output of a Backburner job I opened in Photoshop.
But as stated, if it's a "mono" layer (R=G=B), "Layers to Channels" creates a single channel (in the example image, the standard beauty alpha is nothing else but a mono mask). And yes, it processes only selected layers, I don't want my beauty or lightmix layers to disappear :)
Good Luck
-
Yeah I just recorded an action to run the script on the selected layer and it works beautifully - thanks again for sharing it (!)
-
Welcome. But I want to understand: why you recorded some action? What for? It should work like this: select some layers, use "Layers to Channels" and that's it(?).
Good Luck
-
This was my reason for asking - I misunderstood the instructions for using the script, having not looked at the code.
My mistake.
Yes, the script will process all selected layers; it is not necessary to run the script on each layer individually.
-
Ah, ok. Well, a short description what it does can be found in Photoshop Help-> About Plugins -> Layer to Channels or in the Script Events Manager when selecting it:
"Creates channels from selected layers (e.g. render masks) and removes them. Creates separate channels for R/G/B if they are not equal."
Oops, just corrected a typo and replaced the zip. So have fun and
Good Luck
-
@Frood
Your script is fantastic and it so happens that it is exactly what I was trying to achieve. Thank you so much for sharing, I really, really appreciate it :)
In your case, you are loading packed RGB masks - not mono masks - into the layered .EXR and then running the script on a single layer, i.e. the script does not loop through all layers, only the selected layer?
@GeorgeK
The Random Wire Color Tools script is really great for its intended use case, i.e. assigning wire colors to objects in the scene. How are you using it in conjunction with masking in your workflow? For example, are you using packed RGB masks or mono masks? In the case of the former, obviously you can use CMasking_WireColor, but this produces a single RGB mask that would have to be color selected in PS, which may require additional clean-up to generate a clean mask.
There is another script on the forums (https://forum.corona-renderer.com/index.php?topic=8195.0) (2015) that will generate mono masks based on ALL scene materials, which when used in conjunction with @Frood's script, basically implements the workflow I had imagined. However, unless you keep a VERY tidy scene you are going to generate a bunch of masks you don't need (i.e. materials that are on hidden objects, HDRIs, rayswitch, etc.).
I'm looking through the script (.ms) now to see if there is a way to condition the mask generation loop on only selected objects or based on wire color instead of material.
Just mono! Haven't used multi channel alpha since my game-dev times, were we would put normal alpha and emission on those channels for .dds, but we had coders to hardcode the loading in the game engine.
I will try what frood provided looks amazing, and it's a pretty nice workflow for cases with many element outputs.