Author Topic: Corona Randomizer  (Read 11004 times)

2023-11-16, 10:17:30

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
By user request I am releasing this script for free. Script attached to this post or download here.

Notes:
- Select the objects you want to add the CoronaMappingRandomizer.
- Press the icon in the toolbar to run the script.

Install:
- Drag the script into your 3dsmax viewport.
- Customize > Customize User Interface > Toolbars > Category: Vella > Automate CoronaRandomizer
- Drag this toolbar button somewhere in your UI/Toolbars

Version 1.0 Features:
- Attaches all nodes in the material of the selected object to a CoronaMappingRandomizer.
- Currently adds a new CoronaMappingRandomizer, if you already have one for that material it will add another (might look into this later, code is available if you wish to try yourself).
- Supports Corona Physical and Corona Legacy materials.

randomizer" border="0


« Last Edit: 2023-11-16, 10:34:16 by James Vella »

2023-11-17, 07:33:33
Reply #1

Tom

  • Active Users
  • **
  • Posts: 236
    • View Profile
    • www
That's awesome, thanks man.
What would be even better is the ability to add a CoronaTriplanar map right after the CoronaMappingRandomizer node.
Most of the time I'm using this setup so that I don't have to put mapping coordinates on the objects, instead I just have to play with the Scale setting of the Triplanar map.

2023-11-17, 07:47:52
Reply #2

Tom

  • Active Users
  • **
  • Posts: 236
    • View Profile
    • www
Your script doesn't seem to work for me: I select the objects, then Script > Run script > I choose your .ms, and nothing happens. The material of the objects remains the same.
I use 3ds Max 2023.3.4 and Corona 10 HF2.

And about the Triplanar setup: I see in your example you put the Triplanar map before the MappingRandomizer map. It's recommended to do the other way around, first the MappingRandomizer and after the Triplanar map:

https://docs.chaos.com/display/CRMAX/Corona+Mapping+Randomizer#expand-Clickheretoseethematerialsetup

2023-11-17, 10:09:47
Reply #3

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8854
  • Let's move this topic, shall we?
    • View Profile
    • My Models
Your script doesn't seem to work for me: I select the objects, then Script > Run script > I choose your .ms, and nothing happens. The material of the objects remains the same.
I use 3ds Max 2023.3.4 and Corona 10 HF2.

I didn't test the script yet, but i think when you run it for the first time, it installs macroscript and then you need to go to customize UI, locate installed macroscript and move it to your place of choice in UI, like shortcut, toolbar, quad-menu, etc.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2023-11-17, 10:13:32
Reply #4

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Your script doesn't seem to work for me: I select the objects, then Script > Run script > I choose your .ms, and nothing happens.
The .ms script file is the installer, you can follow the instructions above once you have installed it to create the toolbar icon.

Currently the functionality is only for Randomizer, however not too hard to add a button for the Triplanar. Maybe ill add a small UI to it so you have the option of both or either if thats more useful.
« Last Edit: 2023-11-17, 10:22:35 by James Vella »

2023-11-17, 10:28:07
Reply #5

Tom

  • Active Users
  • **
  • Posts: 236
    • View Profile
    • www
Ok, thanks for the explanation guys.
I wanted to run it instead of following the instructions and create a new toolbar as I found sometimes it's impossible to remove the toolbar for some reason. It depends on the script you install but I remember some of them I've created a toolbar for refused to go away once I decided I didn't need them anymore and deleted their toolbar. Eventhough I do Customize User Interface > Toolbars, select the given toolbar and hit 'Delete', next time I run 3ds Max, it's here again.

So I will wait and see if James realeases a version with the ability to choose between MappingRandomizer only or combo MappingRandomizer + Triplanar and I'll install that one, that'd be awesome :)

2023-11-17, 10:34:36
Reply #6

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
I wanted to run it instead of following the instructions and create a new toolbar

If you want to run it without installing remove the macroscript block (this applies for any .ms file):
ms" border="0

So I will wait and see if James realeases a version with the ability to choose between MappingRandomizer only or combo MappingRandomizer + Triplanar and I'll install that one, that'd be awesome :)

Can you show me a screenshot of your materials where you have this setup? For example does every output of the randomizer have its own triplanar or do all outputs go into the triplanar?

I assume you want something like this?
triplanar" border="0
« Last Edit: 2023-11-17, 10:38:32 by James Vella »

2023-11-17, 11:37:10
Reply #7

Tom

  • Active Users
  • **
  • Posts: 236
    • View Profile
    • www
Thanks James.

Yes, you're totally right: this is the setup I'm using.

2023-11-17, 14:06:58
Reply #8

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Ok updated to include both Mapping Randomizer and Triplanar. Let me know if you encounter bugs/issues.

Script attached to this post.

Version 2.0 Features:
- UI With 3 buttons, Either Mapping, Triplanar or Both.
- Include basic instructions and help contact link (just use the forums if you found the script here to contact me otherwise).
- When using "Randomizer + Triplanar" the Triplanar will be last in the chain: Diffuse -> MappingRandomizer -> Triplanar etc.
- If you already have version 1 installed, just drop this .ms file into your viewport and your current button will update automatically to Version 2.0

Notes:
- Save your scene before you run the script!
- Multiple undo's tend to crash 3dsmax, will investigate if its my error or Autodesk thing.

UI:
UI" border="0

Randomizer + Triplanar:
Both" border="0

Randomizer:
Rand" border="0

Triplanar:
Triplanar" border="0
« Last Edit: 2023-11-17, 18:00:21 by James Vella »

2023-11-17, 15:22:29
Reply #9

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8854
  • Let's move this topic, shall we?
    • View Profile
    • My Models
Wow, this looks awesome! Can't wait till i have some time to test it in action. Thank you James very much! I don't want to diminish Corona team's effort, but this little script looks more valuable to me than entire Corona power tools script set.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2023-11-17, 16:07:13
Reply #10

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Thank you James very much!

You're welcome.

this little script looks more valuable to me than entire Corona power tools script set.

Maybe ill turn this into a corona toolbox at some point =D

I don't want to diminish Corona team's effort

Yeah they have enough on their plate, its easier to make scripts that integrate with current functionality than integrate scripts back into the core of the software. So while I'm sure they could do this far better and quicker than I can there is lots of hoops to jump through to make it bullet proof and ensure the user experience is in sync with the software as a whole.

Edit:
By the way, in case you were not aware, because the buttons are separate you can actually do this in any order you prefer, which means if you press the triplanar button first, then the randomizer you can swap what the first button does (which is Randomizer -> Triplanar). Effectively meaning Triplanar -> Randomizer. I dont use them so if thats useful for a particular situation you have the option.
« Last Edit: 2023-11-17, 18:00:06 by James Vella »

2023-11-18, 11:13:04
Reply #11

Tom

  • Active Users
  • **
  • Posts: 236
    • View Profile
    • www
Ok updated to include both Mapping Randomizer and Triplanar. Let me know if you encounter bugs/issues.

Script attached to this post.


Thanks James, very much appreciated, it's working perfectly, such a huge time saver 🙏🏻
I had 3ds Max crashing while I was using it though, I remember I was using Corona IR at the same time, not sure if your script is to be blamed or not, 3ds Max is not the most stable software anyhow.

I did some test renders, on a very basic scene of few boxes with a simple wood material on them, just to check if there was any difference when rendering:

1) no Randomizer nor Triplanar map
2) Randomizer map only
3) Triplanar map only
4) Randomizer + Triplanar

Here are the results, respectively:

1) 1mn20s
2) 2mn02s
3) 1mn51s
4) 2mn07s

Meaning an increase of 59% in render time from 1) to 4) which is very strange as the material doesn't really change: only the mapping changes in the end. So there shouldn't be such a difference. Unless Corona is having hard times calculating the resulting shader before actually rendering it?

Interesting to note that:

_ cpu usage is 100% for all 4 renders (we finally got rid of the annoying slow rendering time when using Triplanar map, good)
_ when I move the boxes far away from the camera, the render time drops to 25s, which makes sense.

Happy to hear what Corona dev team think about that.

Thanks again for the script James!

2023-11-18, 14:50:38
Reply #12

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
No worries, glad you enjoy it.

Yeah I'm getting more crashes since I updated to 2024.2 so not sure if that's apart of the issue, but nothing in this script does any extra calculations, it just takes input and output and rewires it. The only issue im facing atm is crashing on multiple-undos, which I need to investigate further.

Regarding crashing on IR, could be corona related because its unplugging and replugging things in and out very quickly and not sure if the RT engine is able to keep in sync with the changes or something. Kind of relates to what I said earlier about things being bullet proof before they are integrated into the host software, even simple scripts, when integrated, can negatively impact the overall scaffolding of the software as a whole.

