0001:
0002:
0003:
0004: struct vert2frag
0005: {
0006: float4 hpos : HPOS;
0007: float4 tcoords : TEX0;
0008: };
0009:
0010:
0011:
0012: fragout main(vert2frag I
0013: , uniform texobj2D SrcMap : texunit0
0014: )
0015: {
0016: fragout O;
0017:
0018: float3 rgb2lum = {0.299, 0.587, 0.114};
0019:
0020: float2 shift00 = { 0.5f/256.0f, 0.5f/256.0f};
0021: float2 shift01 = { 0.5f/256.0f, 1.5f/256.0f};
0022: float2 shift10 = { 1.5f/256.0f, 0.5f/256.0f};
0023: float2 shift0N = { 0.5f/256.0f,-0.5f/256.0f};
0024: float2 shiftN0 = {-0.5f/256.0f, 0.5f/256.0f};
0025:
0026:
0027: float3 col0 = f3tex2D( SrcMap, I.tcoords.xy + shift00 );
0028: float3 col1 = f3tex2D( SrcMap, I.tcoords.xy + shift01 );
0029: float3 col2 = f3tex2D( SrcMap, I.tcoords.xy + shift10 );
0030: float3 col3 = f3tex2D( SrcMap, I.tcoords.xy + shift0N );
0031: float3 col4 = f3tex2D( SrcMap, I.tcoords.xy + shiftN0 );
0032:
0033:
0034: float b0 = dot( col0, rgb2lum );
0035: float b1 = dot( col1, rgb2lum );
0036: float b2 = dot( col2, rgb2lum );
0037: float b3 = dot( col3, rgb2lum );
0038: float b4 = dot( col4, rgb2lum );
0039:
0040:
0041: float flag0 = ((b0< b1)?1.0:0.0) + ((b0< b2)?1.0:0.0) + ((b0< b3)?1.0:0.0) + ((b0< b4)?1.0:0.0);
0042: float flag1 = ((b1<=b0)?1.0:0.0) + ((b1< b2)?1.0:0.0) + ((b1< b3)?1.0:0.0) + ((b1< b4)?1.0:0.0);
0043: float flag2 = ((b2<=b0)?1.0:0.0) + ((b2<=b1)?1.0:0.0) + ((b2< b3)?1.0:0.0) + ((b2< b4)?1.0:0.0);
0044: float flag3 = ((b3<=b0)?1.0:0.0) + ((b3<=b1)?1.0:0.0) + ((b3<=b2)?1.0:0.0) + ((b3< b4)?1.0:0.0);
0045:
0046:
0047: O.col.xyz = ( 1.5f<flag0 && flag0<2.5f ) ? col0 :
0048: (( 1.5f<flag1 && flag1<2.5f ) ? col1 :
0049: (( 1.5f<flag2 && flag2<2.5f ) ? col2 :
0050: (( 1.5f<flag3 && flag3<2.5f ) ? col3 : col4 )));
0051:
0052: return O;
0053: }
0054: