- Timestamp:
- 09/03/08 22:40:35 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r2899 r2900 42 42 43 43 static CGparameter sOldModelViewProjMatrixParam; 44 static CGparameter sModelViewProjMatrixParam; 44 45 static CGparameter sMaxDepthParam; 45 46 static CGparameter sSamplesParam; … … 96 97 97 98 // ssao random spherical samples 98 static Sample2 samples[NUM_SAMPLES]; 99 static Sample2 samples2[NUM_SAMPLES]; 100 static Sample2 samples3[NUM_SAMPLES]; 99 101 100 102 static int colorBufferIdx = 0; … … 117 119 static void GenerateSamples(int sampling) 118 120 { 121 static SphericalSampleGenerator gauss(NUM_SAMPLES, 0.5f); 122 gauss.Generate((float *)samples3); 123 /* 119 124 switch (sampling) 120 125 { … … 122 127 { 123 128 static PoissonDiscSampleGenerator poisson(NUM_SAMPLES, 1.0f); 124 poisson.Generate(( Sample2 *)samples);129 poisson.Generate((float *)samples2); 125 130 } 126 131 break; … … 128 133 { 129 134 //static GaussianSampleGenerator gauss(NUM_SAMPLES, 0.5f); 130 //gauss.Generate(( Sample2 *)samples);135 //gauss.Generate((float *)samples2); 131 136 132 137 static SphericalSampleGenerator gauss(NUM_SAMPLES, 0.5f); 133 gauss.Generate(( Sample2 *)samples);138 gauss.Generate((float *)samples3); 134 139 } 135 140 break; 136 141 default: 137 142 break; 138 } 143 }*/ 139 144 } 140 145 … … 145 150 float *randomNormals = new float[w * h * 3]; 146 151 152 static HaltonSequence halton; 153 float r[2]; 154 147 155 for (int i = 0; i < w * h * 3; i += 3) 148 156 { 149 157 // create random samples on a circle 150 const float rx = RandomValue(0, 1); 158 halton.GetNext(2, r); 159 160 /* 151 161 const float theta = 2.0f * acos(sqrt(1.0f - rx)); 152 162 153 //randomNormals[i + 0] = (GLubyte)((cos(theta) * 0.5f + 0.5f) * 255.0f);154 //randomNormals[i + 1] = (GLubyte)((sin(theta) * 0.5f + 0.5f) * 255.0f);155 163 randomNormals[i + 0] = cos(theta); 156 164 randomNormals[i + 1] = sin(theta); 157 randomNormals[i + 2] = 0; 165 randomNormals[i + 2] = 0;*/ 166 167 const float theta = 2.0f * acos(sqrt(1.0f - r[0])); 168 const float phi = 2.0f * M_PI * r[1]; 169 170 randomNormals[i + 0] = sin(theta) * cos(phi); 171 randomNormals[i + 1] = sin(theta) * sin(phi); 172 randomNormals[i + 2] = cos(theta); 158 173 } 159 174 … … 197 212 //-- the flip-flop fbos 198 213 199 /*mNewFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE);200 201 mNewFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false);202 mNewFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false);203 204 205 ///////////////////////206 207 mOldFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE);208 209 mOldFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false);210 mOldFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false);*/211 212 214 mFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 213 215 … … 269 271 cgCreateProgramFromFile(context, 270 272 CG_SOURCE, 271 "src/shaders/ssao.cg", 273 //"src/shaders/ssao.cg", 274 "src/shaders/ssao2.cg", 272 275 RenderState::sCgFragmentProfile, 273 276 "main", … … 285 288 286 289 sOldModelViewProjMatrixParam = cgGetNamedParameter(sCgSsaoProgram, "oldModelViewProj"); 290 sModelViewProjMatrixParam = cgGetNamedParameter(sCgSsaoProgram, "mymodelViewProj"); 287 291 sMaxDepthParam = cgGetNamedParameter(sCgSsaoProgram, "maxDepth"); 288 292 sTemporalCoherenceParam = cgGetNamedParameter(sCgSsaoProgram, "temporalCoherence"); … … 416 420 void DeferredRenderer::Render(FrameBufferObject *fbo, 417 421 const Matrix4x4 &oldProjViewMatrix, 422 const Matrix4x4 &projViewMatrix, 418 423 float expFactor, 419 424 ShadowMap *shadowMap) … … 457 462 { 458 463 case SSAO: 459 ComputeSsao(fbo, expFactor, oldProjViewMatrix );464 ComputeSsao(fbo, expFactor, oldProjViewMatrix, projViewMatrix); 460 465 CombineSsao(fbo); 461 466 break; … … 487 492 488 493 void DeferredRenderer::ComputeSsao(FrameBufferObject *fbo, 489 float expFactor, 490 const Matrix4x4 &oldProjViewMatrix 491 ) 492 { 494 float expFactor, 495 const Matrix4x4 &oldProjViewMatrix, 496 const Matrix4x4 &projViewMatrix 497 ) 498 { 499 static Matrix4x4 biasMatrix(0.5f, 0.0f, 0.0f, 0.5f, 500 0.0f, 0.5f, 0.0f, 0.5f, 501 0.0f, 0.0f, 0.5f, 0.5f, 502 0.0f, 0.0f, 0.0f, 1.0f); //bias from [-1, 1] to [0, 1] 503 504 Matrix4x4 m = projViewMatrix * biasMatrix; 505 493 506 cgGLSetMatrixParameterfc(sOldModelViewProjMatrixParam, (const float *)oldProjViewMatrix.x); 507 cgGLSetMatrixParameterfc(sModelViewProjMatrixParam, (const float *)m.x); 494 508 495 509 GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); … … 547 561 // needs longer to converge 548 562 GenerateSamples(mSamplingMethod); 549 cgGLSetParameterArray2f(sSamplesParam, 0, NUM_SAMPLES, (const float *)samples); 563 564 //cgGLSetParameterArray2f(sSamplesParam, 0, NUM_SAMPLES, (const float *)samples2); 565 cgGLSetParameterArray3f(sSamplesParam, 0, NUM_SAMPLES, (const float *)samples3); 550 566 } 551 567 … … 772 788 // needs longer to converge 773 789 GenerateSamples(mSamplingMethod); 774 cgGLSetParameterArray2f(sSamplesGiParam, 0, NUM_SAMPLES, (const float *)samples );790 cgGLSetParameterArray2f(sSamplesGiParam, 0, NUM_SAMPLES, (const float *)samples2); 775 791 } 776 792 … … 865 881 { 866 882 GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); 867 //GLuint ssaoTex = mNewFbo->GetColorBuffer(0)->GetTexture();868 883 GLuint ssaoTex = mFbo->GetColorBuffer(mFboIndex)->GetTexture(); 869 884
Note: See TracChangeset
for help on using the changeset viewer.