I would say if there is any render time slowdowns its probably due to how the triplanar/randomizer works in corona itself, so I dont know lol.
« Last Edit: 2023-11-18, 15:24:31 by James Vella »

2023-11-18, 16:14:24
Reply #13

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8854
  • Let's move this topic, shall we?
    • View Profile
    • My Models
Meaning an increase of 59% in render time from 1) to 4) which is very strange as the material doesn't really change: only the mapping changes in the end. So there shouldn't be such a difference. Unless Corona is having hard times calculating the resulting shader before actually rendering it?

Slowdown is expected, for every ray that hits surface with triplanar and randomizer, Corona needs to perform additional calculations which does not come free. In case of randomizer, make sure to uncheck HQ blending, unless you really need it - this feature makes blending look much better, but has significant performance cost.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2023-11-18, 17:21:58
Reply #14

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
In case of randomizer, make sure to uncheck HQ blending, unless you really need it.

Do you want this as a button? =D

2023-11-18, 18:47:02
Reply #15

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8854
  • Let's move this topic, shall we?
    • View Profile
    • My Models
No, not really, 3ds Max 2024 allows to save user defaults for most controls, so that's not an issue anymore. I think it will be better if you keep the script simple.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2023-11-18, 19:43:24
Reply #16

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
That works for me :)

2023-11-19, 10:02:16
Reply #17

Tom

  • Active Users
  • **
  • Posts: 236
    • View Profile
    • www
In case of randomizer, make sure to uncheck HQ blending, unless you really need it - this feature makes blending look much better, but has significant performance cost.

Thanks for the tip.

2023-11-20, 03:09:25
Reply #18

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
Ok updated to include both Mapping Randomizer and Triplanar. Let me know if you encounter bugs/issues.


This is absolutely amazing and will save me a ton of time.
Thank you very much for your time and for making the script freely available.

Will it be okay if I make a post about it in my Telegram channel indicating your authorship and attach the script itself so that more people can use it?

PS the only thing I would love to have  a checkbox, when clicked it would create a  map with parameters:
U | X   -1   1
V | Y   -1   1
W | Z   0   360
randomize each tile - on

and if the checkbox was not pressed, a regular map with default parameters would be created, as it is now.
« Last Edit: 2023-11-20, 03:29:11 by marchik »

2023-11-20, 09:37:50
Reply #19

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
This is absolutely amazing and will save me a ton of time.
Thank you very much for your time and for making the script freely available.

Will it be okay if I make a post about it in my Telegram channel indicating your authorship and attach the script itself so that more people can use it?

Youre welcome. Yes sure you can post it anywhere you like.

PS the only thing I would love to have  a checkbox, when clicked it would create a  map with parameters:
U | X   -1   1
V | Y   -1   1
W | Z   0   360
randomize each tile - on

and if the checkbox was not pressed, a regular map with default parameters would be created, as it is now.

I was thinking maybe I should create the checkboxes and a button for a preset save/load. This way you can load your favourite setups and then just re-use them.

Having a button would obviously be easier so if thats a common request (those same settings) I can just include it as a checkbox instead.
« Last Edit: 2023-11-20, 09:54:57 by James Vella »

2023-11-20, 10:18:14
Reply #20

Tom

  • Active Users
  • **
  • Posts: 236
    • View Profile
    • www
I was thinking maybe I should create the checkboxes and a button for a preset save/load. This way you can load your favourite setups and then just re-use them.

That would be awesome.

2023-11-20, 22:01:16
Reply #21

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
I was thinking maybe I should create the checkboxes and a button for a preset save/load. This way you can load your favourite setups and then just re-use them.

That would be awesome.
+1

No, not really, 3ds Max 2024 allows to save user defaults for most controls, so that's not an issue anymore. I think it will be better if you keep the script simple.

Can you please explain in more detail, I can’t fully understand

2023-11-20, 22:46:27
Reply #22

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8854
  • Let's move this topic, shall we?
    • View Profile
    • My Models
Can you please explain in more detail, I can’t fully understand

Since Max 2024.1 you can right-click on most controls in Max UI and choose "set as new default". You can customize default values in any way you want, for example, make that new Corona material would be in metal mode, or have roughness of 0.3, or chamfer modifier would have 12.375 amount by default. Very handy feature.

https://help.autodesk.com/view/3DSMAX/2024/ENU/?guid=GUID-04D99FD0-33D4-425C-BBAD-63E44A98AE5F
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2023-11-21, 09:05:18
Reply #23

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile

Since Max 2024.1 you can right-click on most controls in Max UI and choose "set as new default". You can customize default values in any way you want, for example, make that new Corona material would be in metal mode, or have roughness of 0.3, or chamfer modifier would have 12.375 amount by default. Very handy feature.

https://help.autodesk.com/view/3DSMAX/2024/ENU/?guid=GUID-04D99FD0-33D4-425C-BBAD-63E44A98AE5F

Wow! Thats an amazing update. I had no idea, this is a huge time saver!

Let me know if this solves your issues guys. The update including every component of the randomizer/triplanar could take awhile, however this seems like a very simple solution since the functionality I was going to put in is basically the same as what romullus just mentioned.
« Last Edit: 2023-11-21, 11:11:39 by James Vella »

2023-11-21, 18:47:02
Reply #24

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile

Since Max 2024.1 you can right-click on most controls in Max UI and choose "set as new default". You can customize default values in any way you want, for example, make that new Corona material would be in metal mode, or have roughness of 0.3, or chamfer modifier would have 12.375 amount by default. Very handy feature.

https://help.autodesk.com/view/3DSMAX/2024/ENU/?guid=GUID-04D99FD0-33D4-425C-BBAD-63E44A98AE5F

Wow! Thats an amazing update. I had no idea, this is a huge time saver!

Let me know if this solves your issues guys. The update including every component of the randomizer/triplanar could take awhile, however this seems like a very simple solution since the functionality I was going to put in is basically the same as what romullus just mentioned.

as for me, I mainly use version 22 of 3ds max, so adding those parameters that I wrote about would be desirable, but I'm going to switch to 24 soon and I checked and the feature that romullus described works perfectly with the script, so there is no need to spend extra effort, let the script remain as simple as possible)

2023-11-21, 19:09:43
Reply #25

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
but I'm going to switch to 24 soon and I checked and the feature that romullus described works perfectly with the script, so there is no need to spend extra effort, let the script remain as simple as possible)

Yeah I tested it when romullus mentioned it, it works as expected. I was already building it all in but I think Ill revert back to this version since now that 2024.2 includes this feature its definately worth using over a very complicated update to this script. Personally I dont mind doing it since Im just seeing how far I can push things in maxscript but the functionality is there now and its super useful!

2023-11-21, 19:32:29
Reply #26

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8854
  • Let's move this topic, shall we?
    • View Profile
    • My Models
To be fair, user defaults, as useful as they are, can only have one state. The script, on the other hand, can be made to be much more flexible. Personally for me the sweet spot between flexibility and simplicity could be single checkbox stochastic mapping, when OFF, it would load randomizer with default settings, when ON, it would load it with marchik's suggested settings.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2023-11-21, 20:12:26
Reply #27

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
To be fair, user defaults, as useful as they are, can only have one state. The script, on the other hand, can be made to be much more flexible. Personally for me the sweet spot between flexibility and simplicity could be single checkbox stochastic mapping, when OFF, it would load randomizer with default settings, when ON, it would load it with marchik's suggested settings.
yes, that's a great idea, although I generally only add a randomizer if I need stochastic tiling

2023-11-21, 20:40:15
Reply #28

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Can you please supply a screenshot of the exact outcome of each setting you guys are talking about as a checkbox? This would be far easier for me to understand.

FYI When scripting things its extremely easy to go entirely in the wrong direction and waste a lot of time without some use cases/examples. What I mean by this is you can change 1 tiny little thing and the whole functionality can change for something entirely different, the more specific the easier it is to design.

2023-11-21, 21:19:34
Reply #29

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
Can you please supply a screenshot of the exact outcome of each setting you guys are talking about as a checkbox? This would be far easier for me to understand.

FYI When scripting things its extremely easy to go entirely in the wrong direction and waste a lot of time without some use cases/examples. What I mean by this is you can change 1 tiny little thing and the whole functionality can change for something entirely different, the more specific the easier it is to design.

i believe something like this

One more thing, I was wondering, is it really necessary to have a selected object with the material applied? Is it possible to implement the use of a script with selected material that is not assigned to any object?
« Last Edit: 2023-11-21, 21:25:30 by marchik »

2023-11-21, 21:42:23
Reply #30

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Thanks for the screenshot, that can be a checkbox. Same with the High Quality blending from what I'm hearing.

