Author Topic: Corona Randomizer  (Read 10981 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