HLSL Shading for 3dsMax 01 - Hello world

Purpose:
Create a HLSL Shader that just use a solid ambient color to shading the model in 3dsMax.

Solution:
1.Create a teapot in 3dsMax



2.Hit shotcut key 'm' to active Material Editor and choice DirectX Shader





3.Load our HLSL Shader file





4.Assign to teapot as a material



5.Adjust the AmbientColor we can see that the color of teapot change as well



Shader source:

float4x4 matViewProjection : WorldViewProjection;

float4 AmbientColor : AMBIENT
<
   string UIName = "AmbientColor";
> = float4( 1.00, 0.79, 0.68, 1.00 );

struct VS_INPUT 
{
	float4 Position : POSITION0;
};

struct VS_OUTPUT 
{
	float4 Position : POSITION0;
};

VS_OUTPUT vs_main( VS_INPUT Input )
{
	VS_OUTPUT Output;
	Output.Position = mul( Input.Position, matViewProjection );
   
	return Output ;
}

float4 ps_main() : COLOR0
{   
	return AmbientColor;
}

technique HelloWorld
{
   pass one
   {
      VertexShader = compile vs_2_0 vs_main();
      PixelShader = compile ps_2_0 ps_main();
   }
}

猜你喜欢

转载自yellowcxx.iteye.com/blog/2196749