- Timestamp:
- 02/23/09 18:33:26 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3325 r3326 268 268 269 269 270 static void UpdateSampleTex(Sample2 *samples, int numSamples) 271 { 272 glEnable(GL_TEXTURE_2D); 273 glBindTexture(GL_TEXTURE_2D, sampleTex2D); 274 275 const int w = numSamples; const int h = 1; 276 277 float *tempBuffer = new float[numSamples * 3]; 278 279 for (int i = 0; i < numSamples; ++ i) 280 { 281 tempBuffer[i * 3 + 0] = samples[i].x; 282 tempBuffer[i * 3 + 1] = samples[i].y; 283 tempBuffer[i * 3 + 2] = 0; 284 285 } 286 287 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGB, GL_FLOAT, (float *)tempBuffer); 288 289 glBindTexture(GL_TEXTURE_2D, 0); 290 glDisable(GL_TEXTURE_2D); 291 292 cout << "updated sample texture" << endl; 293 294 delete [] tempBuffer; 295 296 PrintGLerror("noisetexture"); 297 } 298 299 270 300 static void CreateSampleTex(Sample2 *samples, int numSamples) 271 301 { … … 279 309 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 280 310 281 int w = numSamples; 282 int h = 1; 311 const int w = numSamples; const int h = 1; 283 312 284 313 float *tempBuffer = new float[numSamples * 3]; … … 506 535 507 536 string combineSsaoParams[] = 508 //{"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence"};509 537 {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence", "spatialWeight"}; 510 538 511 //sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 13);512 539 sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 9); 513 540 … … 517 544 string filterSsaoParams[] = 518 545 {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence", "spatialWeight"}; 519 520 546 sCgFilterSsaoProgram->AddParameters(filterSsaoParams, 0, 9); 521 547 … … 549 575 550 576 string prepareSsaoParams[] = 551 {"colorsTex", "normalsTex", "diffVals", "oldTex", "oldTex2",577 {"colorsTex", "normalsTex", "diffVals", "oldTex", 552 578 "oldEyePos", "modelViewProj", "oldModelViewProj", 553 "oldbl", "oldbr", "oldtl", "oldtr"}; 554 579 "oldbl", "oldbr", "oldtl", "oldtr", "myTex"}; 555 580 sCgPrepareSsaoProgram->AddParameters(prepareSsaoParams, 0, 12); 556 581 … … 673 698 // if it hasn't been done yet => just output the latest buffer 674 699 if (!mUseAntiAliasing || !displayAfterAA) 700 { 675 701 Output(fbo); 702 } 676 703 677 704 glEnable(GL_LIGHTING); … … 801 828 // needs longer to converge 802 829 GenerateSamples(mSamplingMethod); 803 CreateSampleTex(samples2, NUM_PRECOMPUTED_SAMPLES); 830 831 if (!sampleTex2D) 832 { 833 CreateSampleTex(samples2, NUM_PRECOMPUTED_SAMPLES); 834 } 835 else 836 { 837 UpdateSampleTex(samples2, NUM_PRECOMPUTED_SAMPLES); 838 } 839 804 840 //if (mSortSamples) { SortSamples(); } 805 841 //sCgSsaoProgram->SetArray2f(i, (float *)samples2, NUM_SAMPLES); … … 936 972 // read the second buffer, write to the first buffer 937 973 mIllumFbo->Bind(); 938 939 974 glDrawBuffers(2, mrt + mIllumFboIndex); 940 975 976 // bind the old buffers for temporal coherence 941 977 GLuint oldSsaoTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex)->GetTexture(); 942 978 GLuint oldIllumTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex + 1)->GetTexture(); … … 1012 1048 GLuint ssaoTex = mIllumFbo->GetColorBuffer(mIllumFboIndex)->GetTexture(); 1013 1049 1014 //mIllumFbo->Bind();1015 //glDrawBuffers(1, mrt + mIllumFboIndex + 1);1016 1050 mTempFbo->Bind(); 1017 1051 glDrawBuffers(1, mrt); … … 1040 1074 GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 1041 1075 GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 1042 //GLuint ssaoTex = mIllumFbo->GetColorBuffer(mIllumFboIndex + 1)->GetTexture();1043 1076 GLuint ssaoTex = mTempFbo->GetColorBuffer(0)->GetTexture(); 1044 1077 … … 1173 1206 // flip flop between illumination buffers 1174 1207 GLuint oldTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex)->GetTexture(); 1175 GLuint oldTex2= mIllumFbo->GetColorBuffer(2 - mIllumFboIndex + 1)->GetTexture();1208 GLuint myTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex + 1)->GetTexture(); 1176 1209 1177 1210 int i = 0; … … 1181 1214 sCgPrepareSsaoProgram->SetTexture(i ++, diffVals); 1182 1215 sCgPrepareSsaoProgram->SetTexture(i ++, oldTex); 1183 sCgPrepareSsaoProgram->SetTexture(i ++, oldTex2);1184 1216 1185 1217 Vector3 de; … … 1193 1225 sCgPrepareSsaoProgram->SetMatrix(i ++, mOldProjViewMatrix); 1194 1226 1227 1195 1228 for (int j = 0; j < 4; ++ j, ++ i) 1196 1229 { 1197 1230 sCgPrepareSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z); 1198 1231 } 1232 1233 sCgPrepareSsaoProgram->SetTexture(i ++, myTex); 1199 1234 1200 1235 glPushAttrib(GL_VIEWPORT_BIT); … … 1244 1279 ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 1245 1280 GLuint colorsTex = colorBuffer->GetTexture(); 1246 //FrameBufferObject::Release();1281 1247 1282 1248 1283 FlipFbos(fbo); … … 1272 1307 DrawQuad(sCgDownSampleProgram); 1273 1308 1274 PrintGLerror(" output");1309 PrintGLerror("Output"); 1275 1310 } 1276 1311 … … 1279 1314 { 1280 1315 for (int i = 0; i < 4; ++ i) 1316 { 1281 1317 mOldCornersView[i] = mCornersView[i]; 1318 } 1282 1319 1283 1320 mOldProjViewMatrix = mProjViewMatrix;
Note: See TracChangeset
for help on using the changeset viewer.