Author Topic: Maxscript call to open Corona Tone Mapping  (Read 685 times)

2024-01-13, 17:34:43

Dalton Watts

  • Active Users
  • **
  • Posts: 210
    • View Profile
This might be a shot in the dark but does anyone know how can I call the Corona Tone Mapping menu via maxscript?

2024-01-13, 18:37:49
Reply #1

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
https://forum.corona-renderer.com/index.php?topic=1439.0

Answer:
Code: [Select]
CoronaRenderer.CoronaFp.showVfb true

Ah Tone mapping. Sorry I didnt read your question properly.

Edit:
This github page has a maxscript you can use for tonemapping:
https://github.com/mohseni-mr/Corona-Tone-Mapping-Wrapper/blob/main/README.md]

For Example:
- I copied his Tone Mapping Pipeline Wrapper.ms into the maxscript editor
- Then in the readme (attached screenshot) you can adjust the values based on his functions
« Last Edit: 2024-01-13, 18:43:28 by James Vella »

2024-01-15, 08:48:33
Reply #2

Aram Avetisyan

  • Corona Team
  • Active Users
  • ****
  • Posts: 561
    • View Profile
Hi,

There is no direct control over the tone mapping, like you have it in VFB. But there were requests for it and we have them reported.

Feel free to use any workarounds you find fit in the meantime.
Aram Avetisyan | chaos-corona.com
Chaos Corona Support Representative | contact us

2024-01-15, 11:15:14
Reply #3

Dalton Watts

  • Active Users
  • **
  • Posts: 210
    • View Profile
Thank you for both replies. I saw that script from Mohammadreza but I don't know what that does :-) I just want a maxscript that calls the tone mapping exactly as the button on the unified lister. From my brief reading before my question, I got the idea that it wasn't as trivial as I would have thought. Meanwhile, my workflow will have to adapt to this apparent impossibility.

2024-01-15, 15:42:06
Reply #4

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
So just as a simple test, delete all the tonemapping operators and add a ACES OT and Saturation :
tonemap1" border="0

Then in the maxscript editor your code should look like this:
Code: [Select]
(
    Mohammadreza's code first....etc
)

currentOperators = crnToneMapping.GetAllTMOperatorsPlusIDs()

-- it shows: SaturationOperatorPlugin & AcesOtOperatorPlugin
-- so thats currentOperators[1] and currentOperators[2]

-- Change saturation (Operator 1)
cfb = renderers.current.colorMap_pipeline
cfb.colorMappingOperator_saturation = .722

-- Go To Next Operator
cfb = cfb.colorMappingOperator_nextOperator

-- Change AcesOT (Operator 2)
cfb.colorMappingOperator_opacity = .22

Output is:
tonemap2" border="0

You can then use his other functions to add new operators, delete them by id etc... I just read through his code to get these variables and work it out from there.

You can also just add one operator at a time then assign the variable cfb and showproperties to see the value you need to change (for example, ill delete them all (for a moment) and add a Tint, from this output we need "colorMappingOperator_tint: color"):
Code: [Select]
cfb = renderers.current.colorMap_pipeline
showproperties cfb

--prints
ReferenceTarget:TintOperatorPlugin
  .colorMappingOperator_nextOperator : maxObject
  .colorMappingOperator_id : integer
  .colorMappingOperator_enabled : boolean
  .colorMappingOperator_tint : color

Once you get all the variables you need you can just convert it to a loop or something like
Code: [Select]
currentOperators = crnToneMapping.GetAllTMOperatorsPlusIDs()
cfb = renderers.current.colorMap_pipeline

-- Iterate through the currentOperators
for operator in currentOperators do
(
if classOf operator[1] == SaturationOperatorPlugin then
(
cfb.colorMappingOperator_saturation = 0.1  -- Replace with your desired value
)
if classOf operator[1] == AcesOtOperatorPlugin then
(
cfb.colorMappingOperator_opacity = 0.2  -- Replace with your desired value
)
if classOf operator[1] == TintOperatorPlugin then
(
cfb.colorMappingOperator_tint = [255, 0, 0] -- RGB Color
)
-- Iterate to next operator
cfb = cfb.colorMappingOperator_nextOperator
)

Output:
tonemap3" border="0

Also, can you show me what it looks like in the unified lister? I'm still running an older version for our current projects
« Last Edit: 2024-01-15, 17:25:40 by James Vella »

2024-01-15, 19:08:46
Reply #5

Dalton Watts

  • Active Users
  • **
  • Posts: 210
    • View Profile
Got it James! Thank you very much for taking the time to explain it! Will try to get my head around it to see if something can be done.

2024-01-15, 19:09:56
Reply #6

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
no worries Dalton, glad to help. Let me know if you get stuck I might be able to dig in a bit deeper for you.

2024-01-15, 19:21:34
Reply #7

Dalton Watts

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

Also, can you show me what it looks like in the unified lister? I'm still running an older version for our current projects

I apologize for not responding to this question, James. Attached are images where you can see the "EDIT" button that opens the dialog with the Tonemapping operators inside the Corona Unified Lister.

2024-01-15, 19:28:37
Reply #8

James Vella

  • Active Users
  • **
  • Posts: 540
    • View Profile
hm, ok I see so now you can edit tone mapping per camera...

That will change things a bit. For example:
1. You can keep that loop I did once you get all variables and put it into a Function
2. You then need to work out how the unified lister is linked to each camera
3. Then for each camera, run the function.

It wont be too hard.. but thats kind of the formula. Its just working out how the camera is linked to each tone mapping that could be tricky. ChatGPT is your friend lol. When I often get stuck I just print as much stuff as I can and ask chatgpt how it works. 99% of the time its wrong (for maxscript) but sometimes it will give me an idea of something I didnt think of. Anyway, I'm sure you can play with it from here and see where you get to and then keep us posted.

Just a tip when using ChatGPT, I find its best to break things down into the most simple way possible, asking it direct questions to specific results. Then you need to build it how you would normally build things in maxscript. Otherwise its going to send you down the rabbit hole and it gets messy from there. For example ive had it build me 3 functions and a class just for something I can do with one call() in maxscript, it doesnt know but it tries its best :D. So yeah take it with a grain of salt and try to work things out step by step, dont let it write a script for you or you will end up re-writing it.
« Last Edit: 2024-01-15, 19:34:27 by James Vella »