Author Topic: Corona Randomizer  (Read 12788 times)

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

James Vella

  • Active Users
  • **
  • Posts: 552
    • 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: 259
    • 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: 249
    • 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: 259
    • 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: 552
    • 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: 259
    • 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: 552
    • 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: 259
    • 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: 259
    • 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: 552
    • 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: 259
    • 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: 552
    • 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: 249
    • 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: 552
    • 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: 552
    • 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