Changeset 1691 for GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs
- Timestamp:
- 10/27/06 17:40:02 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Blur.hlsl
r1257 r1691 1 #define samplesU 52 #define samplesV 51 #define samplesU 3 2 #define samplesV 3 3 3 4 4 struct VS_INPUT { … … 39 39 return tex2D(Texture, uv); 40 40 } 41 42 VS_OUTPUT BlurCubeFaceVS(VS_INPUT IN) { 43 VS_OUTPUT OUT; 44 OUT.hPosition = IN.Position; 45 OUT.Position = OUT.hPosition; 46 return OUT; 47 } 48 49 float4 BlurCubeFacePS(VS_OUTPUT IN, 50 uniform samplerCUBE Texture : register(s0), 51 uniform float width, 52 uniform float height, 53 uniform float face ) : COLOR 54 { 55 56 float2 pixel = float2(2.0 / width, 2.0 / height); 57 float2 uv = IN.Position + pixel * 0.5; 58 59 float4 sum = float4(0,0,0,0); 60 61 for(int i = 0; i < samplesU; i++) 62 for(int j = 0; j < samplesV; j++) 63 { 64 float3 dir; 65 float2 pos = uv + float2(i - samplesU * 0.5,j - samplesV * 0.5) * pixel; 66 if (face == 0) dir = float3(1, pos.y, -pos.x); 67 if (face == 1) dir = float3(-1, pos.y, pos.x); 68 if (face == 2) dir = float3(pos.x, 1, -pos.y); 69 if (face == 3) dir = float3(pos.x, -1, pos.y); 70 if (face == 4) dir = float3(pos.x, pos.y, 1); 71 if (face == 5) dir = float3(-pos.x, pos.y,-1); 72 73 sum += texCUBE(Texture, dir); 74 } 75 76 77 sum /= samplesU * samplesV; 78 79 return sum; 80 //return texCUBE(Texture, float3(uv, 1)) + face * 0.0000001; 81 } -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_CauCube.hlsl
r1487 r1691 23 23 { 24 24 OUT.color = float4(0,0,0,0); 25 OUT.hPosition = float4(0, 0, 1000000, 1);25 OUT.hPosition = float4(0, 0, -1000000, 1); 26 26 } 27 27 else … … 43 43 sumdist += dist; 44 44 valids++; 45 } 45 } 46 46 47 47 float4 pos2 = tex2Dlod(PhotonHitMap, float4(uv + float2(-pixel, pixel),0,0)); … … 68 68 valids++; 69 69 } 70 71 float avrdist = sumdist / 4;//valids;72 float maxdist = 1;73 intensity = max(maxdist - avrdist, 0.0) / maxdist;74 70 //if(valids == 0) sumdist = 100000; 71 float avrdist = sumdist / valids; 72 //float maxdist = 10; 73 //intensity = max(maxdist - avrdist, 0.0) / maxdist; 74 intensity = 60.0 / (avrdist * avrdist * 3.14); 75 75 //intensity = valids / 4.0;//avrdist; 76 76 -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_DepthShadow.hlsl
r1671 r1691 80 80 float bias = 0.001; 81 81 float4 light = float4(1,1,1,1); 82 float4 shadow = float4(0. 85,0.85,0.85,1);82 float4 shadow = float4(0.25,0.25,0.25,1); 83 83 //float4 shadow = float4(0,0,0,1); 84 84 -
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Localized_EnvMap.hlsl
r1525 r1691 47 47 }*/ 48 48 49 50 51 49 #define LIN_ITERATIONCOUNT 8 50 #define SECANT_ITERATIONCOUNT 3 51 52 float3 Hit(float3 x, float3 R, samplerCUBE mp) 53 { 54 R = normalize(R); 55 float3 xNorm = normalize(x); 56 float3 dt = (R - xNorm) / (float) LIN_ITERATIONCOUNT; 57 //float3 pN = normalize(cross(R, xNorm)); 58 //float3 N = normalize(cross(pN,R)); 59 //float d = dot(x, N); 60 61 float3 under = x; 62 float3 over = R; 63 float dUnder = readDistanceCubeMap( mp, x); 64 float dOver = readDistanceCubeMap( mp, R); 65 66 for(int i = 0; i < LIN_ITERATIONCOUNT; i++) 67 { 68 float3 dir = normalize(x + dt * i); 69 float dist = readDistanceCubeMap( mp, dir); 70 float3 point = dir * dist; 71 72 float t = length(x) / dot(dir,xNorm); 73 74 if(dist > t) //undershooting 75 { 76 under = normalize(point); 77 dUnder = dist; 78 } 79 else //overshooting 80 { 81 over = normalize(point); 82 dOver = dist; 83 i = LIN_ITERATIONCOUNT; 84 } 85 86 /* 87 88 if( dot(N, point) > d)//undershooting 89 under = normalize(point); 90 else //overshooting 91 { 92 over = normalize(point); 93 i = LIN_ITERATIONCOUNT; 94 } 95 */ 96 } 97 98 float r1 = length(x) * ctan(acos(dot(under, xNorm))); 99 float r2 = length(x) * ctan(acos(dot(over, xNorm))); 100 float rl = dUnder; 101 102 float ppp = dOver / readDistanceCubeMap( mp, x); // |p|/|p| 103 float dun = 0, pun = ppp, dov = 0, pov = 0; 104 float dl = rl * ( 1 - ppp ); // eq. 2 105 float3 l = x + R * dl; // ray equation 106 107 for( int i = 0; i < SECANT_ITERATIONCOUNT; i++ ) 108 { 109 float llp = length( l ) / readDistanceCubeMap( mp, l); // |l|/|l| 110 if ( llp < 0.999f ) // undershooting 111 { 112 dun = dl; pun = llp; // last undershooting 113 dl += ( dov == 0 ) ? rl * ( 1 - llp ) : // eq. 2 114 ( dl - dov ) * ( 1 - llp ) / ( llp - pov ); // eq. 3 115 } else if ( llp > 1.001f ) // overshooting 116 { 117 dov = dl; pov = llp; // last overshooting 118 dl += ( dl -dun ) * ( 1 - llp ) / ( llp - pun );// eq. 3 119 } 120 l = x + R * dl; // ray equation 121 } 122 123 return (under + over)/2.0; 124 } 125 126 /* 52 127 // This function is called several times. 53 128 float3 Hit( float3 x, float3 R, samplerCUBE mp ) … … 78 153 return l; // computed hit point 79 154 } 155 */ 80 156 81 157 void LocalizedVS(float4 position : POSITION, … … 163 239 newTexCoord = R; 164 240 165 //newTexCoord = Hit(mPos, R, DistanceMap);166 167 Color = readCubeMap(CubeMap, newTexCoord ) + lastCenter.x*0.000001;241 newTexCoord = Hit(mPos, R, DistanceMap); 242 243 Color = readCubeMap(CubeMap, newTexCoord ) /*+ lastCenter.x*0.000001*/; 168 244 169 245 float ctheta_in = dot(mNormal,R); … … 235 311 newTexCoord = Hit(mPos, R, DistanceMap); 236 312 237 Color = float4(n ormalize(newTexCoord),1);313 Color = float4(newTexCoord, 1); 238 314 239 315 //Color = 0.0001 * Color + float4(0,0,1,1);
Note: See TracChangeset
for help on using the changeset viewer.