Changeset 3235 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Timestamp:
- 12/26/08 02:44:45 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r3214 r3235 1326 1326 { 1327 1327 while (mGeometry[i]->GetWorldCenter()[axis] < position) ++ i; 1328 //while ((j > 0) && (position < mGeometry[j]->GetWorldCenter()[axis])) -- j; 1328 1329 while (position < mGeometry[j]->GetWorldCenter()[axis]) -- j; 1329 1330 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3233 r3235 301 301 mSunVisiblePixels(0), 302 302 mSavedFrameNumber(-1), 303 mSavedFrameSuffix("") 303 mSavedFrameSuffix(""), 304 mMaxDistance(1e6f) 304 305 { 305 306 /////////// … … 488 489 //////////////// 489 490 490 string dofParams[] = {"colorsTex", "filterOffs", "sceneRange" };491 492 sCgDOFProgram->AddParameters(dofParams, 0, 3);491 string dofParams[] = {"colorsTex", "filterOffs", "sceneRange", "zFocus"}; 492 493 sCgDOFProgram->AddParameters(dofParams, 0, 4); 493 494 494 495 … … 520 521 // todo matt: it is stupid to put num samples and width of kernel into constructor => change this!!! 521 522 PoissonDiscSampleGenerator2D poisson3(NUM_DOF_TABS, 1.0f); 522 poisson2.Generate((float *)dofSamples); 523 poisson3.Generate((float *)dofSamples); 524 525 for (int i = 0; i < NUM_DOF_TABS; ++ i) 526 { 527 dofSamples[i].x *= 1.0f / mWidth; 528 dofSamples[i].y *= 1.0f / mHeight; 529 } 523 530 524 531 //float dofWeights[NUM_PCF_TABS]; … … 567 574 } 568 575 576 /// do depth of field 577 DepthOfField(fbo); 578 569 579 if (useToneMapping) 570 580 { … … 574 584 ToneMap(fbo, imageKey, whiteLum, middleGrey); 575 585 } 576 577 578 /// do depth of field579 DepthOfField(fbo);580 586 581 587 /// compute lense flare … … 1312 1318 FlipFbos(fbo); 1313 1319 1314 float sceneRange = 1.0f;1315 1316 1320 int i = 0; 1321 1322 const float zFocus = 7.0f; 1317 1323 1318 1324 sCgDOFProgram->SetTexture(i ++, colorsTex); 1319 1325 sCgDOFProgram->SetArray2f(i ++, (float *)dofSamples, NUM_DOF_TABS); 1320 sCgDOFProgram->SetValue1f(i ++, mCamera->GetFar() - mCamera->GetNear()); 1326 sCgDOFProgram->SetValue1f(i ++, min(mCamera->GetFar(), mMaxDistance) - mCamera->GetNear()); 1327 sCgDOFProgram->SetValue1f(i ++, zFocus); 1321 1328 1322 1329 DrawQuad(sCgDOFProgram); … … 1442 1449 1443 1450 1451 void DeferredRenderer::SetMaxDistance(float maxDist) 1452 { 1453 mMaxDistance = maxDist; 1454 } 1455 1456 1444 1457 void DeferredRenderer::SetSaveFrame(const string &suffix, int frameNumber) 1445 1458 { -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h
r3232 r3235 88 88 void SetSaveFrame(const std::string &suffix, int frameNumber); 89 89 90 void SetMaxDistance(float maxDist); 91 90 92 91 93 // hack: store the color buffer idx for the currently used flip flop-MRT here … … 158 160 159 161 162 160 163 //////////// 161 164 … … 205 208 int mSavedFrameNumber; 206 209 std::string mSavedFrameSuffix; 210 211 float mMaxDistance; 207 212 }; 208 213 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp
r3234 r3235 109 109 } 110 110 111 cout << "minDist after= " << (float)minDist / mNumSamples<< " #tries: " << tries << endl;111 //cout << "minDist after= " << (float)minDist / mNumSamples<< " #tries: " << tries << endl; 112 112 } 113 113 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3227 r3235 541 541 //LoadModel("fisch.dem", dynamicObjects); 542 542 LoadModel("hbuddha.dem", dynamicObjects); 543 543 544 //LoadModel("venusm.dem", dynamicObjects); 544 545 //LoadModel("camel.dem", dynamicObjects); … … 575 576 dynamicObjects.push_back(ent); 576 577 } 578 579 580 //LoadModel("vienna_full_hp.dem", dynamicObjects); 581 //dynamicObjects.back()->GetTransform()->SetMatrix(transl); 577 582 578 583 … … 2276 2281 { 2277 2282 // usethe maximal visible distance to focus shadow map 2278 float maxVisibleDist= min(camera->GetFar(), traverser->GetMaxVisibleDistance());2279 RenderShadowMap( maxVisibleDist);2283 const float newFar = min(camera->GetFar(), traverser->GetMaxVisibleDistance()); 2284 RenderShadowMap(newFar); 2280 2285 } 2281 2286 // initialize deferred rendering -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/irradiance.cpp
r3216 r3235 1153 1153 deferredShader->SetUseTemporalCoherence(useTemporalCoherence); 1154 1154 deferredShader->SetSortSamples(sortSamples); 1155 deferredShader->SetMaxDistance(traverser->GetMaxVisibleDistance()); 1155 1156 1156 1157 ShadowMap *sm = showShadowMap ? shadowMap : NULL; … … 2017 2018 { 2018 2019 // usethe maximal visible distance to focus shadow map 2019 float maxVisibleDist = min(camera->GetFar(), traverser->GetMaxVisibleDistance());2020 const float maxVisibleDist = min(camera->GetFar(), traverser->GetMaxVisibleDistance()); 2020 2021 RenderShadowMap(maxVisibleDist); 2021 2022 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/depthOfField.cg
r3232 r3235 7 7 8 8 9 float2 ComputeBlurFactors(float4 color, float sceneRange )9 float2 ComputeBlurFactors(float4 color, float sceneRange, float zFocus) 10 10 { 11 11 float2 result; 12 12 13 const float m = 1.0f; 14 const float focalLen = 1.0f; 15 16 const float scale = 5e4f; 17 13 18 // Compute blur factor based on the CoC size scaled and normalized to 0..1 range 14 //float pixCoC = abs(Dlens * focalLen * (Zfocus - v.fDepth) / (Zfocus * (v.fDepth - focalLen))); 19 //float blur = abs(dLens * focalLen * (zFocus - color.w)) / (1e-6f + abs(zFocus * (color.w - focalLen))); 20 21 const float dist = abs(zFocus - color.w); 22 const float blur = scale * m * focalLen * dist / (sceneRange * (1e-6f + abs(color.w + dist * step(0, zFocus - color.w)))); 15 23 16 //float blur = saturate( pixCoC* scale / maxCoC);24 //float blur = saturate(blur * scale / maxCoC); 17 25 18 26 // Depth/blurriness value scaled to 0..1 range 19 //result = float2(v.fDepth/ sceneRange, blur);27 result = float2(color.w / sceneRange, blur); 20 28 21 29 return result; … … 30 38 ) 31 39 { 32 float average = .0f;40 float4 avgCol = float4(.0f); 33 41 float total_w = .0f; 34 42 35 43 for (int i = 0; i < NUM_DOF_TABS; ++ i) 36 44 { 37 float2 sampleTexCoord = texCoords + filterOffs[i] ;45 float2 sampleTexCoord = texCoords + filterOffs[i] * blurFactors.y; 38 46 float4 sampleCol = tex2Dlod(colorsTex, float4(sampleTexCoord, 0, 0)); 39 47 … … 41 49 float w = 1; 42 50 43 av erage+= sampleCol * w;51 avgCol += sampleCol * w; 44 52 total_w += w; 45 53 } 46 54 47 av erage/= max(total_w, 1e-6f);55 avgCol /= max(total_w, 1e-6f); 48 56 49 return saturate(average);57 return avgCol; 50 58 } 51 59 … … 54 62 uniform sampler2D colorsTex, 55 63 uniform float2 filterOffs[NUM_DOF_TABS], 56 uniform float sceneRange 64 uniform float sceneRange, 65 uniform float zFocus 57 66 ): COLOR 58 67 { … … 60 69 const float4 color = tex2Dlod(colorsTex, float4(IN.texCoords, 0, 0)); 61 70 62 float2 blurFactors = ComputeBlurFactors(color, sceneRange); 71 zFocus = min(zFocus, sceneRange * 0.5f); 72 float2 blurFactors = ComputeBlurFactors(color, sceneRange, zFocus); 73 74 //float4 outCol = float4(color.x, color.y, blurFactors.y, color.w); 63 75 float4 outCol = Blur(color, IN.texCoords, blurFactors, colorsTex, filterOffs); 64 76
Note: See TracChangeset
for help on using the changeset viewer.