float4x4 mInvWorld; float4x4 mWorldViewProj ; //our world view projection matrix float4x4 mWorldViewIt ; //our inverse transpose matrix float4x4 mWorld ; //our world matrix float4x4 mView ; //our view matrix float4x4 mViewInv; //our view inverse matrix float3 mLightPos; //our light position in object space float3 mCamPos; //our cam position in object space float4x4 mProj; float3 eyeIn; float fTime; texture texture0; //our texture texture texture1; //our normal map sampler2D texSampler0 : TEXUNIT0 = sampler_state { Texture = (texture0); MIPFILTER = LINEAR; MAGFILTER = LINEAR; MINFILTER = LINEAR; }; sampler2D texSampler1 : TEXUNIT1 = sampler_state { Texture = (texture1); MIPFILTER = LINEAR; MAGFILTER = LINEAR; MINFILTER = LINEAR; }; //application to vertex structure struct a2v { float4 position : POSITION; float4 tex0 : TEXCOORD0; float4 lightIn : TEXCOORD2; }; //vertex to pixel shader structure struct v2p { float4 tex0 : TEXCOORD0; float4 tex1 : TEXCOORD1; float4 lightIn : TEXCOORD2; }; //pixel shader to screen struct p2f { float4 color : COLOR0; }; //VERTEX SHADER v2p vertexMain( a2v IN ) { v2p OUT; //getting to position to object space float4 worldviewproj_pos = mul(IN.position,mWorldViewProj); OUT.tex1 = IN.tex0; OUT.position = worldviewproj_pos; OUT.tex0.xy = (worldviewproj_pos.xy + worldviewproj_pos.w)*0.5; OUT.tex0.zw = float2(1, worldviewproj_pos.w); IN.lightIn = worldviewproj_pos - (float4)mLightPos; return OUT; } //PIXEL SHADER p2f pixelMain( v2p IN ) { p2f OUT; float2 final = IN.tex0.xy / IN.tex0.w; float t = fTime / 1000.0; float3 sample = tex2D(texSampler1,(IN.tex1 + t)/2.0).xyz ; float3 sample2 = tex2D(texSampler1,(IN.tex1 + t)/-1.0).xyz ; float3 finalsample = (sample + sample2) / 2.0; finalsample *= float3(0.015,0.015,1.0); normalize(finalsample); float4 color = tex2D( texSampler0, final.xy + finalsample.xy); //incoming lightvec // normalize(lightIn); float specular = dot(IN.lightIn,finalsample); color.w = 0.5 + specular; OUT.color = color; return OUT; }