float4x4 worldViewProj : WorldViewProjection; sampler2D image; float2 imageIncrement; struct VertexShaderInput { float4 position : POSITION; float2 imageCoord : TEXCOORD0; }; struct PixelShaderInput { float4 position : POSITION; float2 imageCoord : TEXCOORD0; }; PixelShaderInput SobelVS(VertexShaderInput input) { PixelShaderInput output; output.position = mul(input.position, worldViewProj); output.imageCoord = input.imageCoord; return output; } float lum(float4 c) { return dot(c.rgb, float3(0.3, 0.59, 0.11)); } float4 SobelPS(PixelShaderInput input) : COLOR { float2 imageCoord = input.imageCoord; float t00 = lum(tex2D(image, imageCoord + imageIncrement * float2(-1, -1))); float t10 = lum(tex2D(image, imageCoord + imageIncrement * float2( 0, -1))); float t20 = lum(tex2D(image, imageCoord + imageIncrement * float2( 1, -1))); float t01 = lum(tex2D(image, imageCoord + imageIncrement * float2(-1, 0))); float t21 = lum(tex2D(image, imageCoord + imageIncrement * float2( 1, 0))); float t02 = lum(tex2D(image, imageCoord + imageIncrement * float2(-1, 1))); float t12 = lum(tex2D(image, imageCoord + imageIncrement * float2( 0, 1))); float t22 = lum(tex2D(image, imageCoord + imageIncrement * float2( 1, 1))); float2 grad; grad.x = t00 + 2.0 * t01 + t02 - t20 - 2.0 * t21 - t22; grad.y = t00 + 2.0 * t10 + t20 - t02 - 2.0 * t12 - t22; float len = length(grad); return float4(len, len, len, 1.0); } // #o3d VertexShaderEntryPoint SobelVS // #o3d PixelShaderEntryPoint SobelPS // #o3d MatrixLoadOrder RowMajor