- Timestamp:
- 11/24/08 17:33:53 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3155 r3156 445 445 446 446 string prepareSsaoParams[] = 447 {"colorsTex", "oldTex", " modelViewProj", "oldModelViewProj", "oldEyePos",447 {"colorsTex", "oldTex", "oldEyePos", "modelViewProj", "oldModelViewProj", 448 448 "oldbl", "oldbr", "oldtl", "oldtr", "diffVals"}; 449 449 … … 968 968 //sCgSsaoProgram->SetTexture(i ++, normalsTex); 969 969 sCgPrepareSsaoProgram->SetTexture(i ++, oldTex); 970 971 sCgPrepareSsaoProgram->SetMatrix(i ++, mProjViewMatrix);972 sCgPrepareSsaoProgram->SetMatrix(i ++, mOldProjViewMatrix);973 974 for (int j = 0; j < 4; ++ j, ++ i)975 sCgPrepareSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z);976 970 977 971 Vector3 de; … … 981 975 982 976 sCgPrepareSsaoProgram->SetValue3f(i ++, de.x, de.y, de.z); 977 978 sCgPrepareSsaoProgram->SetMatrix(i ++, mProjViewMatrix); 979 sCgPrepareSsaoProgram->SetMatrix(i ++, mOldProjViewMatrix); 980 981 for (int j = 0; j < 4; ++ j, ++ i) 982 sCgPrepareSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z); 983 983 984 984 sCgPrepareSsaoProgram->SetTexture(i ++, diffVals); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg
r3155 r3156 106 106 const float scale = adaptFactor * scaleFactor * ao.z / (adaptFactor + ao.y); 107 107 108 //ao.x = DiscontinuityFilter(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, filterWeights, scale);108 ao.x = DiscontinuityFilter(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, filterWeights, scale); 109 109 } 110 110 111 111 OUT.illum_col.xyz = col.xyz * ao.x; 112 113 OUT.illum_col.xyz = float3(0, ao.x, 0); 114 112 //OUT.illum_col.xyz = float3(0, ao.x, 0); 115 113 //OUT.illum_col.xyz = float3(0, clamp(1.0f - ao.y * 1e-2f, 0, 1), 1); 116 114 OUT.illum_col.w = col.w; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r3155 r3156 251 251 252 252 // compute position from old frame for dynamic objects + translational portion 253 //const float3 translatedPos = diffVec - oldEyePos + worldPos.xyz; 254 const float3 translatedPos = worldPos.xyz; 253 const float3 translatedPos = diffVec - oldEyePos + worldPos.xyz; 255 254 256 255 … … 259 258 260 259 // note: the old model view matrix only holds the view orientation part 261 //float4 backProjPos = mul(oldModelViewProj, float4(translatedPos, 1.0f)); 262 float4 backProjPos = mul(modelViewProj, float4(translatedPos, 1.0f)); 260 float4 backProjPos = mul(oldModelViewProj, float4(translatedPos, 1.0f)); 263 261 backProjPos /= backProjPos.w; 264 262 265 263 // fit from unit cube into 0 .. 1 266 //const float2 oldTexCoords = backProjPos.xy * 0.5f + 0.5f;267 const float2 oldTexCoords = texCoord;264 const float2 oldTexCoords = backProjPos.xy * 0.5f + 0.5f; 265 //const float2 oldTexCoords = texCoord; 268 266 // retrieve the sample from the last frame 269 267 const float4 oldPixel = tex2Dlod(oldTex, float4(oldTexCoords, .0f, .0f)); … … 273 271 274 272 // vector from eye pos to old sample 275 const float3 oldViewDir = viewDir;//Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr);273 const float3 oldViewDir = Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr); 276 274 const float invLen = 1.0f / length(oldViewDir); 277 275 const float projectedEyeSpaceDepth = invLen * length(translatedPos); … … 280 278 281 279 const float squaredLen = diffVec.x * diffVec.x + diffVec.y * diffVec.y + diffVec.z * diffVec.z; 282 283 280 //if (squaredLen < 1e-8f) // object not dynamic 284 281 //{} … … 289 286 && (oldTexCoords.x >= 0.0f) && (oldTexCoords.x < 1.0f) 290 287 && (oldTexCoords.y >= 0.0f) && (oldTexCoords.y < 1.0f) 291 //&& (depthDif <= MIN_DEPTH_DIFF)292 && (depthDif <= 9e-1f)288 && (depthDif <= MIN_DEPTH_DIFF) 289 //&& (depthDif <= 9e-1f) 293 290 ) 294 291 { … … 297 294 else 298 295 { 299 validPixel = 1 .5f;296 validPixel = 10.5f; 300 297 } 301 298 302 return depthDif;303 //return validPixel;299 //return depthDif; 300 return validPixel; 304 301 } 305 302 … … 310 307 uniform float4x4 modelViewProj, 311 308 uniform float4x4 oldModelViewProj, 312 uniform float3 oldEyePos,313 309 uniform float3 oldbl, 314 310 uniform float3 oldbr, 315 311 uniform float3 oldtl, 316 312 uniform float3 oldtr, 313 uniform float3 oldEyePos, 317 314 uniform sampler2D diffVals 318 315 ): COLOR -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3155 r3156 183 183 #endif 184 184 185 //float pixelValid = 0.5f;186 float overallDepth = 0;187 188 #if 0189 185 const float squaredLen = diffVec.x * diffVec.x + diffVec.y * diffVec.y + diffVec.z * diffVec.z; 190 191 if (squaredLen < 1e-8f) // object not dynamic192 {193 for (int i = 0; i < NUM_SAMPLES; ++ i)194 {195 float sampleDif = ComputeDifference(samples[i],196 oldTex,197 oldModelViewProj,198 colors,199 noiseTex,200 scaleFactor,201 bl, br, tl, tr,202 texcoord0,203 oldEyePos,204 oldbl, oldbr, oldtl, oldtr,205 eyeSpaceDepth206 );207 //overallDepth += sampleDif;208 if (sampleDif >= MIN_DEPTH_DIFF) ++ notValid;209 }210 }211 #endif212 186 213 187 const float oldWeight = clamp(oldPixel.y, .0f, temporalCoherence); … … 227 201 // increase the weight for convergence 228 202 newWeight = oldWeight + 1.0f; 229 if ( pixelValid > 1.0f) newWeight = 4.0f;203 if ((pixelValid > 1.0f) && (squaredLen < 1e-8f)) newWeight = 4.0f; 230 204 //if (pixelValid > 1.0f) newWeight = max(15.0f - notValid * 2.0f, 1.0f); 231 205 } … … 461 435 } 462 436 437 463 438 ///////////////// 464 439 //-- compute temporal reprojection … … 482 457 483 458 484 OUT.illum_col.x = ao.y;//(ao.x + oldSsao * (newWeight - 1.0f)) / newWeight;459 OUT.illum_col.x = (ao.x + oldSsao * (newWeight - 1.0f)) / newWeight; 485 460 OUT.illum_col.y = newWeight; 486 461 OUT.illum_col.z = invw;
Note: See TracChangeset
for help on using the changeset viewer.