Multimaterial: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Aesthetical update)
Line 1: Line 1:
 
{{SideTOC}}
 
=== Motivation, goal ===
===Motivation, goal===
   
   
MultiMaterial is shader that allows composition of textures used in material from multiple layers of common textures via defined mask.
MultiMaterial is shader that allows composition of textures used in material from multiple layers of common textures via defined mask.
Line 11: Line 10:
[[Image:multi.jpg|Multishader]]
[[Image:multi.jpg|Multishader]]


===Definition of individual stages in material===
=== Definition of individual stages in material ===


Material uses more than 8 stages (14) and must use alternative write for TexGen definition - with "class TexGenX".
Material uses more than 8 stages (14) and must use alternative write for TexGen definition - with "class TexGenX".
Line 17: Line 16:
Only first 3 SMDI maps may have own TexGen, fourth using TexGen identical with CO4. MC and AS maps using TexGen identical with mask.
Only first 3 SMDI maps may have own TexGen, fourth using TexGen identical with CO4. MC and AS maps using TexGen identical with mask.


====0-3 CO map====
==== 0-3 CO map ====


Usual CO maps - noteworthy is that it's using also stage 0. On the contrary in model it's awaited that no texture is assigned.
Usual CO maps - noteworthy is that it's using also stage 0. On the contrary in model it's awaited that no texture is assigned.
While model has also link to texture then it will multiple with stage 0 similarly to macro-map.
While model has also link to texture then it will multiple with stage 0 similarly to macro-map.


====4 MASK map====
==== 4 MASK map ====


Mask determining in RGB components mixing of separate layers.
Mask determining in RGB components mixing of separate layers.


====5-8 DTSMDI map====
==== 5-8 DTSMDI map ====


Map similar to SMDI map which keeps detail map inside R channel.
Map similar to SMDI map which keeps detail map inside R channel.


====9 MC map====
==== 9 MC map ====


Usual macro map - uses same texture coordinates as mask. Calculations with macro map in this shader is different than usual (so LERP with basic map).
Usual macro map - uses same texture coordinates as mask. Calculations with macro map in this shader is different than usual (so LERP with basic map).
Line 36: Line 35:
This technique was taken from mixing with satellite map which is done on terrain.
This technique was taken from mixing with satellite map which is done on terrain.


====10 AS map====
==== 10 AS map ====


Usual ambient map - uses same texture coordinates as mask.
Usual ambient map - uses same texture coordinates as mask.


====11-14 NO map====
==== 11-14 NO map ====


Usual NO maps.
Usual NO maps.


===Example===
=== Example ===


