0001:
0002:
0003:
0004:
0005:
0006:
0007:
0008:
0009:
0010: float4 MaterialAmbientColor;
0011: float4 MaterialDiffuseColor;
0012:
0013: float3 LightDir = normalize(float3(1.0f, 1.0f, -1.0f));
0014: float4 LightAmbient = { 1.0f, 1.0f, 1.0f, 1.0f };
0015: float4 LightDiffuse = { 1.0f, 1.0f, 1.0f, 1.0f };
0016:
0017:
0018:
0019: float4x4 mWorldIT;
0020:
0021: float4x4 mWorldViewProjection;
0022:
0023: float INV_TEXSIZE;
0024:
0025: texture SrcMap;
0026: sampler SrcSamp = sampler_state
0027: {
0028: Texture = <SrcMap>;
0029: MinFilter = LINEAR;
0030: MagFilter = LINEAR;
0031: MipFilter = NONE;
0032:
0033: AddressU = Clamp;
0034: AddressV = Clamp;
0035: };
0036:
0037: texture PointMap;
0038: sampler PointSamp = sampler_state
0039: {
0040: Texture = <PointMap>;
0041: MinFilter = POINT;
0042: MagFilter = POINT;
0043: MipFilter = NONE;
0044:
0045: AddressU = Clamp;
0046: AddressV = Clamp;
0047: };
0048:
0049: texture WaveletTexture;
0050: sampler WaveletSamp = sampler_state
0051: {
0052: Texture = <WaveletTexture>;
0053: MinFilter = POINT;
0054: MagFilter = POINT;
0055: MipFilter = NONE;
0056:
0057: AddressU = Wrap;
0058: AddressV = Wrap;
0059: };
0060:
0061: texture SrcMap0;
0062: sampler SrcSamp0 = sampler_state
0063: {
0064: Texture = <SrcMap0>;
0065: MinFilter = POINT;
0066: MagFilter = POINT;
0067: MipFilter = NONE;
0068:
0069: AddressU = Clamp;
0070: AddressV = Clamp;
0071: };
0072:
0073: texture SrcMap1;
0074: sampler SrcSamp1 = sampler_state
0075: {
0076: Texture = <SrcMap1>;
0077: MinFilter = POINT;
0078: MagFilter = POINT;
0079: MipFilter = NONE;
0080:
0081: AddressU = Clamp;
0082: AddressV = Clamp;
0083: };
0084:
0085: texture SrcMap2;
0086: sampler SrcSamp2 = sampler_state
0087: {
0088: Texture = <SrcMap2>;
0089: MinFilter = POINT;
0090: MagFilter = POINT;
0091: MipFilter = NONE;
0092:
0093: AddressU = Clamp;
0094: AddressV = Clamp;
0095: };
0096:
0097: texture SrcMap3;
0098: sampler SrcSamp3 = sampler_state
0099: {
0100: Texture = <SrcMap3>;
0101: MinFilter = POINT;
0102: MagFilter = POINT;
0103: MipFilter = NONE;
0104:
0105: AddressU = Clamp;
0106: AddressV = Clamp;
0107: };
0108:
0109: texture IndexMap;
0110: sampler IndexSamp = sampler_state
0111: {
0112: Texture = <IndexMap>;
0113: MinFilter = POINT;
0114: MagFilter = POINT;
0115: MipFilter = NONE;
0116:
0117: AddressU = Clamp;
0118: AddressV = Clamp;
0119: };
0120:
0121:
0122:
0123:
0124:
0125:
0126:
0127: struct VS_OUTPUT
0128: {
0129: float4 Pos : POSITION;
0130: float2 Tex : TEXCOORD0;
0131: };
0132:
0133:
0134:
0135:
0136:
0137: float4 PS_pass1(VS_OUTPUT In) : COLOR
0138: {
0139: float3 Color = tex2D( SrcSamp, In.Tex ).xyz;
0140: const float3 RGB2Y = {0.299, 0.587, 0.114};
0141: float Y;
0142:
0143: Y = dot(Color, RGB2Y);
0144:
0145: return Y;
0146: }
0147:
0148:
0149:
0150: technique TShader
0151: {
0152: pass P0
0153: {
0154:
0155: PixelShader = compile ps_1_1 PS_pass1();
0156:
0157: Sampler[0] = (SrcSamp);
0158: }
0159: }
0160:
0161:
0162:
0163:
0164:
0165:
0166:
0167: struct SmallFragment
0168: {
0169: float4 Position : POSITION;
0170: float2 TextureUV0 : TEXCOORD0;
0171: float2 TextureUV1 : TEXCOORD1;
0172: float2 TextureUV2 : TEXCOORD2;
0173: float2 TextureUV3 : TEXCOORD3;
0174: float2 TextureUV4 : TEXCOORD4;
0175: float2 TextureUV5 : TEXCOORD5;
0176: float2 TextureUV6 : TEXCOORD6;
0177: float2 TextureUV7 : TEXCOORD7;
0178: };
0179:
0180:
0181:
0182:
0183:
0184:
0185:
0186: SmallFragment SmallVS( float3 vPos : POSITION,
0187: float2 vTexCoord : TEXCOORD )
0188: {
0189: SmallFragment Output;
0190:
0191: Output.Position.x = vPos.x;
0192: Output.Position.y = -vPos.y;
0193: Output.Position.z = 0.5f;
0194: Output.Position.w = 1;
0195:
0196: Output.TextureUV0 = vTexCoord + float2(1.0f, 1.0f) * INV_TEXSIZE;
0197: Output.TextureUV1 = vTexCoord + float2(1.0f, 3.0f) * INV_TEXSIZE;
0198: Output.TextureUV2 = vTexCoord + float2(1.0f, 5.0f) * INV_TEXSIZE;
0199: Output.TextureUV3 = vTexCoord + float2(1.0f, 7.0f) * INV_TEXSIZE;
0200: Output.TextureUV4 = vTexCoord + float2(3.0f, 1.0f) * INV_TEXSIZE;
0201: Output.TextureUV5 = vTexCoord + float2(3.0f, 3.0f) * INV_TEXSIZE;
0202: Output.TextureUV6 = vTexCoord + float2(3.0f, 5.0f) * INV_TEXSIZE;
0203: Output.TextureUV7 = vTexCoord + float2(3.0f, 7.0f) * INV_TEXSIZE;
0204:
0205: return Output;
0206: }
0207:
0208:
0209:
0210:
0211:
0212:
0213:
0214: float4 SmallPS( SmallFragment In ) : COLOR
0215: {
0216: float2 ofset = float2(4.0f, 0.0f) * INV_TEXSIZE;
0217:
0218: return (1.0f/16.0f)*(
0219: tex2D( SrcSamp, In.TextureUV0) + tex2D( SrcSamp, In.TextureUV0 + ofset)
0220: + tex2D( SrcSamp, In.TextureUV1) + tex2D( SrcSamp, In.TextureUV1 + ofset)
0221: + tex2D( SrcSamp, In.TextureUV2) + tex2D( SrcSamp, In.TextureUV2 + ofset)
0222: + tex2D( SrcSamp, In.TextureUV3) + tex2D( SrcSamp, In.TextureUV3 + ofset)
0223: + tex2D( SrcSamp, In.TextureUV4) + tex2D( SrcSamp, In.TextureUV4 + ofset)
0224: + tex2D( SrcSamp, In.TextureUV5) + tex2D( SrcSamp, In.TextureUV5 + ofset)
0225: + tex2D( SrcSamp, In.TextureUV6) + tex2D( SrcSamp, In.TextureUV6 + ofset)
0226: + tex2D( SrcSamp, In.TextureUV7) + tex2D( SrcSamp, In.TextureUV7 + ofset)
0227: );
0228: }
0229:
0230:
0231:
0232:
0233:
0234:
0235:
0236: technique SmallTech
0237: {
0238: pass P0
0239: {
0240: VertexShader = compile vs_1_1 SmallVS();
0241: PixelShader = compile ps_2_0 SmallPS();
0242:
0243: CULLMODE =NONE;
0244: }
0245: }
0246:
0247:
0248:
0249:
0250:
0251:
0252:
0253: SmallFragment WaveletVS( float3 vPos : POSITION,
0254: float2 vTexCoord : TEXCOORD )
0255: {
0256: SmallFragment Output=(SmallFragment)0;
0257:
0258: Output.Position.x = vPos.x;
0259: Output.Position.y = -vPos.y;
0260: Output.Position.z = 0.5f;
0261: Output.Position.w = 1;
0262:
0263: Output.TextureUV0 = vTexCoord + 0.5 * INV_TEXSIZE;
0264:
0265: return Output;
0266: }
0267:
0268:
0269:
0270:
0271:
0272:
0273: float4 WaveletPS( SmallFragment In ) : COLOR
0274: {
0275: return 0.5f + 2.0 * (tex2D( PointSamp, In.TextureUV0)-0.5)
0276: * (tex2D( WaveletSamp, 16*In.TextureUV0)-0.5);
0277: }
0278:
0279:
0280:
0281:
0282:
0283:
0284:
0285: SmallFragment Small4VS( float3 vPos : POSITION,
0286: float2 vTexCoord : TEXCOORD )
0287: {
0288: SmallFragment Output;
0289:
0290: Output.Position.x = vPos.x;
0291: Output.Position.y = -vPos.y;
0292: Output.Position.z = 0.5f;
0293: Output.Position.w = 1;
0294:
0295: Output.TextureUV0 = vTexCoord + float2(0.5f, 0.5f) * INV_TEXSIZE;
0296: Output.TextureUV1 = vTexCoord + float2(0.5f, 1.5f) * INV_TEXSIZE;
0297: Output.TextureUV2 = vTexCoord + float2(1.5f, 0.5f) * INV_TEXSIZE;
0298: Output.TextureUV3 = vTexCoord + float2(1.5f, 1.5f) * INV_TEXSIZE;
0299: Output.TextureUV4 = vTexCoord + float2(2.5f, 0.5f) * INV_TEXSIZE;
0300: Output.TextureUV5 = vTexCoord + float2(2.5f, 1.5f) * INV_TEXSIZE;
0301: Output.TextureUV6 = vTexCoord + float2(3.5f, 0.5f) * INV_TEXSIZE;
0302: Output.TextureUV7 = vTexCoord + float2(3.5f, 1.5f) * INV_TEXSIZE;
0303:
0304: return Output;
0305: }
0306:
0307:
0308:
0309:
0310:
0311:
0312:
0313: float4 Small4PS( SmallFragment In ) : COLOR
0314: {
0315: float2 ofset = float2(0.0f, 2.0f) * INV_TEXSIZE;
0316:
0317: return (1.0f/16.0f)*(
0318: tex2D( SrcSamp, In.TextureUV0) + tex2D( SrcSamp, In.TextureUV0 + ofset)
0319: + tex2D( SrcSamp, In.TextureUV1) + tex2D( SrcSamp, In.TextureUV1 + ofset)
0320: + tex2D( SrcSamp, In.TextureUV2) + tex2D( SrcSamp, In.TextureUV2 + ofset)
0321: + tex2D( SrcSamp, In.TextureUV3) + tex2D( SrcSamp, In.TextureUV3 + ofset)
0322: + tex2D( SrcSamp, In.TextureUV4) + tex2D( SrcSamp, In.TextureUV4 + ofset)
0323: + tex2D( SrcSamp, In.TextureUV5) + tex2D( SrcSamp, In.TextureUV5 + ofset)
0324: + tex2D( SrcSamp, In.TextureUV6) + tex2D( SrcSamp, In.TextureUV6 + ofset)
0325: + tex2D( SrcSamp, In.TextureUV7) + tex2D( SrcSamp, In.TextureUV7 + ofset)
0326: );
0327: }
0328:
0329:
0330:
0331:
0332:
0333:
0334:
0335: technique SmallTech4
0336: {
0337: pass P0
0338: {
0339: VertexShader = compile vs_1_1 Small4VS();
0340: PixelShader = compile ps_2_0 Small4PS();
0341:
0342: CULLMODE =NONE;
0343: }
0344: }
0345:
0346:
0347:
0348:
0349:
0350:
0351:
0352: technique WaveletTech
0353: {
0354: pass P0
0355: {
0356: VertexShader = compile vs_1_1 WaveletVS();
0357: PixelShader = compile ps_2_0 WaveletPS();
0358:
0359: CULLMODE =NONE;
0360: }
0361: }
0362:
0363:
0364:
0365:
0366:
0367:
0368:
0369:
0370: float4 DiffPS ( float2 TexCoord : TEXCOORD0 ) : COLOR
0371: {
0372: float4 o;
0373: float4 co0 = tex2D( SrcSamp0, TexCoord );
0374: float4 co1 = tex2D( SrcSamp1, TexCoord );
0375: float4 co2 = tex2D( SrcSamp2, TexCoord );
0376: float4 co3 = tex2D( SrcSamp3, TexCoord );
0377:
0378: float4 target00 = tex2D( PointSamp, float2( 0.5/52.0 + INV_TEXSIZE, 0.5/4) );
0379: float4 target01 = tex2D( PointSamp, float2( 0.5/52.0 + INV_TEXSIZE, 1.5/4) );
0380: float4 target02 = tex2D( PointSamp, float2( 0.5/52.0 + INV_TEXSIZE, 2.5/4) );
0381: float4 target03 = tex2D( PointSamp, float2( 0.5/52.0 + INV_TEXSIZE, 3.5/4) );
0382:
0383: float4 c00 = co0 - target00;
0384: float4 c01 = co1 - target01;
0385: float4 c02 = co2 - target02;
0386: float4 c03 = co3 - target03;
0387:
0388: o = dot(c00,c00)
0389: + 2.0*( dot(c01,c01) + dot(c02,c02) + dot(c03,c03) );
0390:
0391: return o;
0392: }
0393:
0394:
0395:
0396:
0397: technique DiffTech
0398: {
0399: pass P0
0400: {
0401:
0402: PixelShader = compile ps_2_0 DiffPS();
0403: }
0404: }
0405:
0406:
0407:
0408:
0409:
0410:
0411:
0412: struct CompareFragment
0413: {
0414: float4 Value : COLOR0;
0415: float4 Index : COLOR1;
0416: };
0417:
0418:
0419:
0420:
0421: CompareFragment ComparePS ( float2 TexCoord : TEXCOORD0 )
0422: {
0423: CompareFragment O;
0424: float value;
0425: float index;
0426: float4 c0 = tex2D( SrcSamp0, TexCoord );
0427: float4 c1 = tex2D( SrcSamp1, TexCoord );
0428: float4 c2 = tex2D( SrcSamp2, TexCoord );
0429: float4 c3 = tex2D( SrcSamp3, TexCoord );
0430: float4 i0 = float4( 0.0/52.0, 1.0/52.0, 2.0/52.0, 3.0/52.0);
0431: float4 i1 = float4( 4.0/52.0, 5.0/52.0, 6.0/52.0, 7.0/52.0);
0432: float4 i2 = float4( 8.0/52.0, 9.0/52.0, 10.0/52.0, 11.0/52.0);
0433: float4 i3 = float4(12.0/52.0, 13.0/52.0, 14.0/52.0, 15.0/52.0);
0434:
0435: i0 = ( c0 <= c1 ) ? i0 : i1;
0436: c0 = ( c0 <= c1 ) ? c0 : c1;
0437:
0438: i2 = ( c2 <= c3 ) ? i2 : i3;
0439: c2 = ( c2 <= c3 ) ? c2 : c3;
0440:
0441: i0 = ( c0 <= c2 ) ? i0 : i2;
0442: c0 = ( c0 <= c2 ) ? c0 : c2;
0443:
0444: index = i0.x;
0445: value = c0.x;
0446:
0447: if( c0.y <= value ) {index = i0.y; value = c0.y;}
0448: if( c0.z <= value ) {index = i0.z; value = c0.z;}
0449: if( c0.w <= value ) {index = i0.w; value = c0.w;}
0450:
0451: O.Value = value;
0452: O.Index = index + INV_TEXSIZE;
0453:
0454: return O;
0455: }
0456:
0457:
0458:
0459:
0460: technique CompareTech
0461: {
0462: pass P0
0463: {
0464:
0465: PixelShader = compile ps_2_0 ComparePS();
0466: }
0467: }
0468:
0469:
0470:
0471:
0472:
0473:
0474:
0475: float4 Compare2PS ( float2 TexCoord : TEXCOORD0 ) : COLOR0
0476: {
0477: float value;
0478: float index;
0479: float4 c0 = tex2D( SrcSamp0, TexCoord );
0480: float4 i0 = tex2D( IndexSamp, TexCoord );
0481:
0482: index = i0.x;
0483: value = c0.x;
0484:
0485: if( c0.y <= value ) {index = i0.y; value = c0.y;}
0486: if( c0.z <= value ) {index = i0.z; value = c0.z;}
0487: if( c0.w <= value ) {index = i0.w; value = c0.w;}
0488:
0489: return index;
0490: }
0491:
0492:
0493:
0494:
0495: technique Compare2Tech
0496: {
0497: pass P0
0498: {
0499:
0500: PixelShader = compile ps_2_0 Compare2PS();
0501: }
0502: }
0503:
0504:
0505:
0506:
0507:
0508:
0509:
0510: struct FinalFragment
0511: {
0512: float4 Pos : POSITION;
0513: float2 Tex : TEXCOORD0;
0514: };
0515:
0516:
0517:
0518:
0519: float4 FinalPS ( float2 TexCoord : TEXCOORD0 ) : COLOR
0520: {
0521: float idx = floor( 52 * tex2D( SrcSamp0, TexCoord ) );
0522:
0523: float2 texcoord;
0524: float2 t_mod = fmod( 16*TexCoord, 1 );
0525: texcoord.x = (1.0/52.0) * (idx + t_mod.x );
0526: texcoord.y = t_mod.y;
0527:
0528: return tex2D( SrcSamp, texcoord ) * tex2D( PointSamp, TexCoord );
0529: }
0530:
0531:
0532:
0533:
0534: technique FinalTech
0535: {
0536: pass P0
0537: {
0538:
0539: PixelShader = compile ps_2_0 FinalPS();
0540: }
0541: }
0542:
0543:
0544:
0545:
0546:
0547:
0548:
0549: struct SimpleFragment
0550: {
0551: float4 Position : POSITION;
0552: float4 Diffuse : COLOR0;
0553: float2 TextureUV : TEXCOORD0;
0554: };
0555:
0556:
0557:
0558:
0559:
0560:
0561:
0562: SimpleFragment SimpleVS( float4 vPos : POSITION,
0563: float3 vNormal : NORMAL,
0564: float2 vTexCoord0 : TEXCOORD0 )
0565: {
0566: SimpleFragment Output;
0567: float3 vWorldNormal;
0568:
0569:
0570: Output.Position = mul(vPos, mWorldViewProjection);
0571:
0572:
0573: vWorldNormal = mul(vNormal, (float3x3)mWorldIT);
0574: vWorldNormal = normalize(vWorldNormal);
0575:
0576:
0577: Output.Diffuse.rgb = MaterialDiffuseColor * LightDiffuse * max(0,dot(vWorldNormal, LightDir)) +
0578: MaterialAmbientColor * LightAmbient;
0579: Output.Diffuse.a = 0;
0580:
0581:
0582: Output.TextureUV = vTexCoord0;
0583:
0584: return Output;
0585: }
0586:
0587:
0588:
0589:
0590:
0591:
0592:
0593: float4 SimplePS( SimpleFragment In ) : COLOR
0594: {
0595:
0596: return tex2D( SrcSamp, In.TextureUV);
0597: }
0598:
0599:
0600:
0601:
0602:
0603:
0604:
0605: technique SimpleTech
0606: {
0607: pass P0
0608: {
0609: VertexShader = compile vs_1_1 SimpleVS();
0610: PixelShader = compile ps_2_0 SimplePS();
0611: }
0612: }
0613:
0614:
0615:
0616:
0617: