--------- '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:
MtlSelector_AnimatedIndex.max :
MtlSelector_Random.max :
MtlSelector_Texture.max :
Material Selector tutorial and samples
Forum rules
Please post only in English in this subforum. For alternate language discussion please go here http://render.otoy.com/forum/viewforum.php?f=18
Please post only in English in this subforum. For alternate language discussion please go here http://render.otoy.com/forum/viewforum.php?f=18
- neonZorglub
- Posts: 1005
- Joined: Sun Jul 31, 2016 10:08 pm
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
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
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
( so I'll copy paste, I'd prefer )

Thanks
YOKO Studio | win 10 64 | i7 5930K GTX 3090 | 3dsmax 2022.3 |
- neonZorglub
- Posts: 1005
- Joined: Sun Jul 31, 2016 10:08 pm
Sure: here it is: 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 ..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

Thanks NZ ! But to late... You already release RC3 and it works fine ! 

YOKO Studio | win 10 64 | i7 5930K GTX 3090 | 3dsmax 2022.3 |
- neonZorglub
- Posts: 1005
- Joined: Sun Jul 31, 2016 10:08 pm
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: 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: 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
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: 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: 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
- Posts: 1005
- Joined: Sun Jul 31, 2016 10:08 pm
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.
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.