0001:
0002:
0003:
0004:
0005:
0006:
0007:
0008:
0009:
0010:
0011: float4x4 mWVP;
0012: float4 vCol;
0013: float4 vLightPos;
0014: float4 vCamPos;
0015: float A;
0016: float B;
0017:
0018:
0019:
0020:
0021:
0022: texture tSinTan;
0023: sampler SinTanSamp = sampler_state
0024: {
0025: Texture = <tSinTan>;
0026: MinFilter = LINEAR;
0027: MagFilter = LINEAR;
0028: MipFilter = NONE;
0029:
0030: AddressU = Clamp;
0031: AddressV = Clamp;
0032: };
0033:
0034:
0035:
0036:
0037:
0038: struct VS_OUTPUT
0039: {
0040: float4 Pos : POSITION;
0041: float4 Color : COLOR0;
0042: float3 Normal : TEXCOORD0;
0043: float3 Light : TEXCOORD1;
0044: float3 Eye : TEXCOORD2;
0045: };
0046:
0047:
0048:
0049:
0050: VS_OUTPUT VS(
0051: float4 Pos : POSITION,
0052: float3 Normal : NORMAL
0053: ){
0054: VS_OUTPUT Out = (VS_OUTPUT)0;
0055: float4 uv;
0056:
0057:
0058: Out.Pos = mul(Pos, mWVP);
0059:
0060:
0061: Out.Color = vCol;
0062:
0063: Out.Normal = Normal;
0064: Out.Light = vLightPos.xyz - Pos.xyz;
0065: Out.Eye = vCamPos.xyz - Pos.xyz;
0066:
0067: return Out;
0068: }
0069:
0070:
0071:
0072: float4 PS(VS_OUTPUT In) : COLOR
0073: {
0074: float4 Out = 0;
0075:
0076: float3 l = normalize(In.Light);
0077: float3 n = normalize(In.Normal);
0078: float3 e = normalize(In.Eye);
0079:
0080: float2 tcoord = {dot(l,n), max(0,dot(e,n))};
0081: float sintan = tex2D( SinTanSamp, 0.5f * tcoord + 0.5f ).x;
0082:
0083: float3 al = normalize(l-dot(l,n)*n);
0084: float3 ae = normalize(e-dot(e,n)*n);
0085: float C = max(0, dot(al,ae));
0086:
0087: Out = dot(l,n) * (A + B * C * sintan);
0088:
0089:
0090:
0091: return Out;
0092: }
0093:
0094:
0095:
0096: technique TShader
0097: {
0098: pass P0
0099: {
0100:
0101: VertexShader = compile vs_1_1 VS();
0102: PixelShader = compile ps_2_0 PS();
0103: }
0104: }
0105: