- Timestamp:
- 09/04/08 15:00:42 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r2901 r2903 47 47 static CGparameter sOldTexParam; 48 48 static CGparameter sNoiseTexParam; 49 static CGparameter sNoiseMultiplierParam;50 49 static CGparameter sTemporalCoherenceParam; 51 50 … … 65 64 static CGparameter sOldIllumTexGiParam; 66 65 static CGparameter sNoiseTexGiParam; 67 static CGparameter sNoiseMultiplierGiParam;68 66 static CGparameter sTemporalCoherenceGiParam; 69 67 … … 92 90 static CGparameter sSampleWidthParam; 93 91 92 //#define USE_3D_SSAO 94 93 95 94 … … 97 96 98 97 // ssao random spherical samples 98 #ifdef USE_3D_SSAO 99 100 static Sample2 samples3[NUM_SAMPLES]; 101 102 #else 103 99 104 static Sample2 samples2[NUM_SAMPLES]; 100 static Sample2 samples3[NUM_SAMPLES]; 105 106 #endif 101 107 102 108 static int colorBufferIdx = 0; … … 119 125 static void GenerateSamples(int sampling) 120 126 { 121 SphericalSampleGenerator gauss(NUM_SAMPLES, 1.0f); 122 gauss.Generate((float *)samples3); 123 124 /* 127 #ifdef USE_3D_SSAO 128 129 SphericalSampleGenerator sph(NUM_SAMPLES, 1.0f); 130 sph.Generate((float *)samples3); 131 132 #else 125 133 switch (sampling) 126 134 { 127 135 case DeferredRenderer::POISSON: 128 136 { 129 staticPoissonDiscSampleGenerator poisson(NUM_SAMPLES, 1.0f);137 PoissonDiscSampleGenerator poisson(NUM_SAMPLES, 1.0f); 130 138 poisson.Generate((float *)samples2); 131 139 } … … 133 141 case DeferredRenderer::GAUSS: 134 142 { 135 // static GaussianSampleGenerator gauss(NUM_SAMPLES, 0.5f);136 // gauss.Generate((float *)samples2);137 138 static SphericalSampleGenerator gauss(NUM_SAMPLES, 0.5f);139 gauss.Generate((float *)samples3);143 //PoissonDiscSampleGenerator poisson(NUM_SAMPLES, 1.0f); 144 //poisson.Generate((float *)samples2); 145 146 PseudoRandomGenerator pseudo(NUM_SAMPLES, 1.0f); 147 pseudo.Generate((float *)samples2); 140 148 } 141 149 break; 142 150 default: 151 cout << "should not come here" << endl; 143 152 break; 144 }*/ 153 } 154 #endif 145 155 } 146 156 … … 151 161 float *randomNormals = new float[w * h * 3]; 152 162 153 //SphericalSampleGenerator gauss(w * h, 1.0f);154 //gauss.Generate(randomNormals);155 156 163 static HaltonSequence halton; 157 164 float r[2]; … … 159 166 for (int i = 0; i < w * h * 3; i += 3) 160 167 { 161 // create random samples on a circle162 halton.GetNext(2, r);163 164 168 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;169 #ifdef USE_3D_SSAO 170 //halton.GetNext(2, r); 171 r[0] = RandomValue(0, 1); 172 r[1] = RandomValue(0, 1); 169 173 170 174 const float theta = 2.0f * acos(sqrt(1.0f - r[0])); … … 174 178 randomNormals[i + 1] = sin(theta) * sin(phi); 175 179 randomNormals[i + 2] = cos(theta); 180 #else 181 // create random samples on a circle 182 r[0] = RandomValue(0, 1); 183 //halton.GetNext(1, r); 184 185 const float theta = 2.0f * acos(sqrt(1.0f - r[0])); 186 187 randomNormals[i + 0] = cos(theta); 188 randomNormals[i + 1] = sin(theta); 189 randomNormals[i + 2] = 0; 190 #endif 176 191 } 177 192 … … 274 289 cgCreateProgramFromFile(context, 275 290 CG_SOURCE, 276 //"src/shaders/ssao.cg", 291 #ifdef USE_3D_SSAO 277 292 "src/shaders/ssao3d.cg", 293 294 #else 295 "src/shaders/ssao.cg", 296 #endif 278 297 RenderState::sCgFragmentProfile, 279 298 "main", … … 288 307 sNormalsTexParam = cgGetNamedParameter(sCgSsaoProgram, "normals"); 289 308 sNoiseTexParam = cgGetNamedParameter(sCgSsaoProgram, "noiseTexture"); 290 sNoiseMultiplierParam = cgGetNamedParameter(sCgSsaoProgram, "noiseMultiplier");291 309 292 310 sOldModelViewProjMatrixParam = cgGetNamedParameter(sCgSsaoProgram, "oldModelViewProj"); … … 297 315 sOldTexParam = cgGetNamedParameter(sCgSsaoProgram, "oldTex"); 298 316 299 cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(1.0f, 3.0f));300 317 sSamplesParam = cgGetNamedParameter(sCgSsaoProgram, "samples"); 301 318 } … … 320 337 sNormalsTexGiParam = cgGetNamedParameter(sCgGiProgram, "normals"); 321 338 sNoiseTexGiParam = cgGetNamedParameter(sCgGiProgram, "noiseTexture"); 322 sNoiseMultiplierGiParam = cgGetNamedParameter(sCgGiProgram, "noiseMultiplier");323 339 324 340 sOldModelViewProjMatrixGiParam = cgGetNamedParameter(sCgGiProgram, "oldModelViewProj"); … … 330 346 sOldSsaoTexGiParam = cgGetNamedParameter(sCgGiProgram, "oldSsaoTex"); 331 347 sOldIllumTexGiParam = cgGetNamedParameter(sCgGiProgram, "oldIllumTex"); 332 333 cgGLSetParameter1f(sNoiseMultiplierGiParam, RandomValue(1.0f, 3.0f));334 348 } 335 349 else … … 500 514 ) 501 515 { 516 #ifdef USE_3D_SSAO 502 517 static Matrix4x4 biasMatrix(0.5f, 0.0f, 0.0f, 0.5f, 503 518 0.0f, 0.5f, 0.0f, 0.5f, … … 507 522 Matrix4x4 m = projViewMatrix * biasMatrix; 508 523 524 cgGLSetMatrixParameterfc(sModelViewProjMatrixParam, (const float *)m.x); 525 #endif 526 509 527 cgGLSetMatrixParameterfc(sOldModelViewProjMatrixParam, (const float *)oldProjViewMatrix.x); 510 cgGLSetMatrixParameterfc(sModelViewProjMatrixParam, (const float *)m.x);511 528 512 529 GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); … … 558 575 { 559 576 mRegenerateSamples = false; 560 cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(3.0f, 17.0f));561 577 562 578 // q: should we generate new samples or only rotate the old ones? … … 565 581 GenerateSamples(mSamplingMethod); 566 582 567 //cgGLSetParameterArray2f(sSamplesParam, 0, NUM_SAMPLES, (const float *)samples2); 583 #ifdef USE_3D_SSAO 568 584 cgGLSetParameterArray3f(sSamplesParam, 0, NUM_SAMPLES, (const float *)samples3); 585 #else 586 cgGLSetParameterArray2f(sSamplesParam, 0, NUM_SAMPLES, (const float *)samples2); 587 #endif 569 588 } 570 589 … … 779 798 { 780 799 mRegenerateSamples = false; 781 cgGLSetParameter1f(sNoiseMultiplierGiParam, RandomValue(3.0f, 17.0f));782 800 783 801 // q: should we generate new samples or only rotate the old ones? … … 785 803 // needs longer to converge 786 804 GenerateSamples(mSamplingMethod); 805 806 #ifdef USE_3D_SSAO 807 cgGLSetParameterArray3f(sSamplesGiParam, 0, NUM_SAMPLES, (const float *)samples3); 808 #else 787 809 cgGLSetParameterArray2f(sSamplesGiParam, 0, NUM_SAMPLES, (const float *)samples2); 810 #endif 788 811 } 789 812
Note: See TracChangeset
for help on using the changeset viewer.