Material Selector tutorial and samples

Forums: Material Selector tutorial and samples
3D Studio Max Plugin (Export Script Plugins developed by [gk] and KilaD; Integrated Plugin developed by Karba)
Forum rules
Please post only in English in this subforum. For alternate language discussion please go here viewforum.php?f=18

Material Selector tutorial and samples

Postby neonZorglub » Fri Oct 28, 2022 4:37 am

neonZorglub Fri Oct 28, 2022 4:37 am
--------- 'Material Selector' material ----------
(From version 2021.1.6 - 12.28 and 2022.1 RC1 - 13.09)

* Avoid 'Material' modifier
The main purpose is to avoid adding a 'Material' modifier in the geometry.
The material modifier allows to select a material from a Multi-material by material ID.

But when the material ID from the modifier is animated, this forces Octane to read the full mesh every frame, as the object is considered having a geometry animation.
For better performance, you can use the 'Material Selector' material.

* How it works
The 'Material Selector' is a wrapper that uses the Octane Composite material.
It gather materials from a standard Multi-material, and set the mask for each material so only 1 is visible.
There are 2 custom osl shaders used to compare material indices.

Note that is uses material index of the multi-material, not material IDs
Material are selected by their index, from 1 to the material count.

* Additional features

- Random material
Set the Selection type to 'Random'
Use the seed parameter to generate different random distribution.
Internally using an Octane Random Color texture, this generates values that are used to select one of the material.

- Generic Octane texture.
Set the Selection type to 'Texture'
Any texture can be used to select one of the materials.
A grey scale texture, with ranging output from (0,1) will select a material in the range (1, material count)
For color textures, you can specify the color channel to use, or All to consider all the rgb channels.

Here are some samples:
Samples_MaterialSelector.zip
(277.95 KiB) Downloaded 89 times


MtlSelector_AnimatedIndex.max :
MtlSel_AnimatedIndex_fr0.png

MtlSel_AnimatedIndex_fr29.png


MtlSelector_Random.max :
MtlSel_Random.png


MtlSelector_Texture.max :
MtlSel_Texture.png
neonZorglub
OctaneRender Team
OctaneRender Team
 
Posts: 899
Joined: Sun Jul 31, 2016 10:08 pm

Re: Material Selector tutorial and samples

Postby neonZorglub » Wed Nov 16, 2022 1:24 am

neonZorglub Wed Nov 16, 2022 1:24 am
Note: There seems to be some issue when creating a new Material Selector material.

In some case, the osl shader files may not be copied to the correct location.

A work around is to open the Octane Preferences, Material tab:
-Set Preset Material Location to 3dsMax user Scene folder.
-Open Octane viewport
-Click the Rebuild all button.

-Close Octane viewport
-Set Preset Material Location to Current max file folder.
-Open Octane viewport
-Click the Rebuild all button.

You can check if the osl files are correctly created after those steps:
-Open the current max file folder (Octane menu, 'Explore scene folder')
There should be a folder 'OctanePreset', and 2 osl files inside: #IndexAsColor.osl, #MaskSwitcher.osl
neonZorglub
OctaneRender Team
OctaneRender Team
 
Posts: 899
Joined: Sun Jul 31, 2016 10:08 pm

Re: Material Selector tutorial and samples

Postby HHbomb » Thu Nov 17, 2022 10:14 am

HHbomb Thu Nov 17, 2022 10:14 am
Hi, NZ in the meantime you fix the problem, could you give us a folder 'OctanePreset' with the 2 osl files inside: #IndexAsColor.osl, #MaskSwitcher.osl and the right place related to the scene file ?
( so I'll copy paste, I'd prefer ) :-)
Thanks
YOKO Studio | win 10 64 | i7 5930K GTX 3090 | 3dsmax 2022.3 |
HHbomb
Licensed Customer
Licensed Customer
 
Posts: 1307
Joined: Wed Jun 30, 2010 8:45 pm

Re: Material Selector tutorial and samples

Postby neonZorglub » Mon Nov 21, 2022 9:27 pm