See [[Mondkalb's MultiMaterial Tutorial]] for a detailed walkthrough on how to implement the MultiMaterial.
See [[Mondkalb's MultiMaterial Tutorial]] for a detailed walkthrough on how to implement the MultiMaterial.
<syntaxhighlight lang="cpp">
ambient[]={1,1,1,1.000000};
diffuse[]={1,1,1,1.000000};
forcedDiffuse[]={0.000000,0.000000,0.000000,0.000000};
emmisive[]={0.000000,0.000000,0.000000,1.000000};
specular[]={1.000000,1.0000,1.00000,1.000000};
specularPower=100.000000;
PixelShaderID="Multi";
VertexShaderID="Multi";
class TexGen0
{
uvSource="tex";
};
class TexGen1
{
uvSource="tex";
};
class TexGen2
{
uvSource="tex";
};
class TexGen3
{
uvSource="tex";
};
class TexGen4
{
uvSource="tex";
};
class TexGen5
{
uvSource="tex";
};
class TexGen6
{
uvSource="tex";
};
class TexGen7
{
uvSource="tex";
};
class Stage0
{
texture="ca\MultiTest\kostky_CO.paa";
texGen=0;
};
class Stage1
{
texture="ca\MultiTest\oblaka_CO.paa";
texGen=1;
};
class Stage2
{
texture="#(rgba,8,8,3)color(0,0,0,1)";
texGen=2;
};
class Stage3
{
texture="#(rgba,8,8,3)color(0,0,0,1)";
texGen=3;
};
class Stage4
{
texture="ca\MultiTest\maska_MASK.paa";
texGen=4;
};
class Stage5
{
texture="ca\MultiTest\kostky_DTSMDI.paa";
texGen=5;
};
class Stage6
{
texture="ca\MultiTest\oblaka_DTSMDI.paa";
texGen=6;
};
class Stage7
{
texture="ca\MultiTest\kostky_DTSMDI.paa";
texGen=7;
};
class Stage8
{
texture="#(rgba,8,8,3)color(0.5,0,1,1)";
texGen=3;
};


ambient[]={1,1,1,1.000000};
class Stage9
diffuse[]={1,1,1,1.000000};
{
forcedDiffuse[]={0.000000,0.000000,0.000000,0.000000};
texture="#(rgba,8,8,3)color(1,1,1,0)"; // MC map
emmisive[]={0.000000,0.000000,0.000000,1.000000};
texGen=4;
specular[]={1.000000,1.0000,1.00000,1.000000};
};
specularPower=100.000000;
class Stage10
PixelShaderID="Multi";
{
VertexShaderID="Multi";
texture="#(rgba,8,8,3)color(0,1,1,1)"; // AS map
texGen=4;
class TexGen0
};
{
class Stage11
uvSource="tex";
{
};
texture="ca\MultiTest\kostky_NO.paa";
class TexGen1
texGen=0;
{
};
uvSource="tex";
class Stage12
};
{
class TexGen2
texture="ca\MultiTest\oblaka_NO.paa";
{
texGen=1;
uvSource="tex";
};
};
class Stage13
class TexGen3
{
{
texture="#(rgba,8,8,3)color(0.5,0.5,1,1)";
uvSource="tex";
texGen=2;
};
};
class TexGen4
class Stage14
{
{
uvSource="tex";
texture="#(rgba,8,8,3)color(0.5,0.5,1,1)";
};
texGen=3;
class TexGen5
};
{
</syntaxhighlight>
uvSource="tex";
};
class TexGen6
{
uvSource="tex";
};
class TexGen7
{
uvSource="tex";
};
class Stage0
{
texture="ca\MultiTest\kostky_CO.paa";
texGen=0;
};
class Stage1
{
texture="ca\MultiTest\oblaka_CO.paa";
texGen=1;
};
class Stage2
{
texture="#(rgba,8,8,3)color(0,0,0,1)";
texGen=2;
};
class Stage3
{
texture="#(rgba,8,8,3)color(0,0,0,1)";
texGen=3;
};
class Stage4
{
texture="ca\MultiTest\maska_MASK.paa";
texGen=4;
};
class Stage5
{
texture="ca\MultiTest\kostky_DTSMDI.paa";
texGen=5;
};
class Stage6
{
texture="ca\MultiTest\oblaka_DTSMDI.paa";
texGen=6;
};
class Stage7
{
texture="ca\MultiTest\kostky_DTSMDI.paa";
texGen=7;
};
class Stage8
{
texture="#(rgba,8,8,3)color(0.5,0,1,1)";
texGen=3;
};
class Stage9
{
texture="#(rgba,8,8,3)color(1,1,1,0)"; // MC map
texGen=4;
};
class Stage10
{
texture="#(rgba,8,8,3)color(0,1,1,1)"; // AS map
texGen=4;
};
class Stage11
{
texture="ca\MultiTest\kostky_NO.paa";
texGen=0;
};
class Stage12
{
texture="ca\MultiTest\oblaka_NO.paa";
texGen=1;
};
class Stage13
{
texture="#(rgba,8,8,3)color(0.5,0.5,1,1)";
texGen=2;
};
class Stage14
{
texture="#(rgba,8,8,3)color(0.5,0.5,1,1)";
texGen=3;
};


=== Alternate layout ===
=== Alternate layout ===
ambient[] = {1,1,1,1};
 
diffuse[] = {1,1,1,1};
<syntaxhighlight lang="cpp">
forcedDiffuse[] = {0,0,0,0};
ambient[] = {1,1,1,1};
emmisive[] = {0,0,0,1};
diffuse[] = {1,1,1,1};
specular[] = {1,1,1,1};
forcedDiffuse[] = {0,0,0,0};
specularPower = 50;
emmisive[] = {0,0,0,1};
PixelShaderID = "Multi";
specular[] = {1,1,1,1};
VertexShaderID = "Multi";
specularPower = 50;
// BLACK
PixelShaderID = "Multi";
class TexGen0 {uvSource="tex"; class uvTransform{aside[]={1,0,0}; up[]={0,1,0}; dir[]={0,0,1}; pos[]={0,0,0};};};
VertexShaderID = "Multi";
class TexGen5 {uvSource="tex"; class uvTransform{aside[]={1,0,0}; up[]={0,1,0}; dir[]={0,0,1}; pos[]={0,0,0};};};
// BLACK
class Stage0 {texture="#(argb,8,8,3)color(0,0,0,1,co)"; texGen="0";};
class TexGen0 {uvSource="tex"; class uvTransform{aside[]={1,0,0}; up[]={0,1,0}; dir[]={0,0,1}; pos[]={0,0,0};};};
class Stage5 {texture="#(argb,8,8,3)color(0.5,0,1,1,DTSMDI)"; texGen="5";};
class TexGen5 {uvSource="tex"; class uvTransform{aside[]={1,0,0}; up[]={0,1,0}; dir[]={0,0,1}; pos[]={0,0,0};};};
class Stage11 {texture="#(argb,8,8,3)color(0.5,0.5,1,1,NOHQ)"; texGen="0";};
class Stage0 {texture="#(argb,8,8,3)color(0,0,0,1,co)"; texGen="0";};
// RED
class Stage5 {texture="#(argb,8,8,3)color(0.5,0,1,1,DTSMDI)"; texGen="5";};
class TexGen1 {uvSource="tex"; class uvTransform{aside[]={1,0,0}; up[]={0,1,0}; dir[]={0,0,1}; pos[]={0,0,0};};};
class Stage11 {texture="#(argb,8,8,3)color(0.5,0.5,1,1,NOHQ)"; texGen="0";};
class TexGen6 {uvSource="tex"; class uvTransform{aside[]={1,0,0}; up[]={0,1,0}; dir[]={0,0,1}; pos[]={0,0,0};};};
// RED
class Stage1 {texture="#(argb,8,8,3)color(1,0,0,1,co)"; texGen="1";};
class TexGen1 {uvSource="tex"; class uvTransform{aside[]={1,0,0}; up[]={0,1,0}; dir[]={0,0,1}; pos[]={0,0,0};};};
class Stage6 {texture="#(argb,8,8,3)color(0.5,0,1,1,DTSMDI)"; texGen="6";};
class TexGen6 {uvSource="tex"; class uvTransform{aside[]={1,0,0}; up[]={0,1,0}; dir[]={0,0,1}; pos[]={0,0,0};};};
class Stage12 {texture="#(argb,8,8,3)color(0.5,0.5,1,1,NOHQ)"; texGen="1";};
class Stage1 {texture="#(argb,8,8,3)color(1,0,0,1,co)"; texGen="1";};
// GREEN
class Stage6 {texture="#(argb,8,8,3)color(0.5,0,1,1,DTSMDI)"; texGen="6";};
class TexGen2 {uvSource="tex"; class uvTransform{aside[]={1,0,0}; up[]={0,1,0}; dir[]={0,0,1}; pos[]={0,0,0};};};
class Stage12 {texture="#(argb,8,8,3)color(0.5,0.5,1,1,NOHQ)"; texGen="1";};
class TexGen7 {uvSource="tex"; class uvTransform{aside[]={1,0,0}; up[]={0,1,0}; dir[]={0,0,1}; pos[]={0,0,0};};};
// GREEN
class Stage2 {texture="#(argb,8,8,3)color(0,1,0,1,co)"; texGen="2";};
class TexGen2 {uvSource="tex"; class uvTransform{aside[]={1,0,0}; up[]={0,1,0}; dir[]={0,0,1}; pos[]={0,0,0};};};
class Stage7 {texture="#(argb,8,8,3)color(0.5,0,1,1,DTSMDI)"; texGen="7";};
class TexGen7 {uvSource="tex"; class uvTransform{aside[]={1,0,0}; up[]={0,1,0}; dir[]={0,0,1}; pos[]={0,0,0};};};
class Stage13 {texture="#(argb,8,8,3)color(0.5,0.5,1,1,NOHQ)"; texGen="2";};
class Stage2 {texture="#(argb,8,8,3)color(0,1,0,1,co)"; texGen="2";};
// BLUE
class Stage7 {texture="#(argb,8,8,3)color(0.5,0,1,1,DTSMDI)"; texGen="7";};
class TexGen3 {uvSource="tex"; class uvTransform{aside[]={1,0,0}; up[]={0,1,0}; dir[]={0,0,1}; pos[]={0,0,0};};};
class Stage13 {texture="#(argb,8,8,3)color(0.5,0.5,1,1,NOHQ)"; texGen="2";};
class Stage3 {texture="#(argb,8,8,3)color(0,0,1,1,co)"; texGen="3";};
// BLUE
class Stage8 {texture="#(argb,8,8,3)color(0.5,0,1,1,DTSMDI)"; texGen="3";};
class TexGen3 {uvSource="tex"; class uvTransform{aside[]={1,0,0}; up[]={0,1,0}; dir[]={0,0,1}; pos[]={0,0,0};};};
class Stage14 {texture="#(argb,8,8,3)color(0.5,0.5,1,1,NOHQ)"; texGen="3";};
class Stage3 {texture="#(argb,8,8,3)color(0,0,1,1,co)"; texGen="3";};
// MASK, MC, AS/ADS
class Stage8 {texture="#(argb,8,8,3)color(0.5,0,1,1,DTSMDI)"; texGen="3";};
class TexGen4 {uvSource="tex1"; class uvTransform{aside[]={1,0,0}; up[]={0,1,0}; dir[]={0,0,1}; pos[]={0,0,0};};};
class Stage14 {texture="#(argb,8,8,3)color(0.5,0.5,1,1,NOHQ)"; texGen="3";};
class Stage4 {texture="#(argb,8,8,3)color(1,0,0,1,Mask)"; texGen="4";};
// MASK, MC, AS/ADS
class Stage9 {texture="#(argb,8,8,3)color(0,0,0,0,MC)"; texGen="4";};
class TexGen4 {uvSource="tex1"; class uvTransform{aside[]={1,0,0}; up[]={0,1,0}; dir[]={0,0,1}; pos[]={0,0,0};};};
class Stage10 {texture="#(argb,8,8,3)color(1,1,1,1,ADS)"; texGen="4";};
class Stage4 {texture="#(argb,8,8,3)color(1,0,0,1,Mask)"; texGen="4";};
class Stage9 {texture="#(argb,8,8,3)color(0,0,0,0,MC)"; texGen="4";};
class Stage10 {texture="#(argb,8,8,3)color(1,1,1,1,ADS)"; texGen="4";};
</syntaxhighlight>


== Multimaterial for Autodesk 3DS MAX ==
== Multimaterial for Autodesk 3DS MAX ==


=== Shader settings ===
=== Shader settings ===
* see above^
  // Get the mask content
  half3 mask = tex2D(sampler4, input.tMSK_DT0.xy);
  // Get the masked CO map
  half3 mCO = tex2D(sampler0, co0.xy).rgb;
  mCO = lerp(mCO, tex2D(sampler1, co1.xy).rgb, mask.r);
  mCO = lerp(mCO, tex2D(sampler2, co2.xy).rgb, mask.g);
  mCO = lerp(mCO, tex2D(sampler3, co3.xy).rgb, mask.b);
  // Get the masked avg CO map
  half3 mCOavg = tex2Dlod(sampler0, co0).rgb;
  mCOavg = lerp(mCOavg, tex2Dlod(sampler1, co1).rgb, mask.r);
  mCOavg = lerp(mCOavg, tex2Dlod(sampler2, co2).rgb, mask.g);
  mCOavg = lerp(mCOavg, tex2Dlod(sampler3, co3).rgb, mask.b);
  // Sample the macro map
  half4 macro = tex2D(sampler9, input.tMSK_DT0.xy);
  // Modify the base color by macro map (the same turn is used in Terrain shader)
  half3 adjust = (macro.rgb/mCOavg);
  adjust = min(2,max(adjust,0));
  mCO = lerp(mCO, mCO * adjust, macro.a) ;
  // Calculate the color
  fout.color.rgb = mCO * mSMDI.r * 2.0;
  fout.color.a = 1;


* along this setting You can create other shaders for another programs
See above ^
<syntaxhighlight lang="cpp">
// Get the mask content
half3 mask = tex2D(sampler4, input.tMSK_DT0.xy);
// Get the masked CO map
half3 mCO = tex2D(sampler0, co0.xy).rgb;
mCO = lerp(mCO, tex2D(sampler1, co1.xy).rgb, mask.r);
mCO = lerp(mCO, tex2D(sampler2, co2.xy).rgb, mask.g);
mCO = lerp(mCO, tex2D(sampler3, co3.xy).rgb, mask.b);
// Get the masked avg CO map
half3 mCOavg = tex2Dlod(sampler0, co0).rgb;
mCOavg = lerp(mCOavg, tex2Dlod(sampler1, co1).rgb, mask.r);
mCOavg = lerp(mCOavg, tex2Dlod(sampler2, co2).rgb, mask.g);
mCOavg = lerp(mCOavg, tex2Dlod(sampler3, co3).rgb, mask.b);
// Sample the macro map
half4 macro = tex2D(sampler9, input.tMSK_DT0.xy);
// Modify the base color by macro map (the same turn is used in Terrain shader)
half3 adjust = (macro.rgb/mCOavg);
adjust = min(2,max(adjust,0));
mCO = lerp(mCO, mCO * adjust, macro.a) ;
// Calculate the color
fout.color.rgb = mCO * mSMDI.r * 2.0;
fout.color.a = 1;
</syntaxhighlight>
along this setting You can create other shaders for another programs


=== Progress ===
=== Progress ===
Line 276: Line 281:




==External links==
== External links ==
* [http://en.wikipedia.org/wiki/Lerp_(computing) LERP] , wikipedia
* [http://en.wikipedia.org/wiki/Lerp_(computing) LERP] , wikipedia


[[Category:ArmA 2: Editing]]
[[Category:ArmA 2: Editing]]

Revision as of 15:21, 1 April 2019

Template:SideTOC

Motivation, goal

MultiMaterial is shader that allows composition of textures used in material from multiple layers of common textures via defined mask. Primary purpose is reducing number of sections, thus on surface which mixes multiple materials is needed only one material to combine them all - rendering pass in just one call. Advantage of using MultiMaterial is similar like with landscape (technology is similar) - saves textures, higher detail, prevents repeating. There is no Fresnel for specularity so it is not that valuable for glossy surfaces. Name of this new shader (vertex as well as pixel) is "Multi".

Multishader

Definition of individual stages in material

Material uses more than 8 stages (14) and must use alternative write for TexGen definition - with "class TexGenX". Details are visible in example. All CO maps may have own TexGen. Mask may have own text gen naturally too. Only first 3 SMDI maps may have own TexGen, fourth using TexGen identical with CO4. MC and AS maps using TexGen identical with mask.

0-3 CO map

Usual CO maps - noteworthy is that it's using also stage 0. On the contrary in model it's awaited that no texture is assigned. While model has also link to texture then it will multiple with stage 0 similarly to macro-map.

4 MASK map

Mask determining in RGB components mixing of separate layers.

5-8 DTSMDI map

Map similar to SMDI map which keeps detail map inside R channel.

9 MC map

Usual macro map - uses same texture coordinates as mask. Calculations with macro map in this shader is different than usual (so LERP with basic map). With macro map we aim to influence only median/average color in the given place - thus original layers aren't overlapped. This technique was taken from mixing with satellite map which is done on terrain.

10 AS map

Usual ambient map - uses same texture coordinates as mask.

11-14 NO map

Usual NO maps.

Example

See Mondkalb's MultiMaterial Tutorial for a detailed walkthrough on how to implement the MultiMaterial.

ambient[]={1,1,1,1.000000};
diffuse[]={1,1,1,1.000000};
forcedDiffuse[]={0.000000,0.000000,0.000000,0.000000};
emmisive[]={0.000000,0.000000,0.000000,1.000000};
specular[]={1.000000,1.0000,1.00000,1.000000};
specularPower=100.000000;
PixelShaderID="Multi";
VertexShaderID="Multi";

class TexGen0
{
	uvSource="tex";
};
class TexGen1
{
	uvSource="tex";
};
class TexGen2
{
	uvSource="tex";
};
class TexGen3
{
	uvSource="tex";
};
class TexGen4
{
	uvSource="tex";
};
class TexGen5
{
	uvSource="tex";
};
class TexGen6
{
	uvSource="tex";
};
class TexGen7
{
	uvSource="tex";
};

class Stage0
{
	texture="ca\MultiTest\kostky_CO.paa";
	texGen=0;
};
class Stage1
{
	texture="ca\MultiTest\oblaka_CO.paa";
	texGen=1;
};
class Stage2
{
	texture="#(rgba,8,8,3)color(0,0,0,1)";
	texGen=2;
};
class Stage3
{
	texture="#(rgba,8,8,3)color(0,0,0,1)";
	texGen=3;
};
class Stage4
{
	texture="ca\MultiTest\maska_MASK.paa";
	texGen=4;
};
class Stage5
{
	texture="ca\MultiTest\kostky_DTSMDI.paa";
	texGen=5;
};
class Stage6
{
	texture="ca\MultiTest\oblaka_DTSMDI.paa";
	texGen=6;
};
class Stage7
{
	texture="ca\MultiTest\kostky_DTSMDI.paa";
	texGen=7;
};
class Stage8
{
	texture="#(rgba,8,8,3)color(0.5,0,1,1)";
	texGen=3;
};

class Stage9
{
	texture="#(rgba,8,8,3)color(1,1,1,0)"; // MC map
	texGen=4;
};
class Stage10
{
	texture="#(rgba,8,8,3)color(0,1,1,1)"; // AS map
	texGen=4;
};
class Stage11
{
	texture="ca\MultiTest\kostky_NO.paa";
	texGen=0;
};
class Stage12
{
	texture="ca\MultiTest\oblaka_NO.paa";
	texGen=1;
};
class Stage13
{
	texture="#(rgba,8,8,3)color(0.5,0.5,1,1)";
	texGen=2;
};
class Stage14
{
	texture="#(rgba,8,8,3)color(0.5,0.5,1,1)";
	texGen=3;
};

Alternate layout

ambient[]		= {1,1,1,1};
diffuse[]		= {1,1,1,1};
forcedDiffuse[]	= {0,0,0,0};
emmisive[]		= {0,0,0,1};
specular[]		= {1,1,1,1};
specularPower	= 50;
PixelShaderID	= "Multi";
VertexShaderID	= "Multi";
// BLACK
class TexGen0 	{uvSource="tex";	class uvTransform{aside[]={1,0,0};	up[]={0,1,0};	dir[]={0,0,1};	pos[]={0,0,0};};};
class TexGen5 	{uvSource="tex";	class uvTransform{aside[]={1,0,0};	up[]={0,1,0};	dir[]={0,0,1};	pos[]={0,0,0};};};
class Stage0	{texture="#(argb,8,8,3)color(0,0,0,1,co)";										texGen="0";};
class Stage5	{texture="#(argb,8,8,3)color(0.5,0,1,1,DTSMDI)";								texGen="5";};
class Stage11	{texture="#(argb,8,8,3)color(0.5,0.5,1,1,NOHQ)";								texGen="0";};
// RED
class TexGen1 	{uvSource="tex";	class uvTransform{aside[]={1,0,0};	up[]={0,1,0};	dir[]={0,0,1};	pos[]={0,0,0};};};
class TexGen6 	{uvSource="tex";	class uvTransform{aside[]={1,0,0};	up[]={0,1,0};	dir[]={0,0,1};	pos[]={0,0,0};};};
class Stage1	{texture="#(argb,8,8,3)color(1,0,0,1,co)";										texGen="1";};
class Stage6	{texture="#(argb,8,8,3)color(0.5,0,1,1,DTSMDI)";								texGen="6";};
class Stage12	{texture="#(argb,8,8,3)color(0.5,0.5,1,1,NOHQ)";								texGen="1";};
// GREEN
class TexGen2 	{uvSource="tex";	class uvTransform{aside[]={1,0,0};	up[]={0,1,0};	dir[]={0,0,1};	pos[]={0,0,0};};};
class TexGen7 	{uvSource="tex";	class uvTransform{aside[]={1,0,0};	up[]={0,1,0};	dir[]={0,0,1};	pos[]={0,0,0};};};
class Stage2	{texture="#(argb,8,8,3)color(0,1,0,1,co)";										texGen="2";};
class Stage7	{texture="#(argb,8,8,3)color(0.5,0,1,1,DTSMDI)";								texGen="7";};
class Stage13	{texture="#(argb,8,8,3)color(0.5,0.5,1,1,NOHQ)";								texGen="2";};
// BLUE
class TexGen3 	{uvSource="tex";	class uvTransform{aside[]={1,0,0};	up[]={0,1,0};	dir[]={0,0,1};	pos[]={0,0,0};};};
class Stage3	{texture="#(argb,8,8,3)color(0,0,1,1,co)";										texGen="3";};
class Stage8	{texture="#(argb,8,8,3)color(0.5,0,1,1,DTSMDI)";								texGen="3";};
class Stage14	{texture="#(argb,8,8,3)color(0.5,0.5,1,1,NOHQ)";								texGen="3";};
// MASK, MC, AS/ADS
class TexGen4 	{uvSource="tex1";	class uvTransform{aside[]={1,0,0};	up[]={0,1,0};	dir[]={0,0,1};	pos[]={0,0,0};};};
class Stage4	{texture="#(argb,8,8,3)color(1,0,0,1,Mask)";									texGen="4";};
class Stage9	{texture="#(argb,8,8,3)color(0,0,0,0,MC)";										texGen="4";};
class Stage10	{texture="#(argb,8,8,3)color(1,1,1,1,ADS)";										texGen="4";};

Multimaterial for Autodesk 3DS MAX

Shader settings

See above ^

// Get the mask content
half3 mask = tex2D(sampler4, input.tMSK_DT0.xy);
// Get the masked CO map
half3 mCO = tex2D(sampler0, co0.xy).rgb;
mCO = lerp(mCO, tex2D(sampler1, co1.xy).rgb, mask.r);
mCO = lerp(mCO, tex2D(sampler2, co2.xy).rgb, mask.g);
mCO = lerp(mCO, tex2D(sampler3, co3.xy).rgb, mask.b);
// Get the masked avg CO map
half3 mCOavg = tex2Dlod(sampler0, co0).rgb;
mCOavg = lerp(mCOavg, tex2Dlod(sampler1, co1).rgb, mask.r);
mCOavg = lerp(mCOavg, tex2Dlod(sampler2, co2).rgb, mask.g);
mCOavg = lerp(mCOavg, tex2Dlod(sampler3, co3).rgb, mask.b);
// Sample the macro map
half4 macro = tex2D(sampler9, input.tMSK_DT0.xy);
// Modify the base color by macro map (the same turn is used in Terrain shader)
half3 adjust = (macro.rgb/mCOavg);
adjust = min(2,max(adjust,0));
mCO = lerp(mCO, mCO * adjust, macro.a) ;
// Calculate the color
fout.color.rgb = mCO * mSMDI.r * 2.0;
fout.color.a = 1;

along this setting You can create other shaders for another programs

Progress

Needed Filters / Plugins

Pre-defined material 3DMAX

  • now is available script which creates material by defined values
  • it can read data from RVMATs
  • works only for MENTALRAY
  • You may find script on address
    • someURL://VM_MultiShader.mcr
  • it's MacroSkript
    • load into 3DMAX\UI\MacroScripts\
    • run MAX
    • v CUSTOMIZE -> CUSTOMIZE USER INTERFACE -> TOOLBARS -> CATEGORY = "VM's" -> "MULTISHADER"
  • with help of "Render To Texture" -> render resulting Diffuse channel
SCRIPT CONTROL PANEL PREVIEW
  • Each texture is named TYPE_CHANNEL
  • non-filled or incorrectly-filled texturs aren't created (default settings will be used)
    • then there is no problem with entering procedural textures


Material settings preview through script
  • in slot Diffuse is saved entire color -> baked material
  • in slot Ambient is saved DTSMDI information for entire material (Ambient because it wasn't possible otherway)
  • in slot Bump is NOHQ information for entire material
  • all slots ready for bake


Step by Step

  • run script
  • fill corresponding cells for textures
    • or load RVMAT (works only for MultiShader materials)
  • click onto Create Multimaterial
  • material will be autocreated inside Material Editor
  • Bake standalone "DIFFUSE"(colormap) ,standalone "NORMAL"(normalmap) and standalone "AMBIENT"(through BLEND)(DTSMDI)


External links