is it really necessary to have a selected object with the material applied? Is it possible to implement the use of a script with selected material that is not assigned to any object?

From my understanding (happy to be wrong if someone knows otherwise), it can be applied to either selected objects, a selected object(s) material or all scene materials. Can you show me a situation where you find this useful? Just to clarify further, the reason I chose this route is that if its not specific to the selected object(s), it will apply to every single material in the scene.




2023-11-22, 06:00:15
Reply #31

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
Thanks for the screenshot, that can be a checkbox. Same with the High Quality blending from what I'm hearing.

is it really necessary to have a selected object with the material applied? Is it possible to implement the use of a script with selected material that is not assigned to any object?

From my understanding (happy to be wrong if someone knows otherwise), it can be applied to either selected objects, a selected object(s) material or all scene materials. Can you show me a situation where you find this useful? Just to clarify further, the reason I chose this route is that if its not specific to the selected object(s), it will apply to every single material in the scene.

no, of course it is not an option to apply this to all scene materials at once.
As an example, materials from Megascans, you add 5 of them using Bridge to the scene at once and do not assign them to specific objects yet, because you want to combine them into one CoronaLayeredMtl, it would be convenient to select them in material editor and add a randomizer directly to them. But if the option is between “everything” and "assigned to object", then of course it’s better to leave it as it is now

2023-11-22, 12:03:26
Reply #32

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Updated to include Stochastic & HQ Blending as buttons (CoronaMappingRandomizer).

Script attached to this post.

Version 3.2 Features:
- Stochastic Button: Changes U|X: -1.0 to 1.0, V|Y: -1.0 to 1.0, W|Z: 0 to 360, Randomize each tile (on)
- HQ Blending Button: High quality blending (on/off)
- Save as Default Button: Save your enabled/disabled buttons as your new default settings for when you re-open the script
- Reset all Settings Button: Reset your default settings to the original settings for the CoronaMappingRandomizer

Notes:
- I currently broke some functionality so dont press Randomizer twice in a row for the same object lol. When I fix it ill update this as v3.1 (Fixed, v3.1)
- Broke undo now, lol. Incoming (Fixed v3.2)

UI:
UI" border="0

Stochastic Button + HQ Blending (off) Output:
Mapping" border="0

In regards to your question about currently selected materials @marchik. I think its possible, however it needs to be handled differently in slate/old material editor. Ill take a look at this another day. Out of curiosity, does anyone still use the old material editor or just slate?

Also didnt really know what to call the Stochastic button so I went with romollus suggestion, if I understand correctly (oops, forgot the word 'Mapping'). Either way it tells you what it does on the tooltip.

As always, save your scenes before running the script, let me know if you encounter bugs/crashes.
« Last Edit: 2023-11-22, 16:53:13 by James Vella »

2023-11-23, 16:33:13
Reply #33

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Updated to include selected Material as well as Object selection, more details in the Features section.

Script attached to this post.

Version 3.3 Features:
- If no object selected then select a material to apply the CoronaRandomizer to. Objects take priority over materials so as long as an object is not selected in the viewport and a material is selected in the slate editor it will apply the script to the selected material. Does not work with multiple material selections. Does work with multiple object selections.
- Updated tooltips
- Updated Instructions
- Updated checkbox naming

UI:
UI" border="0

2023-11-23, 22:13:06
Reply #34

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
Updated to include selected Material as well as Object selection, more details in the Features section.

Script attached to this post.

Version 3.3 Features:
- If no object selected then select a material to apply the CoronaRandomizer to. Objects take priority over materials so as long as an object is not selected in the viewport and a material is selected in the slate editor it will apply the script to the selected material. Does not work with multiple material selections. Does work with multiple object selections.
- Updated tooltips
- Updated Instructions
- Updated checkbox naming

UI:
UI" border="0

I didn’t have time to answer yesterday, but there’s a new version already, I checked everything, it works like a charm, thank you very much again.

I don’t even know what you can add to it anymore, maybe it’s possibility to add randomizer to several selected materials in SME at once? now it only applies to the last one selected :D


2023-11-24, 08:34:47
Reply #35

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
maybe it’s possibility to add randomizer to several selected materials in SME at once? now it only applies to the last one selected :D

Hah, yeah that is the intention. After reading through the maxscript docs I cant find a way to make this possible. If someone knows or has an example of how to do it I'm all ears (oh I think I found an example by pixamoon, it may work, fingers crossed!).
« Last Edit: 2023-11-24, 08:53:55 by James Vella »

2023-11-24, 09:11:50
Reply #36

Frood

  • Active Users
  • **
  • Posts: 1922
    • View Profile
    • Rakete GmbH
Hey James,

have not (again :) looked at the script but it should work straight like this:

Code: [Select]
if (sme.getview sme.activeView)!=undefined then (
selectedNodes = (sme.getview sme.activeView).GetSelectedNodes()
if selectedNodes.count!=0 then (
for sNode in selectedNodes do (
if (superclassof sNode.reference == material) then (
format "Doing something with '%'\n" sNode.reference.name
)
)
)
)


Good Luck
Never underestimate the power of a well placed level one spell.

2023-11-24, 10:06:20
Reply #37

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Thanks Frood, yeah this is similar to pixamoons snippet, its working in theory... just gotta find out why I keep breaking it with my undo lol. My life is just full of undefined lately :D
« Last Edit: 2023-11-24, 10:12:14 by James Vella »

2023-11-24, 10:31:49
Reply #38

Frood

  • Active Users
  • **
  • Posts: 1922
    • View Profile
    • Rakete GmbH
My life is just full of undefined lately :D

Fortunate :) Everything is possible then.


Good Luck



Never underestimate the power of a well placed level one spell.

2023-11-24, 12:00:56
Reply #39

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Script attached to this post.

Version 3.4 Features:
- Can now select multiple materials in the slate editor
- Remember, objects take priority so deselect all objects if you intend on converting selected materials instead
- Updated instructions

Notes:
- Big thanks to Frood! this actually ended up being the solution for this situation that worked best.

UI:
UI" border="0

2023-11-26, 03:01:49
Reply #40

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
Script attached to this post.

Version 3.4 Features:
- Can now select multiple materials in the slate editor
- Remember, objects take priority so deselect all objects if you intend on converting selected materials instead
- Updated instructions

Notes:
- Big thanks to Frood! this actually ended up being the solution for this situation that worked best.

UI:
UI" border="0
hope this will be added to corona's power tools

2023-11-26, 15:15:06
Reply #41

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8854
  • Let's move this topic, shall we?
    • View Profile
    • My Models
Agree, this and converter scripts from/to physical material deserves nice high resolution icons and place next to official Corona scripts. Thank you very much James!! Your scripts are incredible time savers.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2023-11-26, 17:00:47
Reply #42

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Agree, this and converter scripts from/to physical material deserves nice high resolution icons and place next to official Corona scripts. Thank you very much James!! Your scripts are incredible time savers.

You're welcome. Glad you find them useful :)

2023-11-30, 11:21:40
Reply #43

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
Agree, this and converter scripts from/to physical material deserves nice high resolution icons and place next to official Corona scripts. Thank you very much James!! Your scripts are incredible time savers.

You're welcome. Glad you find them useful :)

Wouldn't it be impudent to ask you to write another similar script?
It would be cool if we had the opportunity to add a Corona colorcorrect map using a similar method.
Only for selected materials (no objects involved) and with a choice of Basecolor (and/or) Translucency color map slots.

This can be extremely convenient for vegetation when setting up scatters. Forest Pack has a similar script built into it, but it works a little clumsily and uses a proprietary map that is not so easy to control.

I have attached a gif file with an approximate explanation of how I see it

2023-11-30, 12:42:10
Reply #44

Tom

  • Active Users
  • **
  • Posts: 236
    • View Profile
    • www
Hi,

I didn't dare ask, but I confirm it would be extremely helpful, and I'm sure a large number of 3D artists would be interested in such a script, starting with myself.

What I have in mind, is a script that would allow to:

_ add a CoronaColorCorrect map on Diffuse only, Translucency only, or both Diffuse and Translucency

_ include/exclude particular materials of the selected object when dealing with Multi/Sub-Object material types (useful to exclude trunks, branches, stems for example)

Ideally in addition, once the CoronaColorCorrect map has been added, the script could offer the possibilty to:

_ change the CoronaColorCorrect properties in a row for all objects selected: Brightness, Contrast, Saturation, Hue, Gamma etc ...

So that it's possible to change all of these settings for multiple objects in a row  :)


I know it's a lot of work, and I don't know if this is something you would be willing to do but it would be very useful and a huge time saver.

2023-12-01, 07:28:05
Reply #45

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
_ include/exclude particular materials of the selected object when dealing with Multi/Sub-Object material types (useful to exclude trunks, branches, stems for example)

