0001:
0002:
0003:
0004:
0005:
0006:
0007:
0008:
0009:
0010: float4x4 mWVP;
0011: float4 LightPos;
0012: float4 EyePos;
0013: float4 alpha;
0014:
0015:
0016:
0017:
0018: texture MapP;
0019: sampler SampP = sampler_state
0020: {
0021: Texture = <MapP>;
0022: MinFilter = LINEAR;
0023: MagFilter = LINEAR;
0024: MipFilter = NONE;
0025:
0026: AddressU = Clamp;
0027: AddressV = Clamp;
0028: };
0029:
0030: texture MapQ;
0031: sampler SampQ = sampler_state
0032: {
0033: Texture = <MapQ>;
0034: MinFilter = LINEAR;
0035: MagFilter = LINEAR;
0036: MipFilter = NONE;
0037:
0038: AddressU = Clamp;
0039: AddressV = Clamp;
0040: };
0041:
0042:
0043:
0044: struct VS_INPUT
0045: {
0046: float4 Pos : POSITION;
0047: float3 Normal : NORMAL0;
0048: float2 Tex : TEXCOORD0;
0049: };
0050:
0051:
0052:
0053: struct VS_OUTPUT
0054: {
0055: float4 Pos : POSITION;
0056: float4 v : TEXCOORD0;
0057: float4 h : TEXCOORD1;
0058: float4 w : TEXCOORD2;
0059: float4 Intensity : COLOR0;
0060: };
0061:
0062:
0063:
0064:
0065: float4 Q(float3 In, float3 B, float3 T, float3 N)
0066: {
0067: float4 Out = (float4)0;
0068:
0069:
0070: float3 v;
0071: v.x = dot(B,In);
0072: v.y = dot(T,In);
0073: v.z = dot(N,In);
0074:
0075:
0076: float pv = 7.0f/8.0f;
0077: float ar = 1.0/(2.0*(1.000000001+v.z));
0078:
0079: if(0.7*(8.0f/7.0f)<ar){
0080:
0081: Out = 0;
0082: }else if(0.5*(8.0f/7.0f)<ar){
0083:
0084: Out = (0.7*(8.0f/7.0f)-ar)/(0.2*(8.0f/7.0f));
0085: }else{
0086: Out = 1;
0087: }
0088:
0089: Out.x = pv * ar * v.x + 0.5;
0090: Out.y = pv * ar * v.y + 0.5;
0091:
0092: return Out;
0093: }
0094:
0095:
0096:
0097: VS_OUTPUT VS(VS_INPUT In)
0098: {
0099: VS_OUTPUT Out = (VS_OUTPUT)0;
0100:
0101:
0102: Out.Pos = mul( In.Pos, mWVP );
0103:
0104:
0105: float3 N = In.Normal;
0106: float3 B = float3(0,1,0);
0107: float3 T = normalize(cross(N,B));
0108: B = cross(T,N);
0109:
0110:
0111: float3 V = normalize(EyePos -In.Pos.xyz);
0112: float3 W = normalize(LightPos-In.Pos.xyz);
0113: float3 H = normalize(W+V);
0114:
0115:
0116: Out.v = Q(V, B,T,N);
0117: Out.w = Q(W, B,T,N);
0118: Out.h = Q(H, B,T,N);
0119:
0120:
0121: Out.Intensity = Out.w.a;
0122:
0123: return Out;
0124: }
0125:
0126:
0127:
0128: float4 PS(VS_OUTPUT In) : COLOR
0129: {
0130: float4 v = tex2D( SampP, In.v );
0131: float4 h = tex2D( SampQ, In.h );
0132: float4 w = tex2D( SampP, In.w );
0133:
0134: return alpha * v * h * w * In.Intensity;
0135: }
0136:
0137:
0138:
0139: technique TShader
0140: {
0141: pass P0
0142: {
0143: VertexShader = compile vs_1_1 VS();
0144: PixelShader = compile ps_1_1 PS();
0145: }
0146: }
0147:
0148: