- Timestamp:
- 02/16/09 17:08:51 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3311 r3313 71 71 static GLuint noiseTex2D = 0; 72 72 static GLuint noiseTex1D = 0; 73 static GLuint sampleTex2D = 0; 74 75 76 static Sample2 samples2[NUM_PRECOMPUTED_SAMPLES]; 73 74 77 75 // ssao random spherical samples 78 //static Sample2 samples2[NUM_SAMPLES]; 79 76 static Sample2 samples2[NUM_SAMPLES]; 77 //#define NUM_PRECOMPUTED_SAMPLES 240 78 //static Sample2 samples2[NUM_PRECOMPUTED_SAMPLES]; 80 79 // pcf samples 81 80 static Sample2 pcfSamples[NUM_PCF_TABS]; … … 92 91 /** Helper method that computes the view vectors in the corners of the current view frustum. 93 92 */ 94 static void ComputeViewVectors(PerspectiveCamera *cam, 95 Vector3 &bl, 96 Vector3 &br, 97 Vector3 &tl, 98 Vector3 &tr) 93 static void ComputeViewVectors(PerspectiveCamera *cam, Vector3 &bl, Vector3 &br, Vector3 &tl, Vector3 &tr) 99 94 { 100 95 Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr; … … 212 207 case DeferredRenderer::SAMPLING_QUADRATIC: 213 208 { 214 QuadraticDiscSampleGenerator2D g(NUM_PRECOMPUTED_SAMPLES, 1.0f);215 //static QuadraticDiscSampleGenerator2D g(NUM_SAMPLES, 1.0f);209 //static QuadraticDiscSampleGenerator2D g(NUM_PRECOMPUTED_SAMPLES, 1.0f); 210 static QuadraticDiscSampleGenerator2D g(NUM_SAMPLES, 1.0f); 216 211 g.Generate((float *)samples2); 217 212 } … … 262 257 263 258 cout << "created noise texture" << endl; 264 265 PrintGLerror("noisetexture");266 }267 268 269 static void CreateSampleTex(Sample2 *samples, int numSamples)270 {271 glEnable(GL_TEXTURE_2D);272 glGenTextures(1, &sampleTex2D);273 glBindTexture(GL_TEXTURE_2D, sampleTex2D);274 275 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);276 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);277 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);278 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);279 280 int w = numSamples;281 int h = 1;282 283 float *tempBuffer = new float[numSamples * 3];284 285 for (int i = 0; i < numSamples; ++ i)286 {287 tempBuffer[i * 3 + 0] = samples[i].x;288 tempBuffer[i * 3 + 1] = samples[i].y;289 tempBuffer[i * 3 + 2] = 0;290 291 }292 293 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, w, h, 0, GL_RGB, GL_FLOAT, (float *)tempBuffer);294 295 glBindTexture(GL_TEXTURE_2D, 0);296 glDisable(GL_TEXTURE_2D);297 298 cout << "created sample texture" << endl;299 300 delete [] tempBuffer;301 259 302 260 PrintGLerror("noisetexture"); … … 469 427 470 428 string ssaoParams[] = 471 429 {"colors", "normals", "oldTex", "noiseTex", "temporalCoherence", 472 430 "samples", "bl", "br", "tl", "tr", 473 431 "modelViewProj", "oldModelViewProj", "oldEyePos", "oldbl", "oldbr", 474 432 "oldtl", "oldtr", "attribsTex", "kernelRadius", "sampleIntensity"}; 475 476 433 sCgSsaoProgram->AddParameters(ssaoParams, 0, 20); 477 434 … … 783 740 sCgSsaoProgram->SetTexture(i ++, noiseTex2D); 784 741 785 sCgSsaoProgram->SetValue1f(i ++, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : .0f); 786 787 if (/*mUseTemporalCoherence || */mRegenerateSamples) 742 sCgSsaoProgram->SetValue1f(i ++, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0); 743 744 static int currentPos = 0; 745 746 if (mUseTemporalCoherence || mRegenerateSamples) 788 747 { 789 748 mRegenerateSamples = false; … … 792 751 // in the first case, the sample patterns look nicer, but the kernel 793 752 // needs longer to converge 794 GenerateSamples(mSamplingMethod); 795 CreateSampleTex(samples2, NUM_PRECOMPUTED_SAMPLES); 753 //if (currentPos + NUM_SAMPLES >= NUM_PRECOMPUTED_SAMPLES) { 754 currentPos = 0; 755 GenerateSamples(mSamplingMethod); 756 //} 757 796 758 //if (mSortSamples) { SortSamples(); } 797 //sCgSsaoProgram->SetArray2f(i, (float *)samples2, NUM_SAMPLES); 798 //sCgSsaoProgram->SetArray2f(i, (float *)samples2, NUM_PRECOMPUTED_SAMPLES); 799 sCgSsaoProgram->SetTexture(i, sampleTex2D); 800 } 801 802 759 sCgSsaoProgram->SetArray2f(i, (float *)samples2 + currentPos, NUM_SAMPLES); 760 761 currentPos += NUM_SAMPLES; 762 } 763 803 764 ++ i; 804 765 805 766 for (int j = 0; j < 4; ++ j, ++ i) 806 {807 767 sCgSsaoProgram->SetValue3f(i, mCornersView[j].x, mCornersView[j].y, mCornersView[j].z); 808 }809 768 810 769 sCgSsaoProgram->SetMatrix(i ++, mProjViewMatrix); … … 815 774 de.y = mOldEyePos.y - mEyePos.y; 816 775 de.z = mOldEyePos.z - mEyePos.z; 817 818 776 819 777 sCgSsaoProgram->SetValue3f(i ++, de.x, de.y, de.z);
Note: See TracChangeset
for help on using the changeset viewer.