I would prefer it not to work with objects and its multi/sub-object material at all.  It is not difficult to take material from an asset using an eyedropper and then select only the necessary coronaphysicalmtls in its composition, manually excluding the bark and branches yourself, if necessary.
Sometimes you need to edit the bark, and in general it is not necessary to use it for plants, because you can take any several materials, even as part of several multi/sub-object materials, and “group” their editing using this script.


Ideally in addition, once the CoronaColorCorrect map has been added, the script could offer the possibilty to:

_ change the CoronaColorCorrect properties in a row for all objects selected: Brightness, Contrast, Saturation, Hue, Gamma etc ...

similarly, I think such functionality is unnecessary, it will complicate creation of a script, but we already use multiple inputs/ouputs corona colorcorrect map to group our materials and get the possibility to edit them all together at once

2023-12-01, 15:31:25
Reply #46

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8854
  • Let's move this topic, shall we?
    • View Profile
    • My Models
Small cosmetic issue with V3.4 - when it adds triplanar or mapping randomizer to Corona physical material, it places displacement map above bump map which makes shader tree look a bit untidy. Legacy material gets wired correctly.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2023-12-01, 15:51:55
Reply #47

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
lol yeah romullus, thats out of my hands. Its based on the subanims order, doesnt do it based on input order. Something I have no idea about. It gets even crazier when you have more inputs or different setups (as you can see from my spaghetti screenshots).

Regarding the color correct stuff ive have a look. Something might be possible.

2023-12-02, 14:20:30
Reply #48

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Where does the color correct go in the chain? Right after the bitmap?

What about when you have other nodes such as falloff/mix/tiles etc?

Something like this? Actually I wont be doing it this way, read below...
cc" border="0

Edit:
I think its going to be easiest as the front of the chain (like the screenshot), things get super complex when its at the end since if you have a triplanar in there or something with multiple inputs/outputs it will need to consider each one and you will end up with connections everywhere. Notice how when you add an 'Additional Output' how you lose the existing outputs unless you add them first? That thing there is a technical brain fart.

Otherwise I do have it currently working at the end of the chain... but its easy for the user to mess up if they then apply the triplanar/randomizer script. Well, actually its kind of working I suppose, I guess it depends on the order you do it in. I just realised this as I was typing this so I dunno, what do you think? I think it actually works better at the end of the chain now I think about it more. What I mean by that is it works in the order YOU push the buttons, but its always at the end of the diffuse chain. Example: diffuse > mix > falloff > colorcorrect > material. instead of diffuse > colorcorrect > mix > falloff > material.

Adding ColorCorrect first, Randomizer Second:
cc-first" border="0

Adding Randomizer First, ColorCorrect Second:
cc-second" border="0

Simplified view of just the ColorCorrect with 4 materials (diffuse only):
cc-4mats" border="0

Keep in mind you dont need to use the Randomizer with this, I'm just testing multiple scenarios in case something breaks. But you get to see it because these things can be things that happen in production (or by accident, or user choice really).
« Last Edit: 2023-12-02, 17:00:14 by James Vella »

2023-12-02, 17:49:13
Reply #49

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
Where does the color correct go in the chain? Right after the bitmap?

What about when you have other nodes such as falloff/mix/tiles etc?

Something like this? Actually I wont be doing it this way, read below...


Edit:
I think its going to be easiest as the front of the chain (like the screenshot), things get super complex when its at the end since if you have a triplanar in there or something with multiple inputs/outputs it will need to consider each one and you will end up with connections everywhere. Notice how when you add an 'Additional Output' how you lose the existing outputs unless you add them first? That thing there is a technical brain fart.

Otherwise I do have it currently working at the end of the chain... but its easy for the user to mess up if they then apply the triplanar/randomizer script. Well, actually its kind of working I suppose, I guess it depends on the order you do it in. I just realised this as I was typing this so I dunno, what do you think? I think it actually works better at the end of the chain now I think about it more. What I mean by that is it works in the order YOU push the buttons, but its always at the end of the diffuse chain. Example: diffuse > mix > falloff > colorcorrect > material. instead of diffuse > colorcorrect > mix > falloff > material.

Adding ColorCorrect first, Randomizer Second:


Adding Randomizer First, ColorCorrect Second:


Simplified view of just the ColorCorrect with 4 materials (diffuse only):


Keep in mind you dont need to use the Randomizer with this, I'm just testing multiple scenarios in case something breaks. But you get to see it because these things can be things that happen in production (or by accident, or user choice really).

Yes, I understand this nuance perfectly.

I believe that the most convenient and logical thing would be to simply add colorcorrect at the end of the chain in any cases, immediately before entering the material. This script is needed when you already have ready-made material, and most often it will be material of vegetation, (leaves or grass) without additional maps (maybe another color correction map, but mostly without triplanar and so on) in the chain. And people will use it knowing what and why they are clicking, so foolproofing is not musthave here;

in any case, you can always click randomizer after color correct if you suddenly need it.

2023-12-02, 18:13:24
Reply #50

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Ok cool, thats pretty much how its functioning now. Just a few last things to add for the Translucency and were ready to roll.

You can add triplanar, randomizer, color correct diffuse or color correct diffuse + translucency in any order you prefer.

Only exception will be: color correct diffuse + translucency. This will be similar to the Randomizer + Triplanar button, it does both actions at once.
« Last Edit: 2023-12-02, 18:16:54 by James Vella »

2023-12-03, 11:28:50
Reply #51

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Script attached to this post.

Version 4.0 Features:
- Added Color Correct Diffuse: Applies a colorcorrect node to all selected materials for the Diffuse
- Added Color Correct Diffuse + Translucency: same as above but also plugs the diffuse into a new color correct and then into the Transluceny Color.
- Undo should be more stable now, I havent been able to crash it yet so fingers crossed.
- You can apply these in any order: CoronaRandomizer, Triplanar, Color Correct Diffuse or Color Correct Diffuse + Translucency. (one potential issue is putting the color correct after the triplanar since it creates a new output called "MultiOutputChannelTexmapToTexmap". I have no idea how to handle this or if this would be something you do anyway).
- To keep consistency this works the same way as before, objects take priority so if you want to apply to selected materials de-select the objects in the viewport.
- Order of the input/output relies on selection order in the viewport (example below). Material selection dont really have an order (that I can find, so you might end up in spaghetti town! But it works so thats a plus lol)
- Randomizer settings: Rolled up by default, once you set your settings and save them no need to see this unless you want to change something, then just roll it it back down.

UI:
UI" border="0

Color Correct Diffuse + Translucency:
CC" border="0

Selection Order:
OrderMat" border="0
OrderGeo" border="0

Fun Example: Color Correct Diffuse + Translucency > Mapping Randomizer > Triplanar = Spaghetti City!
Crazy-Town" border="0

Notes:
Thanks for the suggestions Tom. I have been thinking about a convenient way to do this (similar to the Randomizer Settings Rollup). It may be possible, for this release I just wanted to make sure you guys can play with the new features asap. I was also thinking maybe some presets would be better similar to the Randomizer Settings? So for example a checkbox for foliage which does subtle changes, happy to hear some suggested settings such as brightness -5, contrast -10 etc. Just thinking of things from the top of my head but happy to explore what's most useful in a production workflow, I mean that's what the tools are designed for to make your job easier. Since its a community project feel free to toss ideas around and come to a conclusion on best practice before I jump back into the code. Cheers
« Last Edit: 2023-12-03, 12:12:12 by James Vella »

2023-12-03, 12:38:28
Reply #52

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
Script attached to this post.

Version 4.0 Features:
- Added Color Correct Diffuse: Applies a colorcorrect node to all selected materials for the Diffuse
- Added Color Correct Diffuse + Translucency: same as above but also plugs the diffuse into a new color correct and then into the Transluceny Color.
- Undo should be more stable now, I havent been able to crash it yet so fingers crossed.
- You can apply these in any order: CoronaRandomizer, Triplanar, Color Correct Diffuse or Color Correct Diffuse + Translucency. (one potential issue is putting the color correct after the triplanar since it creates a new output called "MultiOutputChannelTexmapToTexmap". I have no idea how to handle this or if this would be something you do anyway).
- To keep consistency this works the same way as before, objects take priority so if you want to apply to selected materials de-select the objects in the viewport.
- Order of the input/output relies on selection order in the viewport (example below). Material selection dont really have an order (that I can find, so you might end up in spaghetti town! But it works so thats a plus lol)
- Randomizer settings: Rolled up by default, once you set your settings and save them no need to see this unless you want to change something, then just roll it it back down.

UI:


Color Correct Diffuse + Translucency:


Selection Order:


Fun Example: Color Correct Diffuse + Translucency > Mapping Randomizer > Triplanar = Spaghetti City!


