sampler2D diffuse = sampler_state { minFilter = Linear; magFilter = Linear; wrapS = Repeat; wrapT = Repeat; }; sampler2D bump = sampler_state { generateMipMap = true; minFilter = Linear; magFilter = Linear; wrapS = Repeat; wrapT = Repeat; }; float4x4 mvp : ModelViewProjection; float4x4 mv : ModelView; float4x4 mvit : ModelViewIT; float4 vertexDiff(float4 P : POSITION, float4 N : NORMAL, float2 uvIn : TEXCOORD0, in float4 Cin : COLOR0, out float4 CC : COLOR0, out float3 Pcam : TEXCOORD1, out float3 Ncam : TEXCOORD2, out float2 uv : TEXCOORD0) : POSITION { CC.xyz = normalize(N.xyz); Pcam = mul(mv, P).xyz; Ncam = mul(mvit, N).xyz; return mul(mvp, P); } float4 light( float4 col: COLOR0, in float3 texcoord, float3 Pcam : TEXCOORD1, float3 Ncam : TEXCOORD2) : COLOR { float3 tan = normalize(col.xyz); float3 wo = normalize(-Pcam); float3 result;// = ambient; float3 Nn = normalize(Ncam); float3 scolor = float3(1.0,1.0,1.0); float3 Ln = normalize(float3(0,0,-1)-Pcam); float3 lcolor = float3(1,1,1); float3 Hn = normalize(wo + Ln); float ldn = dot(Ln,Nn); float hdn = dot(Hn,Nn); float4 litV = lit(ldn, hdn, 32); result = tex2D(diffuse ,texcoord)*litV.y; return float4(result, 1.); } float4 vertex(uniform float scale, float4 P : POSITION, float4 N : NORMAL, float2 uvIn : TEXCOORD0, in float4 Cin : COLOR0, out float4 CC : COLOR0, out float3 Pcam : TEXCOORD1, out float3 Ncam : TEXCOORD2, out float2 uv : TEXCOORD0) : POSITION { float4 vert = P + float4(N.xyz*scale, 0); uv = uvIn; uv *= 0.25; Ncam = mul(mvit, N).xyz; Pcam = mul(mv, vert); return mul(mvp, vert); } float4 fragment( in float3 uv, float3 Pcam : TEXCOORD1, float3 Ncam : TEXCOORD2) : COLOR { float3 wo = normalize(-Pcam); float3 result;// = ambient; float3 alpha = tex2D(bump, uv*2).xyz; if (alpha.r + alpha.g + alpha.b < 1.5) discard; return tex2D(diffuse,uv); } technique red { pass p110 { VertexProgram = compile arbvp1 vertexDiff(); FragmentProgram = compile arbfp1 light(); } pass p0 { VertexProgram = compile arbvp1 vertex(0.012); FragmentProgram = compile arbfp1 fragment(); } pass p1 { VertexProgram = compile arbvp1 vertex(0.024); FragmentProgram = compile arbfp1 fragment(); } pass p2 { VertexProgram = compile arbvp1 vertex(0.036); FragmentProgram = compile arbfp1 fragment(); } pass p3 { VertexProgram = compile arbvp1 vertex(0.048); FragmentProgram = compile arbfp1 fragment(); } pass p4 { VertexProgram = compile arbvp1 vertex(0.06); FragmentProgram = compile arbfp1 fragment(); } pass p5 { VertexProgram = compile arbvp1 vertex(0.072); FragmentProgram = compile arbfp1 fragment(); } pass p6 { VertexProgram = compile arbvp1 vertex(0.084); FragmentProgram = compile arbfp1 fragment(); } pass p7 { VertexProgram = compile arbvp1 vertex(0.096); FragmentProgram = compile arbfp1 fragment(); } pass p8 { VertexProgram = compile arbvp1 vertex(0.108); FragmentProgram = compile arbfp1 fragment(); } pass p9 { VertexProgram = compile arbvp1 vertex(0.12); FragmentProgram = compile arbfp1 fragment(); } }