uniform float4x4 projection; uniform float4x4 view; uniform float4x4 world; uniform float shading; uniform float blur; uniform float blackValue; uniform float sharpen; uniform float greyValue; uniform float negValue; uniform float threshold; uniform float timer : TIME; texture Texture; sampler TextureSampler = sampler_state { texture = ; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = mirror; AddressV = mirror; }; struct VertexStructure { float4 Position : POSITION; float2 TexCoord : TEXCOORD0; }; struct PixelStructure { float4 Position : POSITION; float2 TexCoord : TEXCOORD0; }; PixelStructure VertexShader(VertexStructure vInput) { PixelStructure vOutput; float4x4 preViewProjection = mul (view, projection); float4x4 preWorldViewProjection = mul (world, preViewProjection); vOutput.Position = mul(vInput.Position, preWorldViewProjection); vOutput.TexCoord = vInput.TexCoord; return vOutput; } PixelStructure VertexShader1(VertexStructure vInput) { PixelStructure vOutput; float offset = 100.0f; float4x4 preViewProjection = mul (view, projection); float4x4 preWorldViewProjection = mul (world, preViewProjection); vOutput.Position = float4(vInput.Position.xyz,1); float y = vOutput.Position.y * offset + timer; float x = sin(y) * offset; vOutput.Position.x += x; vOutput.TexCoord = vInput.TexCoord; return vOutput; } float4 PixelShader(PixelStructure vInput) : COLOR0 { float4 pOutput; pOutput = saturate(tex2D(TextureSampler, vInput.TexCoord) * shading); return pOutput; } float4 PixelShader2(PixelStructure vInput) : COLOR0 { float4 pOutput; pOutput = tex2D(TextureSampler, float2(vInput.TexCoord.x + blur, vInput.TexCoord.y)); pOutput += tex2D(TextureSampler, float2(vInput.TexCoord.x - blur, vInput.TexCoord.y)); pOutput += tex2D(TextureSampler, float2(vInput.TexCoord.x, vInput.TexCoord.y + blur)); pOutput += tex2D(TextureSampler, float2(vInput.TexCoord.x, vInput.TexCoord.y - blur)); pOutput /= 4; return pOutput; } //No Effects float4 PixelShader3(PixelStructure vInput) : COLOR0 { float4 pOutput; pOutput = tex2D(TextureSampler, vInput.TexCoord); return pOutput; } //Changes the image to black or white excusively float4 PixelShader4(PixelStructure vInput) : COLOR0 { float4 pOutput; float4 black = float4(0.0f,0.0f,0.0f,1.0f); float4 white = float4(1.0f,1.0f,1.0f,1.0f); pOutput = tex2D(TextureSampler, vInput.TexCoord); if(pOutput.r > blackValue) { pOutput = white; } else { pOutput = black; } return pOutput; } //Negative Image float4 PixelShader5(PixelStructure vInput) : COLOR0 { float4 pOutput; pOutput = negValue - tex2D(TextureSampler, vInput.TexCoord); return pOutput; } //Sharpen Image/Emboss float4 PixelShader6(PixelStructure vInput) : COLOR0 { float4 pOutput; pOutput.rgb = 1.0f; pOutput.a = .10f; pOutput += tex2D(TextureSampler, vInput.TexCoord - .001) * sharpen; pOutput -= tex2D(TextureSampler, vInput.TexCoord + .001) * sharpen; return pOutput; } //Grey Value float4 PixelShader7(PixelStructure vInput) : COLOR0 { float4 pOutput; pOutput = tex2D(TextureSampler, vInput.TexCoord); pOutput = dot(pOutput.rgb, float3(.3,.59,.11)) / greyValue; return pOutput; } //Sobel Edge Detection float4 PixelShader8(PixelStructure vInput) : COLOR0 { float4 pOutput; float gradient; float sx; float sy; float kY0 = 1; float kY1 = 2; float kY2 = 1; float kY3 = 0; float kY4 = 0; float kY5 = 0; float kY6 = -1; float kY7 = -2; float kY8 = -1; float kX0 = -1; float kX1 = 0; float kX2 = 1; float kX3 = -2; float kX4 = 0; float kX5 = 2; float kX6 = -1; float kX7 = 0; float kX8 = 1; //get color of each surounding pixel float4 c0 = tex2D(TextureSampler, float2(vInput.TexCoord.x - .005, vInput.TexCoord.y - .005)); float4 c1 = tex2D(TextureSampler, float2(vInput.TexCoord.x, vInput.TexCoord.y - .005)); float4 c2 = tex2D(TextureSampler, float2(vInput.TexCoord.x + .005, vInput.TexCoord.y - .005)); float4 c3 = tex2D(TextureSampler, float2(vInput.TexCoord.x - .005, vInput.TexCoord.y)); float4 c4 = tex2D(TextureSampler, float2(vInput.TexCoord.x, vInput.TexCoord.y)); float4 c5 = tex2D(TextureSampler, float2(vInput.TexCoord.x + .005, vInput.TexCoord.y)); float4 c6 = tex2D(TextureSampler, float2(vInput.TexCoord.x - .005, vInput.TexCoord.y + .005)); float4 c7 = tex2D(TextureSampler, float2(vInput.TexCoord.x, vInput.TexCoord.y + .005)); float4 c8 = tex2D(TextureSampler, float2(vInput.TexCoord.x + .005, vInput.TexCoord.y + .005)); //convert to grey float g0 = dot(c0.rgb, float3(.3,.59,.11)); float g1 = dot(c1.rgb, float3(.3,.59,.11)); float g2 = dot(c2.rgb, float3(.3,.59,.11)); float g3 = dot(c3.rgb, float3(.3,.59,.11)); float g4 = dot(c4.rgb, float3(.3,.59,.11)); float g5 = dot(c5.rgb, float3(.3,.59,.11)); float g6 = dot(c6.rgb, float3(.3,.59,.11)); float g7 = dot(c7.rgb, float3(.3,.59,.11)); float g8 = dot(c8.rgb, float3(.3,.59,.11)); //set x and y values to 0 sx = 0.0f; sy = 0.0f; sx += g0 * kX0; sx += g1 * kX1; sx += g2 * kX2; sx += g3 * kX3; sx += g4 * kX4; sx += g5 * kX5; sx += g6 * kX6; sx += g7 * kX7; sx += g8 * kX8; sy += g0 * kY0; sy += g1 * kY1; sy += g2 * kY2; sy += g3 * kY3; sy += g4 * kY4; sy += g5 * kY5; sy += g6 * kY6; sy += g7 * kY7; sy += g8 * kY8; float dist = sqrt((sx*sx) + (sy*sy)); float result = 1; if(dist > threshold) result = 0; return result.xxxx; } //---------------------------------------------------------------------------------------------- Technique None { Pass pass0 { VertexShader = compile vs_3_0 VertexShader(); PixelShader = compile ps_3_0 PixelShader3(); } Pass pass1 { VertexShader = compile vs_3_0 VertexShader(); PixelShader = compile ps_3_0 PixelShader(); } Pass pass2 { VertexShader = compile vs_3_0 VertexShader(); PixelShader = compile ps_3_0 PixelShader2(); } Pass pass3 { VertexShader = compile vs_3_0 VertexShader(); PixelShader = compile ps_3_0 PixelShader4(); } Pass pass4 { VertexShader = compile vs_3_0 VertexShader(); PixelShader = compile ps_3_0 PixelShader5(); } //sharpen Pass pass5 { VertexShader = compile vs_3_0 VertexShader(); PixelShader = compile ps_3_0 PixelShader6(); } //grey scale Pass pass6 { VertexShader = compile vs_3_0 VertexShader(); PixelShader = compile ps_3_0 PixelShader7(); } //Sobel Edge Pass pass7 { VertexShader = compile vs_3_0 VertexShader(); PixelShader = compile ps_3_0 PixelShader8(); } Pass pass8 { VertexShader = compile vs_3_0 VertexShader1(); PixelShader = compile ps_3_0 PixelShader3(); } } Technique VertexMover { Pass pass0 { VertexShader = compile vs_3_0 VertexShader1(); PixelShader = compile ps_3_0 PixelShader3(); } }