source: GTP/trunk/App/Demos/Illum/IBRBillboardCloudTrees/OGRE/IBRTreesOGRE/media/general/indirectTexturingWithAmbientOcclusion_hlsl_FP20.shd.bak @ 1493

Revision 1493, 1.8 KB checked in by igarcia, 18 years ago (diff)
Line 
1sampler indirectTexture: register(s0);
2sampler sourceTexture: register(s1);
3sampler visibilityTexture: register(s2);
4
5uniform float epsilonX;
6uniform float epsilonY;
7uniform float sourceTextureSize;
8uniform float numSamples;
9uniform float sqrtNumSamples;
10
11float4 main_fp(float2 texCoord: TEXCOORD0,
12               float2 subTexCoord: TEXCOORD1): COLOR
13{
14   float4 ocolor = float4(0.0, 0.0, 0.0, 0.0); 
15   float2 epsilon = float2(epsilonX, epsilonY); 
16   float4 value = tex2D(indirectTexture, subTexCoord).xyzw;
17   float2 coords = texCoord - ( value.xy - epsilon );
18
19   if (value.w != 0.0)
20   {   
21        float2 unifcoord;
22        float2 scale;
23        unifcoord = (texCoord - value.xy) * float2(sourceTextureSize, sourceTextureSize);
24        scale = coords * float2(sourceTextureSize, sourceTextureSize) / float2(sqrtNumSamples, sqrtNumSamples);
25        float2 newcoord = float2(1.0, 1.0) - value.zw + scale;
26        ocolor = tex2D(sourceTexture, newcoord).xyzw;
27       
28        if (ocolor.w != 0.0)
29        {
30                float4 visibility = tex2D(visibilityTexture, subTexCoord).xyzw;
31                float greyRange = 12.9107;
32                float absGreyMin = abs(min(-6.47313, 0.0));
33                visibility.xyzw = (visibility.xyzw * float4(greyRange, greyRange, greyRange, greyRange)) - float4(absGreyMin, absGreyMin, absGreyMin, absGreyMin);
34                float e = lerp(visibility.x, visibility.y, unifcoord.x);
35                float f = lerp(visibility.w, visibility.z, unifcoord.x);
36                float g = lerp(e, f, unifcoord.y);
37                ocolor.xyz =  g * ( ocolor.xyz );
38        }
39        // Debugging values...
40        //ocolor.xyz = float3( epsilon.x, epsilon.y, 0.0 );
41        //ocolor.xyz = float3( unifcoord.x, unifcoord.y, 0.0 );
42        //ocolor.xyz =  float3( unifcoord.x, 0.0, 0.0 );
43        //ocolor.xyz = float3( 0.0, unifcoord.y, 0.0 );
44        //ocolor.xyz = float3( g, g, g );
45        //ocolor.xyz = visibility.xyz;
46        //ocolor.w = 1.0;
47   }
48
49   return  ocolor;
50}
Note: See TracBrowser for help on using the repository browser.