Changeset 2901 for GTP/trunk/App/Demos
- Timestamp:
- 09/04/08 10:14:18 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
r2900 r2901 808 808 </File> 809 809 <File 810 RelativePath=".\src\shaders\ssao 2.cg"810 RelativePath=".\src\shaders\ssao3d.cg" 811 811 > 812 812 </File> -
GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
r2897 r2901 19 19 # shader stuff 20 20 21 # ssao exponential smoothing factor 22 expFactor=0.1f 23 #numSsaoSamples=8 21 # ssao temporal coherence factor 22 tempCohFactor=100.0f -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r2900 r2901 119 119 static void GenerateSamples(int sampling) 120 120 { 121 static SphericalSampleGenerator gauss(NUM_SAMPLES, 0.5f);121 SphericalSampleGenerator gauss(NUM_SAMPLES, 1.0f); 122 122 gauss.Generate((float *)samples3); 123 /* 123 124 /* 124 125 switch (sampling) 125 126 { … … 150 151 float *randomNormals = new float[w * h * 3]; 151 152 153 //SphericalSampleGenerator gauss(w * h, 1.0f); 154 //gauss.Generate(randomNormals); 155 152 156 static HaltonSequence halton; 153 157 float r[2]; … … 158 162 halton.GetNext(2, r); 159 163 160 /* 161 const float theta = 2.0f * acos(sqrt(1.0f - rx)); 162 163 randomNormals[i + 0] = cos(theta); 164 randomNormals[i + 1] = sin(theta); 165 randomNormals[i + 2] = 0;*/ 164 165 //const float theta = 2.0f * acos(sqrt(1.0f - rx)); 166 //randomNormals[i + 0] = cos(theta); 167 //randomNormals[i + 1] = sin(theta); 168 //randomNormals[i + 2] = 0; 166 169 167 170 const float theta = 2.0f * acos(sqrt(1.0f - r[0])); … … 272 275 CG_SOURCE, 273 276 //"src/shaders/ssao.cg", 274 "src/shaders/ssao 2.cg",277 "src/shaders/ssao3d.cg", 275 278 RenderState::sCgFragmentProfile, 276 279 "main", … … 294 297 sOldTexParam = cgGetNamedParameter(sCgSsaoProgram, "oldTex"); 295 298 296 cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue( 3.0f, 17.0f));299 cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(1.0f, 3.0f)); 297 300 sSamplesParam = cgGetNamedParameter(sCgSsaoProgram, "samples"); 298 301 } … … 328 331 sOldIllumTexGiParam = cgGetNamedParameter(sCgGiProgram, "oldIllumTex"); 329 332 330 cgGLSetParameter1f(sNoiseMultiplierGiParam, RandomValue( 3.0f, 17.0f));333 cgGLSetParameter1f(sNoiseMultiplierGiParam, RandomValue(1.0f, 3.0f)); 331 334 } 332 335 else … … 421 424 const Matrix4x4 &oldProjViewMatrix, 422 425 const Matrix4x4 &projViewMatrix, 423 float expFactor,426 float tempCohFactor, 424 427 ShadowMap *shadowMap) 425 428 { … … 462 465 { 463 466 case SSAO: 464 ComputeSsao(fbo, expFactor, oldProjViewMatrix, projViewMatrix);467 ComputeSsao(fbo, tempCohFactor, oldProjViewMatrix, projViewMatrix); 465 468 CombineSsao(fbo); 466 469 break; 467 470 case GI: 468 ComputeGlobIllum(fbo, expFactor, oldProjViewMatrix);471 ComputeGlobIllum(fbo, tempCohFactor, oldProjViewMatrix); 469 472 CombineIllum(fbo); 470 473 break; … … 492 495 493 496 void DeferredRenderer::ComputeSsao(FrameBufferObject *fbo, 494 float expFactor,497 float tempCohFactor, 495 498 const Matrix4x4 &oldProjViewMatrix, 496 499 const Matrix4x4 &projViewMatrix … … 550 553 cgGLSetParameter1f(sMaxDepthParam, mScaleFactor); 551 554 552 cgGLSetParameter1f(sTemporalCoherenceParam, (mUseTemporalCoherence && !mRegenerateSamples) ? 255: 0);555 cgGLSetParameter1f(sTemporalCoherenceParam, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0); 553 556 554 557 if (mUseTemporalCoherence || mRegenerateSamples) … … 716 719 717 720 void DeferredRenderer::ComputeGlobIllum(FrameBufferObject *fbo, 718 float expFactor, 719 const Matrix4x4 &oldProjViewMatrix 720 ) 721 float tempCohFactor, 722 const Matrix4x4 &oldProjViewMatrix) 721 723 { 722 724 cgGLSetMatrixParameterfc(sOldModelViewProjMatrixGiParam, (const float *)oldProjViewMatrix.x); 723 725 724 //GLuint colorsTex = mFbo->GetColorBuffer(0)->GetTexture();725 726 GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); 726 727 GLuint positionsTex = fbo->GetColorBuffer(1)->GetTexture(); … … 740 741 741 742 // read the second buffer, write to the first buffer 742 //mNewFbo->Bind();743 743 mFbo->Bind(); 744 744 745 745 glDrawBuffers(2, mrt + mFboIndex); 746 746 747 //GLuint oldSsaoTex = mOldFbo->GetColorBuffer(0)->GetTexture();748 //GLuint oldIllumTex = mOldFbo->GetColorBuffer(1)->GetTexture();749 750 747 GLuint oldSsaoTex = mFbo->GetColorBuffer(2 - mFboIndex)->GetTexture(); 751 748 GLuint oldIllumTex = mFbo->GetColorBuffer(2 - mFboIndex + 1)->GetTexture(); … … 776 773 cgGLSetParameter1f(sMaxDepthGiParam, mScaleFactor); 777 774 778 cgGLSetParameter1f(sTemporalCoherenceGiParam, (mUseTemporalCoherence && !mRegenerateSamples) ? 255: 0);775 cgGLSetParameter1f(sTemporalCoherenceGiParam, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0); 779 776 780 777 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h
r2900 r2901 41 41 const Matrix4x4 &oldProjViewMatrix, 42 42 const Matrix4x4 &projViewMatrix, 43 float expFactor,43 float tempCohFactor, 44 44 ShadowMap *shadowMap = NULL); 45 45 … … 62 62 protected: 63 63 64 void ComputeSsao(FrameBufferObject *fbo, float expFactor, const Matrix4x4 &oldProjViewMatrix, const Matrix4x4 &projViewMatrix);64 void ComputeSsao(FrameBufferObject *fbo, float tempCohFactor, const Matrix4x4 &oldProjViewMatrix, const Matrix4x4 &projViewMatrix); 65 65 66 void ComputeGlobIllum(FrameBufferObject *fbo, float expFactor, const Matrix4x4 &oldProjViewMatrix);66 void ComputeGlobIllum(FrameBufferObject *fbo, float tempCohFactor, const Matrix4x4 &oldProjViewMatrix); 67 67 68 68 void FirstPass(FrameBufferObject *fbo); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp
r2900 r2901 1 1 #include "common.h" 2 2 #include "SampleGenerator.h" 3 #include "Halton.h" 3 4 4 5 5 using namespace std; 6 6 7 //SampleGenerator::SampleGenerator() {} 7 HaltonSequence SphericalSampleGenerator::sHalton; 8 HaltonSequence PoissonDiscSampleGenerator::sHalton; 9 HaltonSequence GaussianSampleGenerator::sHalton; 10 8 11 9 12 SampleGenerator::SampleGenerator(int numSamples, float radius): … … 98 101 void GaussianSampleGenerator::Generate(float *samples) const 99 102 { 100 static HaltonSequence halton;101 103 float r[2]; 102 104 … … 110 112 for (int i = 0; i < mNumSamples; ++ i) 111 113 { 112 halton.GetNext(2, r);114 sHalton.GetNext(2, r); 113 115 114 116 float exp_x = -(r[0] * r[0]) / (2.0f * sigma * sigma); … … 130 132 void SphericalSampleGenerator::Generate(float *samples) const 131 133 { 132 static HaltonSequence halton;133 134 float r[2]; 135 Sample3 *s = (Sample3 *)samples; 134 136 135 Sample3 *s = (Sample3 *)samples; 137 // idea: use poisson distribution to generate samples 138 PoissonDiscSampleGenerator poisson(mNumSamples, 1.0f); 139 Sample2 *pSamples = new Sample2[mNumSamples]; 140 141 poisson.Generate((float *)pSamples); 136 142 137 143 for (int i = 0; i < mNumSamples; ++ i) 138 144 { 139 halton.GetNext(2, r); 145 //sHalton.GetNext(2, r); 146 r[0] = pSamples[i].x; r[1] = pSamples[i].y; 140 147 141 148 // create stratified samples over sphere 142 149 const float theta = 2.0f * acos(sqrt(1.0f - r[0])); 143 150 const float phi = 2.0f * M_PI * r[1]; 151 152 s[i].x = mRadius * sin(theta) * cos(phi); 153 s[i].y = mRadius * sin(theta) * sin(phi); 154 s[i].z = mRadius * cos(theta); 155 } 144 156 145 s[i].x = sin(theta) * cos(phi); 146 s[i].y = sin(theta) * sin(phi); 147 s[i].z = cos(theta); 148 } 157 delete [] pSamples; 149 158 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.h
r2900 r2901 1 1 #ifndef __SAMPLEGENERATOR_H 2 2 #define __SAMPLEGENERATOR_H 3 4 #include "Halton.h" 3 5 4 6 … … 52 54 53 55 virtual void Generate(float *samples) const; 56 57 protected: 58 59 static HaltonSequence sHalton; 54 60 }; 55 61 … … 62 68 63 69 virtual void Generate(float *samples) const; 70 71 protected: 72 73 static HaltonSequence sHalton; 64 74 }; 65 75 … … 72 82 73 83 virtual void Generate(float *samples) const; 84 85 protected: 86 87 static HaltonSequence sHalton; 74 88 }; 75 89 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2900 r2901 156 156 bool useTemporalCoherence = true; 157 157 158 static float ssao ExpFactor = 0.1f;158 static float ssaoTempCohFactor = 255.0; 159 159 160 160 bool showAlgorithmTime = false; … … 303 303 304 304 env.GetBoolParam(string("useFullScreen"), useFullScreen); 305 env.GetFloatParam(string(" expFactor"), ssaoExpFactor);305 env.GetFloatParam(string("tempCohFactor"), ssaoTempCohFactor); 306 306 env.GetVectorParam(string("camPosition"), camPos); 307 307 env.GetVectorParam(string("camDirection"), camDir); … … 324 324 cout << "useLODs: " << useLODs << endl; 325 325 cout << "camPosition: " << camPos << endl; 326 cout << " expFactor: " << ssaoExpFactor << endl;326 cout << "temporal coherence: " << ssaoTempCohFactor << endl; 327 327 328 328 //cout << "model path: " << model_path << endl; … … 1032 1032 1033 1033 ShadowMap *sm = showShadowMap ? shadowMap : NULL; 1034 ssaoShader->Render(fbo, oldViewProjMatrix, matProjectionView, ssao ExpFactor, sm);1034 ssaoShader->Render(fbo, oldViewProjMatrix, matProjectionView, ssaoTempCohFactor, sm); 1035 1035 } 1036 1036 … … 1142 1142 break; 1143 1143 case '7': 1144 ssao ExpFactor *= 0.5f;1144 ssaoTempCohFactor *= 0.5f; 1145 1145 break; 1146 1146 case '8': 1147 ssao ExpFactor *= 2.0f;1148 if (ssaoExpFactor > 1.0f) ssaoExpFactor = 1.0f;1147 ssaoTempCohFactor *= 2.0f; 1148 //if (ssaoTempCohFactor > 1.0f) ssaoExpFactor = 1.0f; 1149 1149 break; 1150 1150 case '9': -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
r2900 r2901 5 5 //#define NUM_SAMPLES 16 6 6 7 // rule of thumb: approx 1 / NUM_SAMPLES 8 //#define SAMPLE_INTENSITY 0.14f 7 8 // for linear falloff 9 //#define SAMPLE_INTENSITY 500.0f 10 //#define SAMPLE_INTENSITY 100.0f 11 12 // for quadradtc falloff 9 13 //#define SAMPLE_INTENSITY 0.28f 10 #define SAMPLE_INTENSITY 0.32f 14 //#define SAMPLE_INTENSITY 0.32f 15 #define SAMPLE_INTENSITY 2.4f 11 16 12 //#define AREA_SIZE 18e-1f 17 //#define AREA_SIZE 25e-1f 18 //#define AREA_SIZE 6e-1f 13 19 #define AREA_SIZE 8e-1f 14 20 //#define AREA_SIZE 5e-1f … … 17 23 //#define VIEW_CORRECTION_SCALE 0.1f 18 24 19 //#define DISTANCE_SCALE 1e-6f25 //#define DISTANCE_SCALE 5e-7f 20 26 #define DISTANCE_SCALE 1e-6f 27 //#define DISTANCE_SCALE 1.0f 21 28 22 29 #define ILLUM_INTENSITY 5e-1f;
Note: See TracChangeset
for help on using the changeset viewer.