[3dsMax][DirectX Shader] Technique

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Search this Thread Display Modes
  03 March 2017
[3dsMax][DirectX Shader] Technique

Hi,
I'm learning to create DirectX shaders in 3dsMax, I want to have a shader with two different technique. For example first technique will render the object with the texture and second texture would change it's color. I have both technique working as I want, but when I switch between them using the Technique dropdown in the material editor the technique stay the same, it doesn't switch to my other technique.

The shader looks like this:
[CODE]//////////////////////////////////////////////////
//Replicates HOE Detail shader
// Channel 1 is palette COLOR
// Channel 4 is Detail Texture
//////////////////////////////////////////////////

float4x4 WorldViewProj : WORLDVIEWPROJ;

// tweakables

texture diffuseTexture : DiffuseMap<
string UIName = "Diffuse Texture";
int Texcoord = 0;
int MapChannel = 1;
>;

texture DetailTexture : LightMap <
string UIName = "Detail Texture";
int Texcoord = 1;
int MapChannel = 4;
>;

texture MaskTexture : DiffuseMap <
string UIName = "Mask Texture";
int Texcoord = 0;
int MapChannel = 1;
>;

sampler DiffuseSampler = sampler_state
{
Texture = (diffuseTexture);
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
ADDRESSU = WRAP;
ADDRESSV = WRAP;
};


sampler DetailSampler = sampler_state
{
Texture = (DetailTexture);
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
ADDRESSU = WRAP;
ADDRESSV = WRAP;
};


sampler MaskSampler = sampler_state
{
Texture = (MaskTexture);
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
ADDRESSU = WRAP;
ADDRESSV = WRAP;
};


struct appdata
{
float3 vertex : POSITION;
//loat3 normal : NORMAL;
float2 DiffuseTex : TEXCOORD0;
float2 DetailTex : TEXCOORD1;
};

struct v2f
{
float4 oPos : POSITION;
float2 texcoord : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};


v2f VS(appdata v)
{
v2f o;
// Note: please use WORLDVIEWPROJ instead of WORLDVIEW and PROJECTION to avoid z-fighting in 3ds Max
o.oPos = mul(float4(v.vertex,1),WorldViewProj); // position (projected)
o.texcoord = v.DiffuseTex; // Diffuse UV
o.texcoord1 = v.DetailTex; // Detail UV

return o;
}

float4 fragOverlay(v2f i) : COLOR
{

float4 diff = tex2D(DiffuseSampler, i.texcoord);
float4 details = tex2D(DetailSampler, i.texcoord1);
float4 mask = tex2D(MaskSampler,i.texcoord);

float3 detailedColor = (diff.rgb + (details * 2.0)-1.0);

float4 c;
c.rgb = lerp(diff.rgb,detailedColor,mask.b);
c.a = 1.0;

return c ;

}

float4 fragMul(v2f i) : COLOR
{

return float4(1,0,0,1);
}

technique Overlay
{
pass P0
{
CullMode = CW;
ZEnable = true;
ZWriteEnable = true;
ZFunc = LessEqual;

VertexShader = compile vs_2_0 VS();
PixelShader = compile ps_2_0 fragOverlay();
}
}


technique Multiply
{
pass P0
{
CullMode = CW;
ZEnable = true;
ZWriteEnable = true;
ZFunc = LessEqual;

VertexShader = compile vs_2_0 VS();
PixelShader = compile ps_2_0 fragMul();
}
}
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 06:37 PM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.