Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - niljut

Pages: [1] 2
1
I made a version that adds a "ignore legacy materials" checkbox, which, unsurprisingly, ignores legacy materials.

https://gist.github.com/ejut/68f88069f7b2fbb4765d41a2803693fc

Download it and place the .ms file in C:\Program Files\Corona\Corona Renderer for 3ds Max\20XX\Scripts. Make a backup of the original, of course.

The only actual change besides the UI is to the convertSceneMtlsMaps function, from:

Code: [Select]
fn convertSceneMtlsMaps ErrorReport:true =(
...
for supportedMtlClassName in converterTempData.supportedMtlClassNames do ( -- Where supportedMtlClassName.creatable.
...
to
Code: [Select]
fn convertSceneMtlsMaps ErrorReport:true =(
...
local supportedMtlClassNames = copy converterTempData.supportedMtlClassNames #noMap

if matConvMethods.owner.converterSettings.ignoreLegacyMaterials == true do (
local idx = findItem supportedMtlClassNames "CoronaLegacyMtl"
if idx != 0 do (
deleteItem supportedMtlClassNames idx
)
)
for supportedMtlClassName in supportedMtlClassNames do ( -- Where supportedMtlClassName.creatable.
...

That said, all of the conversions being done are solid in theory, but fail due to incorrectly made materials. Learning why and how to avoid it is valuable.

2
What happened to the new color selector dialog? It was on the road map for version 7, then pushed to version 8, and now it's gone. I was unreasonably hyped for it. 😂

3
How set are the properties of the material? I don't have the opportunity to install the beta, but I would like to prepare some of my scripts for when it goes live. Could someone so kindly post the properties of the material class? Can be done by typing in Show CoronaPhysicalMaterial in the listener (assuming the class is named as such, otherwise Show $.material with an object selected that has the material applied should work, iirc)

4
General CG Discussion / Re: [Useful Scripts\Tools]
« on: 2020-05-19, 13:47:43 »
Hey guys !
Looking for a script that would allow me to move the object in a file to different layer without opening the file itself. Pretty much like you can change bitmap paths in a file in Connecter.
Any hints much appreciated !

That is not possible, unfortunately.

5
[Max] General Discussion / Re: Tonemapping - Plz Halp
« on: 2020-04-29, 08:36:37 »
Isn't there something futile about discussing color management at all with respect to Corona Renderer for 3ds Max? As I understand it, Max is not a color managed workspace, and if it's taken Autodesk like 7 years just to add a new spinner to the chamfer modifier, why should we even begin to expect that color management is going to appear(?)

https://makeanything.autodesk.com/3DSMAX/public-roadmap-25B1-201DB.html#rendering-future

It is definitely on their minds at least.

6
[Max] I need help! / Re: Corona Mask Manager (2020)
« on: 2020-04-18, 15:03:03 »
There are almost always numerous ways to improve scripts, but as long as it works as intended and is not unreasonably slow it's usually best to let it be. I was almost tempted to rewrite the entire script, but it wouldn't actually accomplish anything meaningful. :-)

If you're curious about optimizing the part you added, all you really need to check for is if there is at least one non hidden item with the material. Something like this:

Code: [Select]
for i=1 to theMaterials.count do
(
obj_list = (for o in Geometry where o.material == theMaterials[i] collect o)

if obj_list.count == 0 do continue

local hidden = true
for obj in obj_list while hidden == true do hidden = obj.isHidden
if hidden == true do continue

re.addrenderelement (CMasking_Mask())
theelement = re.getrenderelement (re.numrenderelements() - 1 )
theelement.elementName = ("alpha_" + theNames[i] as string)
theelement.nodesMonoOn = true
theelement.nodesMonoIncludeMod= true
theelement.nodesMono = obj_list;
obj_list=#()
--maskEls = append maskEls theelement.elementName
)

causes it to break out of the for loop the moment it finds a visible item with the material.

7
[Max] I need help! / Re: Corona Mask Manager (2020)
« on: 2020-04-17, 23:36:10 »
Looking at this briefly, adding this to line 172
Code: [Select]
if obj_list.count == 0 do continueIs enough to fix this issue, I think, making it skip the materials that are not directly assigned to any object.


Complete script:
Code: [Select]
/*
------------------------------------------------------------------------------------------------------
--> by Gabriel Sumner & durandal_1707 (big ThX for the original script structure and wireColor code)
--> timestamp: 23/05/15
-->Version 1.0 Alpha
-------------------------------------------------------------------------------------------------------
*/
/*Credits for code snippets (sorry if someone has been forgotten, his / her name shall be added here asap:
 > Dave Wortleys tutorial for the basis idea of adding renderElements: https://davewortley.wordpress.com/2012/06/22/making-render-element-masks/
 > Bobo "select object my material" : http://forums.cgsociety.org/archive/index.php/t-183739.html
 >
*/

/* known issues:
- only Corona materials are renamed to shorten the naming of the saved renderElement
- only poly geometry is supported: lines need to have an editPoly on top of the stack to be recognized; Groups are not supported
- if the "create mono masks" button is pressed several times the script keeps adding new render elements, no check for existing elements at the moment
- open / close script window is somewhat buggy, needs optimizin'...
*/

/* TODO: planed functions (everyone is welcome to change the script in any way / participate in the development ;) )
- check for existing elements and warn the user to create additional or replace the existing once
- delete all mono mask elements
- set different path for render elements
- set different file format for render elements
*/


(
--try(destroydialog wireColorByMatRollout)catch()   >> toDo dialog creation

re = maxOps.GetCurRenderElementMgr()

local theMaterials = for m in SceneMaterials collect m

/* Material Names List */
local theNames = for n in theMaterials collect n.name
/*Remove the word "Material" for easier file naming */
for i=1 to theNames.count do
(
try(
if i != undefined then
theNames[i] = replace theNames[i] (findstring theNames[i] "Material ") 10 ""
)catch()
)


local fixedPaletteColors = #
(
(color 255 0 0), /* 1 - RED */
(color 0 255 0), /* 2 - GREEN */
(color 0 0 255), /* 3 - BLUE */
(color 255 0 255), /* 4 - MAGENTA */
(color 255 255 0), /* 5 - YELLOW */
(color 0 255 255), /* 6 - CYAN */
(color 120 0 0), /* 7- DARK RED */
(color 0 120 0), /* 8 - DARK GREEN */
(color 0 0 120), /* 9 - DARK BLUE */
(color 120 0 120), /* 10 - DARK MAGENTA */
(color 120 120 0), /* 11 - DARK YELLOW */
(color 0 120 120), /* 12 - DARK CYAN */
(color 60 60 60), /* 13 - DARK GRAY */
(color 120 120 120), /* 14 - GRAY */
(color 255 255 255) /* 15 - WHITE */
)

struct materialWireColor
(
matRef, matName, wireColor
)

/* unique scene materials */
local sceneMats = #()
local sceneMatTags = #()

for sceneObject in (objects) do
(
if sceneObject.material != undefined then
appendIfUnique sceneMats sceneObject.material
)

/* pre-select wire colors from a fixed palette defined above */
for matIdx = 1 to  sceneMats.count do
(
local wireColor = (color 128 128 128)
if(matIdx <= fixedPaletteColors.count) then
wireColor = fixedPaletteColors[matIdx]

local matName = undefined
if sceneMats[matIdx].name != undefined then
matName = sceneMats[matIdx].name
else
matName = "unnamed_material_" + matIdx

append sceneMatTags (materialWireColor sceneMats[matIdx] matName wireColor)
)

/* Main UI */
global rofWireColors
rollout wireColorByMatRollout "Assign wire colors by material" width:340 height:320
(
listbox materialListBox "Scene materials" pos:[16,16] width:179 height:9 items:(for matTag in (sceneMatTags) collect matTag.matRef.name)
button assignColorsButton "Assign wire colors" pos:[50,160] width:235 height:40
--button createMonoMasksButton "Create mono masks" pos:[50,240] width:235 height:40
colorPicker wireColorPicker "" pos:[208,40] width:112 height:112
label lbl1 "Pick wire color" pos:[216,16] width:72 height:24

on wireColorByMatRollout open do
(
try
(
materialListBox.selection = 1
wireColorPicker.color = sceneMatTags[1].wireColor
)catch()
)

on materialListBox selected mlbSelIndex do
(
try
(
wireColorPicker.color = sceneMatTags[mlbSelIndex].wireColor
)catch()
)

on wireColorPicker changed newColor do
(
selMatIndex = materialListBox.selection
if selMatIndex != undefined then
sceneMatTags[selMatIndex].wireColor = newColor
)

on assignColorsButton pressed do
(
/*assign wire colors to objects based on their material */
for sceneObject in (objects) do
(
for sceneMatTag in (sceneMatTags) do
(
if sceneObject.material == sceneMatTag.matRef then
sceneObject.wireColor = sceneMatTag.wireColor
)
)
/* close UI */
try
(
closeRolloutFloater rofWireColors
) catch()
)
)
rollout monoMasksRollout "Generate Mono Masks for assigned sceneMats" width:340 height:260
(
button createMonoMasksButton "Create mono masks" pos:[5,10] width:150 height:40
button deleteAllMonoMasksButton "Delete all mono mask passes" pos:[180,10] width:150 height:40 enabled: false
on createMonoMasksButton pressed do
(
/*
--Materials List
theMaterials = for m in SceneMaterials collect m
--Material Names List
theNames = for n in theMaterials collect n.name
--Remove the word "Material" for easier file naming
for i=1 to theNames.count do
(
theNames[i] = replace theNames[i] (findstring theNames[i] "Material ") 10 ""
)
*/


for i=1 to theMaterials.count do
(
obj_list = (for o in Geometry where o.material == theMaterials[i] collect o)
if obj_list.count == 0 do continue
re.addrenderelement (CMasking_Mask())
theelement = re.getrenderelement (re.numrenderelements() - 1 )
theelement.elementName = ("Matte_" + theNames[i] as string)
theelement.nodesMonoOn = true
theelement.nodesMonoIncludeMod= true
theelement.nodesMono = obj_list;
obj_list=#()
--maskEls = append maskEls theelement.elementName
)

/*update  Render Setup Window */
if renderSceneDialog.isOpen()==true do
(
renderSceneDialog.close()
renderSceneDialog.open()
)

/*show  Render Setup Window */
renderSceneDialog.open()

/* close UI */
try
(
closeRolloutFloater rofWireColors
) catch()

)
/*
on deleteAllMonoMasksButton pressed do
(
)*/

)
/* prevent the user from opening more than one dialog at a time */
rollout miscRollout "Toolbox" width:340 height:260
(
label lbl1 "Select objects by mat" pos:[15,5] width:200 height:16
dropDownList matsDropDownList items:theNames
on matsDropDownList selected itm do
     select (for o in Geometry where o.material == theMaterials[itm] collect o)

label lbl2 "Set different path for render elements" pos:[15,55] width:200 height:16 enabled:false
editText edt1 "" pos:[10,75] width:200 height:25 enabled:false
button btn1 "Change path" pos:[220,75] width:85 height:25
enabled:false

label lbl3 "Set different file format for render elements" pos:[15,110] width:250 height:16 enabled:false
    dropdownList ddl_file_ext "" pos:[12,125] width:110 height:40 items:#(".avi", ".bmp", ".cin", ".eps", ".ps", ".exr", ".fxr", ".hdr", ".pic", ".jpg", ".png", ".rgb", ".rla", ".rpf", ".tga", ".tif", ".dds")enabled:false
)

rofWireColors = newRolloutFloater "Corona Mask Manager" 350 500
addRollout wireColorByMatRollout rofWireColors
addRollout monoMasksRollout rofWireColors
addRollout miscRollout rofWireColors


)

8
tutorials
https://vimeo.com/showcase/1514565 (old, but very thorough)
https://davewortley.wordpress.com/lessons/

cheat sheet
http://www.thecgschool.com/downloads/3DATS_MAXScript_Cheat_Sheet.pdf

docs
https://help.autodesk.com/view/3DSMAX/2020/ENU/?guid=GUID-F039181A-C072-4469-A329-AE60FF7535E7 or whichever version you're using. From my experience, later versions are almost exclusively better to script for compared to older ones.

The number one way I learned things after I got a handle of the basics was to look at other peoples' scripts and see how they did things. Anything named .ms is not encrypted, unlike .mse files, so they can be looked at. Look at scriptspot for simple scripts. Many are unencrypted, thankfully.

9
Just keep diffuse value between 41-230 for non-linear, like Corona Color Picker, and 5-203 for linear, like the standard 3ds Max color dialog. That's pretty much it. If you want 0.8, like for snow, you would have to input 0.8 for the RGB channels with sRGB unchecked, which gives 0.904 in value, since value does not currently respond to unchecking sRGB. Alternatively you can also use a CoronaColor node and put the value in Solid HDR Color values, with "Input values are in linear space" checked.

10
[Max] I need help! / Re: Shader: Glitter / Sequin (Pt.2)
« on: 2020-01-22, 17:29:57 »
I ended up modifying the Chaos Group flakes shader to add a randomized color output. I have no experience with OSL so I mostly just plugged in something that seems to have worked. Changing the material parameters have such a large impact on the final result

Code: [Select]
shader
flakes
(
float flake_scale = 10.0 [[ string description = "Smaller values zoom into the flake map, larger values zoom out" ]],
float flake_size = 0.5 [[ string description = "Relative size of the flakes" ]],
float flake_size_variance = 0.0 [[ string description = "0.0 makes all flakes the same size, 1.0 assigns random size between 0 and the given flake size" ]],
float flake_normal_orientation = 0.0 [[ string description = "Blend between the flake normals (0.0) and the surface normal (1.0)" ]],

output color NormalResult = 1.0,
output color ColorResult = 1.0,
output float alpha  = 1.0
)
{

float safe_flake_size_variance = clamp(flake_size_variance, 0.1, 1.0);

vector cellCenters[9] = {
vector( 0.5,  0.5,  0.0),
vector( 1.5,  0.5,  0.0),
vector( 1.5,  1.5,  0.0),
vector( 0.5,  1.5,  0.0),
vector(-0.5,  1.5,  0.0),
vector(-0.5,  0.5,  0.0),
vector(-0.5, -0.5,  0.0),
vector( 0.5, -0.5,  0.0),
vector( 1.5, -0.5,  0.0)
};

point position = vector(u, v, 0.0);
position = flake_scale * position;

point base = floor(position);

point nearestCell = point(0.0, 0.0, 1.0);
int nearestCellIndex = -1;
for(int cellIndex = 0; cellIndex < 9; ++cellIndex) {
point cellCenter = base + cellCenters[cellIndex];

vector centerOffset = cellnoise(cellCenter) * 2.0 - 1.0;
centerOffset[2] *= safe_flake_size_variance;
centerOffset = normalize(centerOffset);

cellCenter += 0.5 * centerOffset;

float cellDistance = distance(position, cellCenter);
if(cellDistance < flake_size && cellCenter[2] < nearestCell[2]) {
nearestCell = cellCenter;
nearestCellIndex = cellIndex;
}
}

NormalResult = color(0.5, 0.5, 1.0);
ColorResult = 0.0;
alpha = 0.0;

if (nearestCellIndex != -1) {
vector randomNormal = cellnoise(base + cellCenters[nearestCellIndex] + vector(0.0, 0.0, 1.5));
randomNormal = 2.0 * randomNormal - 1.0;
randomNormal = faceforward(randomNormal, I, randomNormal);
randomNormal = normalize(mix(randomNormal, vector(0.0, 0.0, 1.0), flake_normal_orientation));
ColorResult = color(cellnoise(base + cellCenters[nearestCellIndex]));
NormalResult = color(0.5*randomNormal[0]+0.5, 0.5*randomNormal[1]+0.5, randomNormal[2]);
alpha = 1.0;
}
}


11
[Max] I need help! / Re: Shader: Glitter / Sequin (Pt.2)
« on: 2020-01-22, 13:33:22 »
Here's a version based on my old shader using the Chaos Group's OSL flakes shader for random normal directions.



And here I'm substituting the OSL Noise (Gabor) shader entirely for the Chaos Group flakes one.


There are pros and cons to each one. Using only the Chaos Group Flakes shader has the benefit of the flakes lining up with the normal directions, the con is that the colors of the flakes are the same as their normal direction, so all the flakes with left-facing normal directions will have the same color.

I think I prefer the mix, the color variation is nice to have.

12
[Max] I need help! / Re: Shader: Glitter / Sequin (Pt.2)
« on: 2020-01-22, 10:18:21 »
That is probably the case, I'm on 2020. it's called OSL Noise (Gabor).

13
[Max] I need help! / Re: Shader: Glitter / Sequin (Pt.2)
« on: 2020-01-22, 10:02:33 »
This is the setup I used. Going to try the Chaosgroup shader!


14
[Max] I need help! / Re: Shader: Glitter / Sequin (Pt.2)
« on: 2020-01-21, 11:43:47 »
The OSL map Noise (Gabor) can be a pretty decent procedular map for stochastic flakes, I find. This is a quick test:


15
Work in Progress/Tests / Re: dubcats secret little hideout
« on: 2019-05-10, 11:44:09 »




and this is how you can emulate fStorms "Angle Affect" option in Corona





Can anyone explain this shader tree?
There seems to be no detail in this thread about what the corona colour node marked 1.8 is.
Ive tried to recreate this and that colour seems to do absolutely nothing.
To quote myself two posts ago:
I am fairly certain the CoronaColor is set to Solid HDR Color with 1.8 in R, G, and B, making the CoronaMix multiply your original glossiness values by 1.8x. This would make values above 141 go beyond 255, so the output has clamp enabled to bring those values down to 255.

The shader amplifies the glossiness at gracing angles, and yes it's subtle (most of the time).

Pages: [1] 2