float4x4 mvp : ModelViewProjection; float4x4 mv : ModelView; float4x4 mvit : ModelViewIT; samplerCUBE skybox : SKYBOX; sampler2D amberTex = sampler_state { minFilter = Linear; magFilter = Linear; wrapS = Repeat; wrapT = Repeat; }; float4 vertex(uniform float4x4 modelViewProj, uniform float4x4 modelView, uniform float4x4 modelViewIT, 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(modelView, P).xyz; float3x3 rotation = (float3x3)modelView; Ncam.xyz = mul(rotation,N.xyz); uv = uvIn; return mul(modelViewProj, P); } float4 light(in float3 texcoord, float3 Pcam : TEXCOORD1, float3 Ncam : TEXCOORD2) : COLOR { float3 Nn = normalize(Ncam); // Reflection and refraction. float3 refl = reflect(Pcam,Nn); float3 refrRed = refract(Pcam,Nn, 1.3); float3 refrYellow = refract(Pcam,Nn,1.5); float3 reflCol = texCUBE(skybox,refl).rgb; reflCol.b = 0; float3 refrRedCol; refrRedCol.r = texCUBE(skybox,refrRed).r; float3 refrYellowCol; refrYellowCol.r = texCUBE(skybox,refrYellow).r; refrYellowCol.g = texCUBE(skybox,refrYellow).g; float3 refCol = (reflCol + refrRedCol + refrYellowCol) / 3.0; // Amber Texture: float3 amberCol = tex2D(amberTex, texcoord); // Random factor: float3 randomCol = normalize(Pcam); randomCol.b *= .25; float3 finalCol = (5.0 * refCol + 5.0 * amberCol + 0.0 * randomCol) / 10.0; return float4(finalCol, 1); } technique red { pass p0 { VertexProgram = compile arbvp1 vertex(mvp, mv, mvit); FragmentProgram = compile arbfp1 light(); } }