Notes:
Thanks for the suggestions Tom. I have been thinking about a convenient way to do this (similar to the Randomizer Settings Rollup). It may be possible, for this release I just wanted to make sure you guys can play with the new features asap. I was also thinking maybe some presets would be better similar to the Randomizer Settings? So for example a checkbox for foliage which does subtle changes, happy to hear some suggested settings such as brightness -5, contrast -10 etc. Just thinking of things from the top of my head but happy to explore what's most useful in a production workflow, I mean that's what the tools are designed for to make your job easier. Since its a community project feel free to toss ideas around and come to a conclusion on best practice before I jump back into the code. Cheers

I can't say about the settings presets, I usually just change the gamma, saturation and hue to change the shades of the foliage. But each time these will be different settings.

I checked the script and it works like a charm. You can also give it the ability to recognize a Multi/Sub-object material in order to apply color correction to the materials it consists of, if we use a script with "selected objects mode". At the moment, when you run a script with the selection of an object to which a Multi/Sub-object material is assigned, it does nothing.

Otherwise, everything works perfectly, the implementation of the sequential apply of color correction + randomizer + triplanar is simply amazing, personally I am starting to get confused in these spaghetti when its applied :D
« Last Edit: 2023-12-03, 13:17:34 by marchik »

2023-12-03, 12:56:19
Reply #53

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
I checked the script and it works like a charm. You can also give it the ability to recognize a Multi/Sub-object material in order to apply color correction to the materials it consists of, if we use a script with "selected objects mode". At the moment, when you run a script with the selection of an object to which a Multi/Sub-object material is assigned, it does nothing.

Try restart 3dsmax or something, should work just fine. I tested with both object/material selection with multi-sub and it functions just the same. Can you show me a gif or something? The script just looks for Corona materials, it doesnt matter if its in a multisub it should work the same. Edit: Ah I see what you mean now, ill take a look, should be fairly straight forward. For now as a workaround you can select the materials instead of the object, ill update this in 4.1 soon.

Multi-sub:
Multisub" border="0

Otherwise, everything works perfectly, the implementation of the sequential apply of color correction + randomizer + triplanar is simply amazing, personally I am starting to get confused in these spaghetti when its applied :D

Ha yeah, imagine doing it manually.... brain explodes.
« Last Edit: 2023-12-03, 14:49:22 by James Vella »

2023-12-03, 14:39:35
Reply #54

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Script attached to this post.

Version 4.1 Features:
- Now working with Multi-Sub when selecting in object mode.

Notes:
- Thanks for the bug notification marchik!
- As always save your scene before using the script. Multiple undos when using MappingRandomizer & Triplanar can crash your scene. I think its due to how 'Additional Mapping' works but thats far too complicated for me to understand what its actually doing.
- As for the selection order, that could be pure co-incidence after some more testing. Give me your feedback while you use the script since now I have no idea what order its doing it in but it seems to be OK for the most part.
- In regards to your specific comment romullus, that bump/displacement ordering in Physical is due to the ordering of the naming in the subanims. The Legacy and Physical have different naming conventions within the material (on the backend). Its a bit of a pain to work with but I'm sure the Corona team have more experience with this stuff than I do... either that or they are also pulling their hair out. I think I like my grey streaks so ill be doing my best to keep my hair for now =D
- Also due to the nature of how the new buttons work (ColorCorrect Diffuse and or Translucency) that will definitely switch the order of inputs/outputs. The more you use it the more you will understand why it works this way, but to put it simply it needs to process all the other bitmaps like gloss, bump, height etc as well as keeping track of the diffuse/translucency. This also applies to the additional node you get when you do it in reverse order (Mapping/Triplanar then Color Correct. If you are doing it in reverse order for whatever reason you're going to have to put up with an extra node in your spaghetti network ha!). I'm not going back to that as long as its working, so please don't ask :)
« Last Edit: 2023-12-03, 16:21:36 by James Vella »

2023-12-03, 19:47:52
Reply #55

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
Script attached to this post.

Version 4.1 Features:
- Now working with Multi-Sub when selecting in object mode.

Notes:
- Thanks for the bug notification marchik!
- As always save your scene before using the script. Multiple undos when using MappingRandomizer & Triplanar can crash your scene. I think its due to how 'Additional Mapping' works but thats far too complicated for me to understand what its actually doing.
- As for the selection order, that could be pure co-incidence after some more testing. Give me your feedback while you use the script since now I have no idea what order its doing it in but it seems to be OK for the most part.
- In regards to your specific comment romullus, that bump/displacement ordering in Physical is due to the ordering of the naming in the subanims. The Legacy and Physical have different naming conventions within the material (on the backend). Its a bit of a pain to work with but I'm sure the Corona team have more experience with this stuff than I do... either that or they are also pulling their hair out. I think I like my grey streaks so ill be doing my best to keep my hair for now =D
- Also due to the nature of how the new buttons work (ColorCorrect Diffuse and or Translucency) that will definitely switch the order of inputs/outputs. The more you use it the more you will understand why it works this way, but to put it simply it needs to process all the other bitmaps like gloss, bump, height etc as well as keeping track of the diffuse/translucency. This also applies to the additional node you get when you do it in reverse order (Mapping/Triplanar then Color Correct. If you are doing it in reverse order for whatever reason you're going to have to put up with an extra node in your spaghetti network ha!). I'm not going back to that as long as its working, so please don't ask :)

I think I've found an issue, in the previous version when you select materials and apply the script - it creates a CoronaUVWRandomizer map for each material, 4.1 creates one UVWRandomizer map for 2 materials. I've attached a video to explain

PS similarly, I thought that you could teach it to work with CoronaLayeredMtls applied to an object, similar to Multi/Sub-object, so that it will create map for all materials that are connected to this CoronaLayeredMtl

PPS please tell me how I can make a donation so you can buy yourself a couple of pints of good beer and wet your gray hair :D

2023-12-04, 05:24:07
Reply #56

Tom

  • Active Users
  • **
  • Posts: 236
    • View Profile
    • www
Hi guys,

Thanks a lot for these new versions James, this is excellent.

I was just asking why you guys would ever want to add a CoronaMappingRandomizer or a Triplanar map to foliage materials ? I don't honestly see what's the point doing that, as it will mess up the already existing mapping of the model. Can you explain?

I tried version 4.1, it works really well so far.
The thing is, when I deal with vegetation material, what I usually do is:

_ colorcorrecting the diffuse channel
_ plugging the diffuse into a new colorcorrection map, that I plug into the translucency slot

The color correction on the Translucency slot has pretty much all the times the same settings, the ones you can see on the screenshot below.

And here your script doesn't help as it doesn't put the color correction at the right place, so I have to do it by hand (again, have a look at the screenshot to see what I mean).

If this is something you could allow for the script to change, that would be fantastic, if not, that's ok too, your script is already very useful as is and, like Marchik said, more than happy to do a donation for it, thanks again.


2023-12-04, 09:50:44
Reply #57

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
Hi guys,

Thanks a lot for these new versions James, this is excellent.

I was just asking why you guys would ever want to add a CoronaMappingRandomizer or a Triplanar map to foliage materials ? I don't honestly see what's the point doing that, as it will mess up the already existing mapping of the model. Can you explain?

I tried version 4.1, it works really well so far.
The thing is, when I deal with vegetation material, what I usually do is:

_ colorcorrecting the diffuse channel
_ plugging the diffuse into a new colorcorrection map, that I plug into the translucency slot

The color correction on the Translucency slot has pretty much all the times the same settings, the ones you can see on the screenshot below.

And here your script doesn't help as it doesn't put the color correction at the right place, so I have to do it by hand (again, have a look at the screenshot to see what I mean).

If this is something you could allow for the script to change, that would be fantastic, if not, that's ok too, your script is already very useful as is and, like Marchik said, more than happy to do a donation for it, thanks again.

no, of course I don’t add triplanar or randomizer for vegetation. I actually thought that this could be done in the form of a separate script, but having everything in one script is also convenient.

I agree about the sequence for transluency color, it would be more convenient, I didn’t think about it

2023-12-04, 17:00:17
Reply #58

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Script attached to this post.

Version 4.2 Features:
- Fixed Randomizer & Triplanar to work as it did previously in Version 3.4
- Works with object selection: Multi-Sub & CoronaLayeredMtl

Notes:
- I noticed an issue with the Color Correct Diffuse + Translucency. This button doesn't do what it should when selecting a single material. This should be fixed when I re-write the code for 4.3 with the updated functionality for Tom.

I think I've found an issue, in the previous version when you select materials and apply the script - it creates a CoronaUVWRandomizer map for each material, 4.1 creates one UVWRandomizer map for 2 materials. I've attached a video to explain

Ah yeah, I messed it up trying to refactor/clean up the code. Thanks for the feedback.

PS similarly, I thought that you could teach it to work with CoronaLayeredMtls applied to an object, similar to Multi/Sub-object, so that it will create map for all materials that are connected to this CoronaLayeredMtl

Done.

And here your script doesn't help as it doesn't put the color correction at the right place, so I have to do it by hand (again, have a look at the screenshot to see what I mean).

If this is something you could allow for the script to change, that would be fantastic, if not, that's ok too, your script is already very useful

Ill take a look at this for Version 4.3, I wanted to fix these issues first with Randomizer & Triplanar so you can keep working as normal with the latest version. I thought it was going to be an easy change but its actually far more difficult that I first thought. Let me think about it some more, I'm sure its possible.

PPS please tell me how I can make a donation so you can buy yourself a couple of pints of good beer and wet your gray hair :D

more than happy to do a donation for it

Ha thanks guys, no need.
« Last Edit: 2023-12-04, 17:20:01 by James Vella »

2023-12-04, 18:13:01
Reply #59

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
Script attached to this post.

Version 4.2 Features:
- Fixed Randomizer & Triplanar to work as it did previously in Version 3.4
- Works with object selection: Multi-Sub & CoronaLayeredMtl

Notes:
- I noticed an issue with the Color Correct Diffuse + Translucency. This button doesn't do what it should when selecting a single material. This should be fixed when I re-write the code for 4.3 with the updated functionality for Tom.


I finally decided to test and figure out how it would actually work with a real asset and at the moment I imported a tree that in its material has a separate map for diffuse and a separate map for tranc color, after using the script we get what the map for tranc color not used at all. (attached a video)

In real production (before applying all the scripts) we usually have 3 situations:

1) diffuse and tranc color are specified by different independent maps "X" and "Y"
2) Map "X", goes into the Diffuse slot and in the Trans Color slot there is a map "X", but passed through ColorCorrect.
3) The same map "X" goes into the Diffuse and Trans Color slots.

