To explain this quickly, what I need is a script that isolates an object, at the same time, the HDRI needs to switch to a different HDRI and the VFB tone settings need to reset. These settings need to revert back when turning isolate off.
Let me know if I’m not making myself clear
The general idea is to isolate an object and run interactive using an HDRI that’s good for testing materials. What I would usually do is switch my 3ds max settings to single map in corona scene environment settings. The issue with this is you will need to change your VFB tone settings to compensate each HDRI. Therefore you need to save and load Postprocess .conf files when switching your HDRI which is time-consuming!
The issue may get saving/loading vfb conf files. Afaik the corona interface does not have any option to do this by maxscript so it has to be done manually for specific renderer properties (all “colorMap_” ones). But presuming the scene uses a corona camera (with tone mapping overrides) and tweaking happens in perspective mode (which uses “Render Setup” → “Camera” in opposition) it may even not be necessary to save/load vfb settings. I like the idea to have a button “let’s tweak this”. So what kind of help do you actually need to proceed?
Hi Frood. Your approach to using camera tone map override definitely helps. No point in creating a script. Maybe creating a hotkey to switch corona environment settings could be useful.
You could also have 3ds Max enviro set to one HDRI and Corona enviro set to another. Then use a script to switch between “use Max” and “use Corona” options in the Scene tab.
Hi Maru. I’m no expert at using scripts. Understanding something as simple as CoronaRenderer.CoronaFp.showvfb true is as far as my knowledge goes. According to Corona Doc | Corona Renderer 3ds Max enviro and Corona enviro have the same script name “bg_source”. How would it be possible to toggle these settings?
It’s not the result I’m after
Object isolates, Camera to perspective, HDRI loaded. from this point I need a toggle which unisolates, perspective to camera, Scene HDRI Loaded.
-Unisolate: “IsolateSelection.ExitIsolateSelectionMode()”
-Switch to camera view: “viewport.setType(#view_camera)”. However if you have multiple cameras you would get a prompt to choose a camera
-Scene HDRI: Depends where and how it is stored
But basically my approach would be to remember every change made without exception for reverting later (when releasing the button) so the button can be used for any scene without leaving traces behind. Meaning:
Button toggle on:
Save viewport type, save camera reference if it is a camera viewport. (See “viewport.getType()” and “viewport.getCamera()”)
(Maybe even save viewport layout and active viewport in case someone changes it during tweaking)
Save renderer environment setting (“renderers.current.bg_source”, can be 3dsMax (0), Corona single (1) or Corona multiple (2), this also answers your question about switching environment setting by script)
If you choose to always use 3dsmax env for tweaking and Corona env for rendering and renderers.current.bg_source is not set to 3ds max env and it’s empty, plug tweak map into 3ds max environment while saving the currently assigned one if present.
Save states of Corona overrides (“renderers.current.bg_overrideDirect/Refract/Reflect”) and switch them off
Optionally open SME, create a new tab “Tweaking” and fetch all materials from selected objects automatically (bonus task I would like to have
Isolate+zoom selection
Tweak
Button toggle off:
Delete SME tab “Tweaking” (bonus task)
Restore saved 3ds max env map if one was present
Restore saved renderer environment setting (see above)
Restore saved states of Corona overrides
Switch to saved viewport type, switch to saved camera if it has been a camera view ("“viewport.setType()” and “viewport.setCamera()”)
Unisolate
For personal/inhouse use you can of course simplify everything. As mentioned, I pretty much love the idea of having a “Let’s tweak this!” button, maybe I’ll give it a try someday.
Good Luck
Edit: 3dsMax (1), Corona single (2) or Corona multiple (3) → 3dsMax (0), Corona single (1) or Corona multiple (2)
Iv got to a point where my object is isolated and running interactive in perspective with a different hdri. Iv managed to set this up using a a single hotkey.
Reverting back should be easy as the scripts work visa versa. Only issues im having is making it toggle. Is there some toggle language im not understanding?
Good to read of progress As for your toggle issue: you have to remember yourself in which state your script currently is. I would do the whole thing as macroscript to use it as a button, but you can also assign it to a hotkey only. Here is a basic macro script to show how you could do it:
macroScript NeilCrossToggleTemplate
category:"NeilCross"
toolTip:"Toolbar Button Template"
icon:#("MaxScript",3)
(
--- remember everything here, also any variables/settings which have to be reverted later
local tweakingActive=false
on isEnabled do ( --- defines if the button/script is active
--- only be active if something is selected:
if selection.count > 0 then return true else return false
)
on isChecked do ( --- defines if the button is pressed
--- this is either true or false, suitable to return this directly:
return tweakingActive
)
on execute do ( --- someone pressed the button or the assigned hotkey
if tweakingActive==false then ( --- not tweaking currently
print "Preparing to tweak"
--- do everything to make it happen here
--- now we are in tweak mode, so:
tweakingActive=true
)
else ( --- tweaking currently
print "Reverting from tweak mode"
--- reverse/cleanup everything here
--- now we are out of tweak mode, so:
tweakingActive=false
)
)
)
Save it in your usermacros directory and you should find it in Customize → Customize User Interface → Toolbars (I would drag it to any toolbar unless it is finished for better access) → Category “NeilCross” - > Action “Toobar Button Template” → Drag it to some toolbar, right click and choose “Edit macro script” to start modifying.
More about all possible “on do” event handlers and what you can do inside them here:
Same here, I have a prototype (5% of work) in my toolbar, but those 95% work catching errors, special situations and some bugs (getRenderType() again…) and further testing is still missing. But since I want this for myself I will try to complete some first version asap and also post here.
Added this. You are now entirely free to use a preset for distinct VFB settings matching the environment or not, to change tone mapping settings during tweaking; all is saved and will revert back. This way the script can also be used to change into a (https://forum.corona-renderer.com/ index.php?topic=17712.0 ) with one click (and back of course).
v0.40 File Save/Reset/Open callbacks for resetting environment added
v0.35 Deepcopy of VFB parameters workaround (maxscript glitch), lightmix settings also revert after tweaking now. Catched possibly missing camera. ‘useEnvironmentMap’ fix/added. Undefined extended viewport types cause no error any more.
Hi,
(very useful script),
if in ligthmix I deactivated the enviroment, when I launch the script I see the black vfb, so I think it should automatically switch to the beauty of the vfb and come back to te ligthmix when close it.
… but this is not possible. There is no way to get the currently displayed channel index from Corona. So something which would not revert But I will add a parameter for autoswitching to beauty.