// sepia float time=0; float sampleDist = 1.0f/512.0f; // distance one pixel in u/v sampler2D image : register(s0); //------------------------------------------------------------------------------ // SepiaTone.psh // // Converts image to sepia tone by moving color into YIQ space first. // Algo: // 1) find Intensity // 2) load intensity into Y // 3) load 2 and 0 into I and Q respectively // 4) transform Intenty,2, 0.0 color back to RGB. // // // Marwan Y. Ansari - ATI Research, Inc. - 2002 //------------------------------------------------------------------------------// float4 main( float4 Pos : POSITION, float2 texCoord: TEXCOORD0) : COLOR { float4 c = .5; float4 currFrameSample; float4 currFrameSampleYIQ; float4x4 YIQMatrix = { 0.299, 0.587, 0.114,0, 0.596, -0.275, -0.321,0, 0.212, -0.523, 0.311,0, 0,0,0,1}; float4x4 inverseYIQ ={ 1.0000000000000000000, .95568806036115671171, .61985809445637075388, 0, 1.0000000000000000000, -.27158179694405859326, -.64687381613840131330, 0, 1.0000000000000000000, -1.1081773266826619523, 1.7050645599191817149, 0, 0,0,0,1 }; // get sample currFrameSample = tex2D( image, texCoord); // convert to YIQ space currFrameSampleYIQ = mul(YIQMatrix , currFrameSample); currFrameSampleYIQ.y = 0.2; // convert YIQ color to sepia tone currFrameSampleYIQ.z = 0.0; // convert back to RGB c = mul( inverseYIQ, currFrameSampleYIQ); return c; }