0001:
0002:
0003:
0004: struct appdata
0005: {
0006: float4 position : POSITION;
0007: float3 normal : NORMAL;
0008: };
0009:
0010:
0011:
0012: struct vert2frag
0013: {
0014: float4 hpos : HPOS;
0015: float4 tcoords : TEX0;
0016: float4 normal : TEX1;
0017: float3 vlight : TEX2;
0018: float3 vhalf : TEX3;
0019: };
0020:
0021:
0022:
0023: vert2frag main(appdata IN
0024: , uniform float4 LightPosition
0025: , uniform float4x4 ModelViewProj
0026: , uniform float4x4 ModelView
0027: , uniform float4x4 ShaderMatrix
0028: , uniform float4x4 ModelViewIT
0029: )
0030: {
0031: vert2frag OUT;
0032:
0033: float4 pos = IN.position.xyzw;
0034: float4 normal = IN.normal.xyzz;
0035: normal.w = 1.0;
0036:
0037:
0038: OUT.hpos = mul(ModelViewProj, pos);
0039:
0040:
0041: OUT.tcoords = mul(ShaderMatrix, pos);
0042:
0043:
0044: OUT.normal = mul(ModelViewIT, normal);
0045:
0046:
0047: float4 pos_view = mul(ModelView, pos);
0048: float3 L = normalize(LightPosition.xyz - pos_view.xyz);
0049: OUT.vlight = L;
0050:
0051:
0052: float3 eye = float3(0.0, 0.0, 10.0) - pos_view.xyz;
0053: OUT.vhalf = normalize(eye + L);
0054:
0055: return OUT;
0056: }
0057: