struct vertexInputs { float4 position : POSITION; float3 tangent : TANGENT; float3 binormal : BINORMAL; float3 normal : NORMAL; float4 texcoords : TEXCOORD0; }; struct interpolatedValues { float4 decalCoords : TEXCOORD0; float4 normalCoords : TEXCOORD1; float4 lightVec : TEXCOORD2; float4 halfVec : TEXCOORD3; }; // vertex program float4 main(in vertexInputs IN, out interpolatedValues OUT, uniform float3 lightDirection, uniform float3 halfangleDirection, uniform float4x4 modelViewProj) : POSITION { OUT.normalCoords = IN.texcoords; OUT.decalCoords = IN.texcoords; OUT.lightVec.x = dot(lightDirection, IN.tangent); OUT.lightVec.y = dot(lightDirection, IN.binormal); OUT.lightVec.z = dot(lightDirection, IN.normal); OUT.halfVec.x = dot(halfangleDirection, IN.tangent); OUT.halfVec.y = dot(halfangleDirection, IN.binormal); OUT.halfVec.z = dot(halfangleDirection, IN.normal); return mul(modelViewProj, IN.position); } -------------------------------------------------------------- struct interpolatedValues { float2 decalCoords : TEXCOORD0; float2 normalCoords : TEXCOORD1; float3 lightVec : TEXCOORD2; float3 halfVec : TEXCOORD3; }; // fragment program float4 main(in interpolatedValues IN, uniform float3 diffuseCoeff, uniform float specularCoeff, uniform sampler2D decal, uniform sampler2D normalMap, uniform sampler2D lookupTable) : COLOR { float3 decalColor = tex2D(decal, IN.decalCoords).rgb; float3 normal = tex2D(normalMap, IN.normalCoords).rgb; float4 lighting = tex2D(lookupTable, float2(dot(IN.lightVec, normal), dot(IN.halfVec, normal))); float3 diffuse = lighting.rgb * diffuseCoeff; float specular = lighting.a * specularCoeff; return float4(diffuse * decalColor + specular, 1.0); }