After applying the script, we should get a Corona Color Correction map, which would allow us to change the parameters for the Trans color slot regardless of Diffuse. And this should work for all 3 cases I mentioned. In other words, the script must be applied “from the end” creating CoronaColorCorrect immediately before entering the material, regardless of what was inserted into the Trans color slot before.

2023-12-04, 18:44:25
Reply #60

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
I understand what you mean about using the existing translucency texture.

What I dont understand is does this differ from your first request? You said you wanted the diffuse to have a color correct that plugs into the translucency right? (The attached gif)

Also how does this work with Toms suggestion?

Edit:
Does this mean you need a separate button for example: Color Correct + Use Existing Translucency =
So this button would do what the Color Correct Diffuse button does - however applies it to your current existing Translucency texture.

Button: Color Correct + Translucency =
Current Functionality, this way if you dont have a model that has a translucency texture it creates it for you using the Diffuse texture

If you can, please send a screenshot of each scenario you expect. Not a gif, I dont know how to pause it and I end up taking screenshots and sometimes I miss the timing. (videos/mp4 are good too)
« Last Edit: 2023-12-04, 19:22:17 by James Vella »

2023-12-04, 20:07:30
Reply #61

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
I understand what you mean about using the existing translucency texture.

What I dont understand is does this differ from your first request? You said you wanted the diffuse to have a color correct that plugs into the translucency right? (The attached gif)

Also how does this work with Toms suggestion?

Edit:
Does this mean you need a separate button for example: Color Correct + Use Existing Translucency =
So this button would do what the Color Correct Diffuse button does - however applies it to your current existing Translucency texture.

Button: Color Correct + Translucency =
Current Functionality, this way if you dont have a model that has a translucency texture it creates it for you using the Diffuse texture

If you can, please send a screenshot of each scenario you expect. Not a gif, I dont know how to pause it and I end up taking screenshots and sometimes I miss the timing. (videos/mp4 are good too)

yes, when I wrote the first request, I should have thought a little longer :D my fault

From my perspective - the main goal of this script is to take ready-made vegetation materials (which can consist of a large number of materials inside a multi/sub-object, usually) and quickly assign a CCC map that will allow you to adjust the shades of foliage on all materials/models at once. Regardless of how this initial one material was created, (does it use a separate map for translucency or does it use a diffuse map passed through Color Correction for this purpose).

I don't know Tom's specific pipeline, whether he wants a script to help him create vegetation material from scratch, etc. Need to clarify this with him.
I'll attach screenshots in before/after format of what I expect the script to do in different cases.

2023-12-05, 02:46:15
Reply #62

Tom

  • Active Users
  • **
  • Posts: 236
    • View Profile
    • www
From my perspective - the main goal of this script is to take ready-made vegetation materials (which can consist of a large number of materials inside a multi/sub-object, usually) and quickly assign a CCC map that will allow you to adjust the shades of foliage on all materials/models at once. Regardless of how this initial one material was created, (does it use a separate map for translucency or does it use a diffuse map passed through Color Correction for this purpose).

I don't know Tom's specific pipeline, whether he wants a script to help him create vegetation material from scratch, etc. Need to clarify this with him.
I'll attach screenshots in before/after format of what I expect the script to do in different cases.

I'm looking for the same thing as you marchik: quickly tweak already made vegetation materials.

Thanks for the screenshots: I agree with your case #1, but not with #2 and #3 as, to me, the translucency slot should always be populated with a variation of the diffuse map, see the screenshots below.

I do understand your workflow as well marchik, but I prefer to tweak the end result diffuse map (eg after it's been color corrected) rather than tweak it from 'the start' if that makes sense (again, have a look at the screenshots).


2023-12-05, 10:12:46
Reply #63

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
From my perspective - the main goal of this script is to take ready-made vegetation materials (which can consist of a large number of materials inside a multi/sub-object, usually) and quickly assign a CCC map that will allow you to adjust the shades of foliage on all materials/models at once. Regardless of how this initial one material was created, (does it use a separate map for translucency or does it use a diffuse map passed through Color Correction for this purpose).

I don't know Tom's specific pipeline, whether he wants a script to help him create vegetation material from scratch, etc. Need to clarify this with him.
I'll attach screenshots in before/after format of what I expect the script to do in different cases.

I'm looking for the same thing as you marchik: quickly tweak already made vegetation materials.

Thanks for the screenshots: I agree with your case #1, but not with #2 and #3 as, to me, the translucency slot should always be populated with a variation of the diffuse map, see the screenshots below.

I do understand your workflow as well marchik, but I prefer to tweak the end result diffuse map (eg after it's been color corrected) rather than tweak it from 'the start' if that makes sense (again, have a look at the screenshots).

thank you, Tom, now I understand.  Yes, you are absolutely right, this scheme is more convenient, although I often set it up differently.  In general, these methods could be divided into “serial/parallel” connection checkboxes if needed.  But I think it would be logical to accept your scheme and not complicate the script.

I really don’t know what to do with cases when the source material already has a transluence map and it is quite different from diffuse, this sometimes happens with Quixel.  Maybe it can be only 3 controls: "Diffuse", "Diffuse + Trans. Color" and the checkbox "Preserve source trans. map"

2023-12-05, 14:15:24
Reply #64

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Do you have situations where your model does not have a translucency input at all (but needs one)?

Example Before:
before" border="0

Example After:
after" border="0
« Last Edit: 2023-12-05, 14:22:23 by James Vella »

2023-12-05, 15:10:46
Reply #65

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
Do you have situations where your model does not have a translucency input at all (but needs one)?

Example Before:
before" border="0

Example After:
after" border="0

Yes, such cases can exist in theory, we can add this too. 

But I would NOT add this, since let’s consider the following case:

we have a multi/sub-object tree material.  it also contains materials from the trunk and branches that do not have transluency. 

And we may need to simply make the entire tree lighter (both foliage and branches) so that it fits better into its surroundings.  In this case, we need to edit the translucency, but we cannot affect the material of the branches.  We could first select all materials and apply color correction only to diffuse, but we will not have the option to then select foliage materials and apply separate color correction to translucency, since in the script these functions are combined.

So, no)

2023-12-05, 16:00:15
Reply #66

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
So you are saying you always plug in a translucency? The reason I ask is if you do not have anything connected to the translucency then the only thing that will happen is you get another Diffuse Color Correct. We need to consider all edge cases so they can be built into the case scenarios, otherwise unexepcted things will happen.

Example: No translucency input
notrans" border="0

So lets say this is a more preferable workflow:
- Select a tree, hit color correct so you can lighten branches and leaves
- Deselect the tree, select the leaves and apply Translucency.

I think this would be better then if thats how you work. Since the all the script is doing when you press the Diffuse + Translucency button is running the first function again, so we can change that functionality so it only adds a translucency instead of doing both functions. Does that sound better?

Hmm let me think about it more, its quite complex. I understand what you mean I have to map it out since theres quite a few variables to consider.

Edit:
So how would you use this current script in Case 2? Since you already have a Color Correct?
« Last Edit: 2023-12-05, 17:01:56 by James Vella »

2023-12-05, 17:28:11
Reply #67

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
So you are saying you always plug in a translucency? The reason I ask is if you do not have anything connected to the translucency then the only thing that will happen is you get another Diffuse Color Correct. We need to consider all edge cases so they can be built into the case scenarios, otherwise unexepcted things will happen.

Example: No translucency input
notrans" border="0

So lets say this is a more preferable workflow:
- Select a tree, hit color correct so you can lighten branches and leaves
- Deselect the tree, select the leaves and apply Translucency.

I think this would be better then if thats how you work. Since the all the script is doing when you press the Diffuse + Translucency button is running the first function again, so we can change that functionality so it only adds a translucency instead of doing both functions. Does that sound better?

Hmm let me think about it more, its quite complex. I understand what you mean I have to map it out since theres quite a few variables to consider.

Edit:
So how would you use this current script in Case 2? Since you already have a Color Correct?



This is why I believe that we simply should not give the diffuse+translucency button functionality in the form of a forced connection to the translucency slot, if it was not there initially.

Perfect way:
If we select a multi/sub-object material that contains materials, some of which have translucency, and some do not, and press the "Diffuse + translucency" button, then the script should combine all existing diffuses into one CCC map, and after it take those outputs that were initially connected to the "trans. color" slots, and form another CCC map from them. I will attach a screenshot of how it was ideally implemented, in my opinion, and of course I understand that this becomes quite a difficult task.

With all that, I am in favor of simplifying the script as much as possible and not trying to cover all possible use cases. I think people who will use it will calmly come up with ways to avoid making mistakes

2023-12-05, 17:38:03
Reply #68

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile

So lets say this is a more preferable workflow:
- Select a tree, hit color correct so you can lighten branches and leaves
- Deselect the tree, select the leaves and apply Translucency.

I think this would be better then if thats how you work. Since the all the script is doing when you press the Diffuse + Translucency button is running the first function again, so we can change that functionality so it only adds a translucency instead of doing both functions. Does that sound better?



Specifically, this option sounds simpler to implement and quite logical; a person himself will determine where he has materials with translucency and apply it if necessary. If it is not possible to implement the “ideal” option, then I vote for this one.

2023-12-09, 13:04:52
Reply #69

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Script attached to this post.

Version 4.3 Features:
- New: Vegetation Tools section (as this works differently to Randomizer section)
- Updated Translucency options (examples below)
- Updated UI

UI:
UI" border="0

Notes:
- For the Translucency buttons to work you must already have a "Color Correct - Diffuse" applied to the Diffuse (either single or multiple materials). Manually or with the script.
- Case #5 shows "Translucency - Existing" wont affect materials that dont have a translucency input. "Translucency - New" will add one, so depends on what button you push. Which means "Translucency - Existing" should also work for your materials/multi-subs with branches, and if your branches don't have a translucency input they should not be affected.
- Careful when using "Translucency - New", it will delete any nodes that were attached to translucency input. I did this because it left orphan nodes in the scene and defeats the purpose of "New". However if you want them to remain in the Slate Editor thats easy enough to change. Example is the last screenshot with the 2 orphan translucency nodes on the bottom left.

Case 1 Before/After:
case1-1" border="0

case1-2" border="0

Case 2 Before/After:
case2-1" border="0

case2-2" border="0

Case 3 Before/After:
case3-1" border="0

case3-2" border="0

Case 4 Before/After:
case4-1" border="0

case4-2" border="0

Case 5 Before/After Existing/After New (all 3 materials selected):
case5-1" border="0

case5-2" border="0

case5-3" border="0

« Last Edit: 2023-12-09, 19:11:06 by James Vella »

2023-12-09, 15:35:46
Reply #70

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
Script attached to this post.

Version 4.3 Features:
- New: Vegetation Tools section (as this works differently to Randomizer section)
- Updated Translucency options (examples below)
- Updated UI


I checked it now, everything works fine, this is very cool, thanks for your time!
First I encountered a funny bug (attached a video). I always create a Checker map for testing (and you use bitmaps for it) and with the checker the script does not respond to pressing the button for transluency, but then I created a regular Сoronabitmap and everything worked as it should. Very interesting what the hypothetical reason could be :D

2023-12-09, 16:46:39
Reply #71

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
I checked it now, everything works fine, this is very cool, thanks for your time!

You're welcome.

I always create a Checker map for testing (and you use bitmaps for it) and with the checker the script does not respond to pressing the button for transluency, but then I created a regular Сoronabitmap and everything worked as it should. Very interesting what the hypothetical reason could be :D

Its designed for CoronaBitmap/Bitmap, CoronaPhysical/CoronaLegacy/Multi-Sub/Corona-Layered (so far). Its easier to add inclusions later on than the opposite, this way you dont get unintended things happening along the way - basically 'it does what its designed to do'. Then bug fixes, then add more stuff :)

All the other nodes like falloff/mix etc are just bypass nodes, so not input nodes - if you were wondering why they work. Its Translucency button(s) are designed to look up the chain, find the bitmap, go down the chain plug it in basically. It works a lot differently to say the Diffuse - Color Correct button since it has so many variables to keep track of its easier for me to build it this way. Maybe one day ill look back and think this was a trash idea but if it works it works lol.

Edit:
Technical Explanation Rant Incoming:

TLDR:
If you are interested, a more technical understanding of how the Translucency button works is that it checks that the bitmap for the diffuse is the same as the one for the translucency. This is how one button can do 4 different things (case scenarios). If the diffuse bitmap is different to the translucency bitmap then do this, if its in a color correct and is the same bitmap then do that, if its a different bitmap then do another thing, etc. The Diffuse - Color Correct button doesn't care about what's before the diffuse input on the material, it just puts that last.

The rant:
The way the Corona nodes with additional mapping works is just crazy, blew my mind for a whole week. The strange thing is that when you add an "Additional outputs" in the Corona nodes it actually switches the order of things (which is why you do this before otherwise you lose your original output connection right?). It would be much easier if Input/Default Output = Input 1, Output 1. But they are not, they are something else. So what happens when you add a new output is everything gets reordered and new things are created (so Input 1 & Additional Output 1 = Input 1, Output 1. Then your original output is removed and replaced with a new output and the whole Color Correct node changes). What compounds this even further is that what you think is your Output 1 -> Diffuse is not actually a direct connection. It now goes through another invisible new node called "MultiOutputChannelTexmapToTexmap". This is a separate node just like Color Correct and makes things very difficult to keep track of... well at first anyway. I kind of get how it works now but it really threw a spanner in the works for awhile there since not only do you have to work out how to re-wire everything, you are also about 3 loops down and have to do it all backwards... I don't know if that makes any sense to you but yeah, it was a pretty difficult concept to wrap my head around but I think I got a solution that seems easy to follow from here on. (for any maxscripters in the future reading this, dont do it backwards - there is an easier way, just read the code its available for free here or in my github).

I would say its due to the fact that Corona had the ColorCorrect node before they had multiple input/outputs, so re-ordering could have been a major pain and this was the next best idea... seems plausible. Since every other Corona node that uses multiple in/outputs also do this. I'm far from an advanced programmer so I would say someone smart probably created this idea and knew what they were doing so don't take my word for it. Also another pain in the neck is Bitmap works different to CoronaBitmap, so does Physical/Legacy. Not only do you need to work out all the stuff I just said, you then have multiple scenarios where you need to consider different bitmap or material types and incorporate all that into your script(s) or things get left behind.

Hence why in my opinion its better to add stuff once its stable than to remove things later since that means your code will need a lot of re-work. Funnily enough if a button doesn't do something that's usually a sign that your error handling is working correctly lol. The worst case scenario is someone pushes a button and the maxscript listener pops up with an error, breaks the UI and halts the script at that point. From an artists perspective both sound terrible, but the former is actually much better lol. The best solution is really that you inform your user with a popup of the error type, cancel the operation and then the coder/programmer knows where to look in the code since they created that error message in the first place (or continue the operation without that functionality). I was considering this when I made the Translucency button, but I put it as step 5. in the instructions instead since, well that's so much easier lol. Never thought of a checkermap situation but that's not high on my priority list at this stage as long as its works for your vegetation :D
« Last Edit: 2023-12-09, 23:45:18 by James Vella »

2023-12-10, 00:03:55
Reply #72

Tom

  • Active Users
  • **
  • Posts: 236
    • View Profile
    • www