neonZorglub Mon Nov 21, 2022 9:27 pm
HHbomb wrote:Hi, NZ in the meantime you fix the problem, could you give us a folder 'OctanePreset' with the 2 osl files inside: #IndexAsColor.osl, #MaskSwitcher.osl and the right place related to the scene file ?
( so I'll copy paste, I'd prefer ) :-)
Thanks


Sure: here it is:
MaterialSelector_withOSLs.zip
(279.02 KiB) Downloaded 72 times


You may also try copy the 2 osl files at the same level as the max files.. 3dsMax has it's weird ways to find or not find asset files .. ;)
neonZorglub
OctaneRender Team
OctaneRender Team
 
Posts: 899
Joined: Sun Jul 31, 2016 10:08 pm

Re: Material Selector tutorial and samples

Postby HHbomb » Tue Nov 22, 2022 8:55 am

HHbomb Tue Nov 22, 2022 8:55 am
Thanks NZ ! But to late... You already release RC3 and it works fine ! :mrgreen:
YOKO Studio | win 10 64 | i7 5930K GTX 3090 | 3dsmax 2022.3 |
HHbomb
Licensed Customer
Licensed Customer
 
Posts: 1307
Joined: Wed Jun 30, 2010 8:45 pm

Re: Material Selector tutorial and samples

Postby neonZorglub » Thu Feb 23, 2023 2:31 am

neonZorglub Thu Feb 23, 2023 2:31 am
UPDATE (from 13.16) : Addition of the 'Material Index' generator.
To apply materials from a multi material using the Material selector, the Octane Geometry Modifier has options to generate the appropriate vertex attribute.
The use of Material ID ('Mtl ID') as vertex attribute can gives incorrect values.
It is preferable to use the new Generator mode 'Mtl Index'.


The 'Grayscale vertex attribute' texture is used to read values based of the material ID of the mesh
This match the 'Mtl Index' that must be set in the Octane Geometry Modifier, and both are set with the 'MaterialIndex' attribute name.

This creates grey values from dark grey to white, that can be used in various ways, especially as selection method in the 'Material Selector' material.

Here are some updated samples:
MaterialIndexSamples.zip
(620.14 KiB) Downloaded 53 times


Blended_multiMtl08.max:
Plane materials, as seen from top to bottom:
-Plane002 : a default multi materials with simple colored materials
-Plane004 : the 'Grayscale vertex attribute' set as diffuse texture
-Plane003 : a Mix material with a Material selector and multi material to select 6 colored materials, mixed with a material with a Marble texture


MaterialIndexSamples03.max:
MaterialIndexSample03.png

Plane materials, as seen from top to bottom:
-Plane002 : a default multi materials with simple colored materials
-Plane004 : the 'Grayscale vertex attribute' set as diffuse texture
-Plane006 : a Mix material with a Material selector and multi material to select 6 colored materials, mixed with a material with a Marble texture
-Plane003 : the 'Grayscale vertex attribute' used as input of a Gradient texture
-Plane007 : a Specular material with the 'Grayscale vertex attribute' used as Transmission
-Plane009 : a default multi materials with 6 textured materials
-Plane010 : a Mix materials mixing 2 Material selectors
neonZorglub
OctaneRender Team
OctaneRender Team
 
Posts: 899
Joined: Sun Jul 31, 2016 10:08 pm

Re: Material Selector tutorial and samples

Postby neonZorglub » Mon Mar 04, 2024 12:11 am

neonZorglub Mon Mar 04, 2024 12:11 am
Another sample to illustrate the use of the Material Selector as an Octane interface to the 3dsmax Multi material.

For example, the Octane Mix material takes 2 Octane materials as input.
Using a Multi material as one of the input is not directly possible, as it's not an Octane material.
We can achieve the same thing by using a Material Selector instead.
The Material Selector will contain the Multi material, and will use the material index of the object to display the corresponding mixed material.

Blended_multiMtl07.png


Blended_multiMtl07.zip
(92.14 KiB) Downloaded 12 times
neonZorglub
OctaneRender Team
OctaneRender Team
 
Posts: 899
Joined: Sun Jul 31, 2016 10:08 pm

Return to Autodesk 3Ds Max


Who is online

Users browsing this forum: No registered users and 31 guests

Sat Apr 27, 2024 5:38 am [ UTC ]