Phone Shader

//UI interface
float4 AmbientColor : Ambient
<
  string UIName = "Ambient";
> = (0.25f,0.25f,0.25f,0.1f);

float4 DiffuseColor : Diffuse
<
  string UIName = "Diffuse";
> = (0.25f,0.25f,0.25f,0.1f);

texture diffuseMap : DiffuseMap
<
   string name = "defaut";
   string UIName = "Diffuse Textrue";
   string TextureType = "2D";
>;
texture normalMap : NormalMap
<
    string name = "default_bump_normal.dds";
 string UIName = "Normal Map";
    string TextureType = "2D";
>;


float4 light1Pos : POSITION
<
 string UIName = "Light Position";
 string Object = "PointLight";
 string Space = "World";
 int refID = 0;
> = {100.0f, 100.0f, 100.0f, 0.0f};

float4 light1Color : LIGHTCOLOR
<
 int LightRef = 0;
> = { 1.0f, 1.0f, 1.0f, 0.0f };

/****************************************************/
/********** SAMPLERS ********************************/
/****************************************************/

sampler2D diffuseMapSampler = sampler_state
{
 Texture = <diffuseMap>;
 MinFilter = Linear;
 MagFilter = Linear;
 MipFilter = Anisotropic;
 ADDRESSU = WRAP;
    ADDRESSV = WRAP;
};

sampler2D normalMapSampler = sampler_state
{
 Texture = <normalMap>;
 MinFilter = Linear;
 MagFilter = Linear;
 MipFilter = Anisotropic;
 ADDRESSU = WRAP;
    ADDRESSV = WRAP;
};

float4x4 WorldViewProj : WorldViewProjection< string UIWidget = "None"; >;
float4x4 World      :   WORLD< string UIWidget = "None"; >;


struct VS_out
{
 float4 oposition : POSITION;
 float3 onormal : NORMAL;
 float2 otexcoord : TEXCOORD0;
 float4 diffuse     : COLOR;
};

struct VS_IN
{
 float4 position : POSITION;
 float3 texcoord : TEXCOORD0;
 float3 normal :NORMAL;
 float2 Norm : NORMAL;
};

/**************************************/
/***** VERTEX SHADER ******************/
/**************************************/

VS_out mainVS(VS_IN Input)
{
 VS_out Output =(VS_out)0;
 
 Output.oposition = mul(Input.position, WorldViewProj);// transform vert position to homogeneous clip space
 Output.otexcoord = Input.texcoord;
 
    float3 worldSpacePos = mul(Input.position, World);
 float3 L = normalize(light1Pos - worldSpacePos);
 float3 N = normalize(Input.normal);
 float diffuseLight = max(dot(N,L),0);
 
 Output.diffuse = diffuseLight;
 return Output; 
}

/**************************************/
/***** PIXEL SHADER *******************/
/**************************************/

float4 mainPS(VS_out PS_Input) : COLOR
{
 float4 ColorTexture = tex2D(diffuseMapSampler,PS_Input.otexcoord);
 float4 diffuse = PS_Input.diffuse*ColorTexture*DiffuseColor*light1Color;
 return  AmbientColor+diffuse;
}

technique technique0
{
 pass p0
 {
  ZEnable = true;
     ZWriteEnable = true;
      CullMode = cw;
     AlphaBlendEnable = false;
  VertexShader = compile vs_3_0 mainVS();
  PixelShader = compile ps_3_0 mainPS();
 }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值