James you're absolutely amazing, thanks a lot for this huge time saver script.
I don't have time right now to test but I will definitely, and I'm sure it does a great work.
Thanks again!

2023-12-10, 09:01:17
Reply #73

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
James you're absolutely amazing, thanks a lot for this huge time saver script.
I don't have time right now to test but I will definitely, and I'm sure it does a great work.
Thanks again!

You're welcome. Let me know if you get any strange bugs. I still have to work out why multiple undo's crash often, still cant pin point it to anything specific.

Thinking more about your question marchik, its actually a good question for future me lol. I'll keep it in the back of my head since that could potentially be useful for other scenarios.

Edit:
We didnt discuss this scenario, but I imagine in this case you would want to remove the color correct from translucency when running the script yeah? My only thinking is that you could have already made the adjustments and want to just keep it so using the Translucency (or script) would not be neccessary anyway? Thoughts?
Before:
b4" border="0

After:
after" border="0
« Last Edit: 2023-12-10, 09:25:09 by James Vella »

2023-12-10, 11:15:16
Reply #74

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Script attached to this post.

Version 4.4 Features:
- Small quality of life improvements
- Updated UI
- Updated Naming for Color Correct nodes
- New Rollout for saving your Translucency settings (similar to Randomizer)

Notes:
- The UI is a little longer now just to allow rollup/down of Settings so you dont have to scroll when they open
- Just to keep things a bit more clear while you are in the material editor, Diffuse Color Correct is now named (see screenshots Naming). Same with Translucency
- A button just for Tom, well anyone really lol. "Brighter Leaves" in the Vegetation settings: brightness 0.3, saturation 0.3, gamma 1.5 - On/off. You can save these as your default so you dont need to check this button in the rollout or worry about it in future max sessions.

UI (Default):
UI-1" border="0

UI (Vegetation Settings rolled down):
UI-2" border="0

Color Correct Node Naming:
Naming" border="0

2023-12-10, 20:09:53
Reply #75

marchik

  • Active Users
  • **
  • Posts: 258
    • View Profile
Script attached to this post.

Version 4.4 Features:
- Small quality of life improvements
- Updated UI
- Updated Naming for Color Correct nodes
- New Rollout for saving your Translucency settings (similar to Randomizer)

Notes:
- The UI is a little longer now just to allow rollup/down of Settings so you dont have to scroll when they open
- Just to keep things a bit more clear while you are in the material editor, Diffuse Color Correct is now named (see screenshots Naming). Same with Translucency
- A button just for Tom, well anyone really lol. "Brighter Leaves" in the Vegetation settings: brightness 0.3, saturation 0.3, gamma 1.5 - On/off. You can save these as your default so you dont need to check this button in the rollout or worry about it in future max sessions.

UI (Default):
UI-1" border="0

UI (Vegetation Settings rolled down):
UI-2" border="0

Color Correct Node Naming:
Naming" border="0

Let me once again admire your dedication to the work you undertake, I myself try to do the same whenever possible, but your example is very inspiring. In the near future, I will also record a video and tell my audience about this tool. Thanks!

2023-12-10, 21:09:25
Reply #76

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Let me once again admire your dedication to the work you undertake, I myself try to do the same whenever possible, but your example is very inspiring. In the near future, I will also record a video and tell my audience about this tool. Thanks!

Thanks! Glad you find it useful. Sure go ahead share it with those who need it :)

2023-12-11, 01:23:32
Reply #77

aaouviz

  • Active Users
  • **
  • Posts: 886
    • View Profile
    • Another Angle 3D
Hi James,

This is absolutely amazing. Incredible work. Thank you!

I'm wondering if you can somehow take donations or some sort of payment? As a (small way) of saying Thanks for this and all the other script help you've offered me here on the forum in the past.

I notice you don't sell scripts but do sell 3d models. Are you owner of this '3d cargo' website, or is it a marketplace you sell on? (I'll happily buy some models if you get full share of the price).

Cheers!
Nicolas Pratt
Another Angle 3D
https://www.instagram.com/anotherangle3d/

2023-12-11, 10:29:58
Reply #78

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Hi James,

This is absolutely amazing. Incredible work. Thank you!

I'm wondering if you can somehow take donations or some sort of payment? As a (small way) of saying Thanks for this and all the other script help you've offered me here on the forum in the past.

I notice you don't sell scripts but do sell 3d models. Are you owner of this '3d cargo' website, or is it a marketplace you sell on? (I'll happily buy some models if you get full share of the price).

Cheers!

Thanks aaouviz, glad you enjoy it :)

Yes I am the owner of 3D Cargo, so I get full commission. If you see something you like you can buy it there instead of a marketplace. Also if you end up getting something please let me know your thoughts, the reviews I get from other market places are quite basic and its tough to know what people in production actually find useful or want updated for their workflow. Thanks!

2024-01-12, 12:58:23
Reply #79

tatarka

  • Users
  • *
  • Posts: 4
    • View Profile
Could you add a message about the lack of applied material, on the object you are running the script? At the moment it throws an unpleasant error. thx

2024-01-12, 13:21:03
Reply #80

Frood

  • Active Users
  • **
  • Posts: 1922
    • View Profile
    • Rakete GmbH
That ".material" is not required anyway imho. It should work as well if "target:obj.material" is changed to "target:obj" (in both lines). Then there is no error thrown if obj has no material applied.


Good Luck


Never underestimate the power of a well placed level one spell.

2024-01-12, 14:39:02
Reply #81

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Thanks for the bug notice, updated in 4.5 attached.

Cheers Frood, saves the day once again!

2024-02-13, 05:04:03
Reply #82

Tom

  • Active Users
  • **
  • Posts: 236
    • View Profile
    • www
Hi everyone,

I've been using this script few times now and it's working great, I love it.

But today I have an issue with a tree material: this material is a Multi/Sub-Object Mtl, made of 6 sub-materials, all CoronaLegacyMtl.

I had no issue using the "Diffuse - Color Correct" part of the script: it's correctly been applied to sub-mtls #4,5 and 6, which is what I wanted.
But then when I apply "Translucency - Color correct (existing)", only the sub-mtl #6 is being affected. Sub-mtls #4 and #5 are not affected surprisingly.

Please have a look at the attached screenshot: you can see a color correction map has correctly been applied to the sub-mtl #6 translucency map, but not to sub-mtls #4 and #5 translucency maps.

I closed the script, ran it again, this time with the "Translucency - Color correct (new)" button (I deleted the bitmap first so that nothing was plugged in the translucency slot): nothing happened.

Can you help?

Many thanks,


- 3ds Max 2023, Corona 10HF2 -

2024-02-13, 08:27:35
Reply #83

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
It looks like your diffuse doesn't have a color correct node. In the instructions it mentions:
5. Vegetation Tools - To use 'Translucency' you must already have Diffuse - Color Correct.

In your case it looks like you have a Mix node or something between the Diffuse and Material, it wont work unless its a Color Correct node.

Remember selected geometry takes priority over selected materials so check your selection before you run the script.
« Last Edit: 2024-02-13, 08:33:40 by James Vella »

2024-02-13, 08:37:31
Reply #84

Tom

  • Active Users
  • **
  • Posts: 236
    • View Profile
    • www
There is a CoronaColorCorrect node plugged after the diffuse bitmap, but then I plugged a CoronaMultiMap after it, hence why the script didn't do anything, it makes sense now, thanks!

2024-02-13, 08:39:54
Reply #85

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
No worries, let me know if it still doesnt behave correctly after removing the MultiMap

2024-02-13, 08:50:05
Reply #86

Tom

  • Active Users
  • **
  • Posts: 236
    • View Profile
    • www
No, all good now. Amazing script, really.
Thanks again James.

2024-02-13, 09:09:01
Reply #87

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
Good to hear, enjoy Tom :)

2024-02-26, 14:46:06
Reply #88

tatarka

  • Users
  • *
  • Posts: 4
    • View Profile
I have a requests.
Is it possible to add an indicator that will allow me to change the number of entries? as it is in multimap. If I build the material from scratch myself, it would be helpful. And it would be useful to have a shortcut that would add the node itself, without first selecting the material or model.

2024-02-26, 15:52:40
Reply #89

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
I have a requests.
Is it possible to add an indicator that will allow me to change the number of entries? as it is in multimap. If I build the material from scratch myself, it would be helpful. And it would be useful to have a shortcut that would add the node itself, without first selecting the material or model.

Not sure I understand, isnt this the same as putting a new coronarandomizer node into the slate editor then setting the input number?

2024-02-26, 16:32:12
Reply #90

tatarka

  • Users
  • *
  • Posts: 4
    • View Profile
LoL.. I wasn't aware that this option existed, I somehow missed it at the bottom xD Never mind :P