Changeset 3375 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Timestamp:
- 07/09/09 10:21:25 (15 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
r3372 r3375 537 537 string deferredShadowParams[] = 538 538 {"colors", "normals", "shadowMap", "noiseTex", "shadowMatrix", 539 "sampleWidth", "lightDir", "eyePos", "samples", "weights"}; 540 541 sCgDeferredShadowProgram->AddParameters(deferredShadowParams, 0, 10); 539 "sampleWidth", "lightDir", "eyePos", "samples", "weights", 540 "aoTex", "useAO"}; 541 542 sCgDeferredShadowProgram->AddParameters(deferredShadowParams, 0, 12); 542 543 543 544 //////////////// … … 630 631 //-- pcf tabs for depth of field 631 632 632 // todo matt: it is stupid to put numsamples and width of kernel into constructor => change this!!!633 // todo matt: bad style to put #samples and width of kernel into constructor => change this!!! 633 634 PoissonDiscSampleGenerator2D poisson3(NUM_DOF_TABS, 1.0f); 634 635 poisson3.Generate((float *)dofSamples); … … 639 640 dofSamples[i].y *= 1.0f / mHeight; 640 641 } 641 642 //float dofWeights[NUM_PCF_TABS];643 //sCgDOFProgram->SetArray1f(2, (float *)dofWeights, NUM_DOF_TABS);644 642 645 643 PrintGLerror("init"); … … 1148 1146 GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 1149 1147 GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 1148 GLuint aoTex = mTempFbo->GetColorBuffer(1)->GetTexture(); 1150 1149 1151 1150 GLuint shadowTex = shadowMap->GetDepthTexture(); … … 1167 1166 sCgDeferredShadowProgram->SetValue3f(6, lightDir.x, lightDir.y, lightDir.z); 1168 1167 sCgDeferredShadowProgram->SetValue3f(7, mEyePos.x, mEyePos.y, mEyePos.z); 1168 1169 sCgDeferredShadowProgram->SetTexture(10, aoTex); 1170 sCgDeferredShadowProgram->SetValue1f(11, float(mShadingMethod == SSAO)); 1169 1171 1170 1172 DrawQuad(sCgDeferredShadowProgram); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp
r3294 r3375 39 39 /* 40 40 mIndices = new unsigned int[mNumVertices]; 41 42 for (int i = 0; i < mNumVertices; ++ i) 43 { 44 mIndices[i] = i; 45 }*/ 41 for (int i = 0; i < mNumVertices; ++ i) { mIndices[i] = i; } 42 */ 46 43 47 44 // prepare vbos -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r3372 r3375 39 39 float4 outColor; 40 40 41 #if 041 #if 1 42 42 // hack: prevent to shade the sky 43 43 if (color.w > DEPTH_THRESHOLD) … … 47 47 else 48 48 { 49 if (useAO > .5f) 50 outColor = (ambient * ao + diffuse) * color; 51 else 52 outColor = (ambient + diffuse) * color; 49 outColor = (useAO > .5f) ? (ambient * ao + diffuse) * color : (ambient + diffuse) * color; 53 50 } 54 51 #else 52 // just output ambient occlusion 55 53 outColor = ao; 56 54 #endif … … 81 79 82 80 OUT.color = col; 81 83 82 // store scaled view vector so wie don't have to normalize for later 84 //OUT.color.w = color.w / length(IN.view); 83 if (0) OUT.color.w = color.w / length(IN.view); 84 85 85 OUT.color.w = color.w; 86 86 … … 150 150 uniform float3 br, 151 151 uniform float3 tl, 152 uniform float3 tr 152 uniform float3 tr, 153 uniform sampler2D aoTex, 154 uniform float useAO 153 155 ) 154 156 { 155 157 pixel OUT; 158 159 float4 ao = 1;//(useAO > .5f) ? tex2Dlod(aoTex, float4(IN.texCoord, 0, 0)) : 1.0f; 156 160 157 161 const float3 normal = tex2D(normals, IN.texCoord.xy); … … 192 196 const float4 ambient = glstate.light[0].ambient; 193 197 // compute shading 194 OUT.color = useShading ? (ambient + diffuse) * color : color; 198 OUT.color = useShading ? (ambient * ao + diffuse) * color : color * ao; 199 195 200 // store scaled view vector from now on so wie don't have to normalize later (e.g., for ssao) 196 //OUT.color.w = color.w / lenView; 201 if (0) OUT.color.w = color.w / lenView; 202 197 203 OUT.color.w = color.w; 198 204 … … 216 222 return color; 217 223 } 218 219 220 /** This shader computes the reprojection and checks221 if the reprojected pixel from last frame is still222 valid in the current frame223 */224 /*inline float2 ComputeInfo(sampler2D oldTex,225 float4 color,226 float3 difVec,227 float2 texCoord,228 float3 viewDir,229 float3 oldEyePos,230 float4x4 modelViewProj,231 float4x4 oldModelViewProj,232 float3 oldbl,233 float3 oldbr,234 float3 oldtl,235 float3 oldtr,236 sampler2D myTex237 )238 {239 // reconstruct position from the eye space depth240 const float eyeSpaceDepth = color.w;241 const float4 worldPos = float4(-viewDir * eyeSpaceDepth, 1.0f);242 243 // compute position from old frame for dynamic objects + translational portion244 const float3 translatedPos = -oldEyePos + worldPos.xyz + difVec;245 246 247 /////////////////248 //-- reproject into old frame and calculate texture position of sample in old frame249 250 // note: the old model view matrix only holds the view orientation part251 float4 backProjPos = mul(oldModelViewProj, float4(translatedPos, 1.0f));252 backProjPos /= backProjPos.w;253 254 // fit from unit cube into 0 .. 1255 const float2 oldTexCoords = backProjPos.xy * .5f + .5f;256 257 // retrieve the sample from the last frame258 const float4 oldPixel = tex2Dlod(oldTex, float4(oldTexCoords, .0f, .0f));259 const float oldDiff = tex2Dlod(myTex, float4(oldTexCoords, .0f, .0f)).x;260 261 // calculate eye space position of sample in old frame262 const float oldEyeSpaceDepth = oldPixel.w;263 264 // vector from eye pos to old sample265 const float3 oldViewDir = Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr);266 const float invLen = 1.0f / length(oldViewDir);267 268 269 // check if the pixel was outside of the frame buffer270 if ((oldTexCoords.x <= .0f) || (oldTexCoords.x >= 1.0f) ||271 (oldTexCoords.y <= .0f) || (oldTexCoords.y >= 1.0f)272 )273 {274 isPixelValid = pixelIsNotValid;275 }276 else if (// check if changed from dynamic to not dynamic object277 (278 // (oldDynamic && !newDynamic) || (!oldDynamic && newDynamic) ||279 (280 (oldEyeSpaceDepth < DEPTH_THRESHOLD) && (projectedEyeSpaceDepth < DEPTH_THRESHOLD) &&281 //(oldDynamic || newDynamic) && // check if we have a dynamic object282 (depthDif > 5e-2f)))//MIN_DEPTH_DIFF)))283 ) // and there is a depth discontinuity284 {285 isPixelValid = pixelCouldBeValid;286 }287 else288 {289 isPixelValid = pixelIsValid;290 }291 292 //isPixelValid = depthDif;293 294 return float3(isPixelValid, abs(oldEyeSpaceDepth - projectedEyeSpaceDepth));295 }296 */297 224 298 225 … … 365 292 const float3 normal = normalize(tex2Dlod(normalsTex, float4(IN.texCoord, 0, 0)).xyz); 366 293 367 // do reprojection and filter out the pixels that are not save368 /* const float2 pValid = PixelValid(oldTex,369 color,370 difVec.xyz,371 IN.texCoord,372 IN.view,373 oldEyePos,374 modelViewProj,375 oldModelViewProj,376 oldbl, oldbr, oldtl, oldtr,377 myTex378 );379 380 pix.color = color;381 pix.color.xy = pValid.xy;382 pix.color.z = color.w;383 */384 294 const float3 translatedPos = 385 295 ComputeTranslatedPos(color, difVec.xyz, IN.view, oldEyePos, oldModelViewProj); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3373 r3375 547 547 pixelValid = 100.0f; 548 548 } 549 else if ( (cosAngle >= 0) &&(distanceDiff > 1e-3f))549 else if (/*(cosAngle >= 0) && */(distanceDiff > 1e-3f)) 550 550 { 551 551 pixelValid = 5.0f; 552 //pixelValid = 100.0f; 552 553 } 553 554 } … … 732 733 if (ao.y > partlyResetThres) 733 734 { 734 const float factor = 2.0f;735 const float factor = 3.0f; 735 736 736 737 oldWeight = min(oldWeight, factor * NUM_SAMPLES);
Note: See TracChangeset
for help on using the changeset viewer.