- Timestamp:
- 12/07/08 23:26:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3206 r3212 76 76 static float ssaoFilterWeights[NUM_SSAO_FILTER_SAMPLES]; 77 77 78 static GLuint sBurstTex; 79 static GLuint sHaloTex[4]; 78 80 79 81 int DeferredRenderer::colorBufferIdx = 0; 82 83 84 static void PrepareLenseFlare() 85 { 86 sBurstTex = new Texture("burst.jpg"); 87 88 Texture(const std::string &filename); 89 90 glEnable(GL_TEXTURE_2D); 91 glGenTextures(1, &sBurstTex); 92 glBindTexture(GL_TEXTURE_2D, sBurstTex); 93 94 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 95 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 96 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 97 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 98 99 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, randomNormals); 100 101 glBindTexture(GL_TEXTURE_2D, 0); 102 glDisable(GL_TEXTURE_2D); 103 104 delete [] randomNormals; 105 106 cout << "prepared lense flare textures" << endl; 107 108 PrintGLerror("prepare lense flare"); 109 } 80 110 81 111 … … 300 330 mShadingMethod(DEFAULT), 301 331 mIllumFboIndex(0), 302 mSortSamples(true) 332 mSortSamples(true), 333 mKernelRadius(1e-8f), 334 mSampleIntensity(0.2f) 303 335 { 304 336 /////////// 305 337 //-- the flip-flop fbos 306 338 307 const int dsw = w / 2; const int dsh = h / 2;308 //const int dsw = w; const int dsh = h;339 //const int dsw = w / 2; const int dsh = h / 2; 340 const int dsw = w; const int dsh = h; 309 341 310 342 mIllumFbo = new FrameBufferObject(dsw, dsh, FrameBufferObject::DEPTH_NONE); … … 321 353 322 354 /////////////// 323 //-- the downsampled ssao + color bleeding textures: as GI is mostly low frequency, we can use lower resolution toimprove performance 355 //-- the downsampled ssao + color bleeding textures: 356 //-- as GI is mostly low frequency, we can use lower resolution toimprove performance 324 357 325 358 mDownSampleFbo = new FrameBufferObject(dsw, dsh, FrameBufferObject::DEPTH_NONE); … … 327 360 mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 328 361 // downsample buffer for the normal texture 329 mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST); 362 mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 363 330 364 331 365 for (int i = 0; i < 2; ++ i) … … 395 429 "samples", "bl", "br", "tl", "tr", 396 430 "modelViewProj", "oldModelViewProj", "oldEyePos", "oldbl", "oldbr", 397 "oldtl", "oldtr", "attribsTex" };398 sCgSsaoProgram->AddParameters(ssaoParams, 0, 18);431 "oldtl", "oldtr", "attribsTex", "kernelRadius", "sampleIntensity"}; 432 sCgSsaoProgram->AddParameters(ssaoParams, 0, 20); 399 433 400 434 string giParams[] = … … 702 736 703 737 for (int j = 0; j < 4; ++ j, ++ i) 738 { 704 739 sCgSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z); 740 } 705 741 706 742 sCgSsaoProgram->SetTexture(i ++, attribsTex); 743 sCgSsaoProgram->SetValue1f(i ++, mKernelRadius); 744 sCgSsaoProgram->SetValue1f(i ++, mSampleIntensity); 707 745 708 746 … … 957 995 958 996 997 #if TODO 998 999 void DeferredRenderer::SetNumSamples(int numSamples) 1000 { 1001 mNumSamples = numSamples; 1002 } 1003 1004 #endif 1005 1006 1007 void DeferredRenderer::SetSampleIntensity(float sampleIntensity) 1008 { 1009 mSampleIntensity = sampleIntensity; 1010 } 1011 1012 1013 void DeferredRenderer::SetKernelRadius(float kernelRadius) 1014 { 1015 mKernelRadius = kernelRadius; 1016 } 1017 1018 959 1019 void DeferredRenderer::ComputeToneParameters(FrameBufferObject *fbo, 960 1020 DirectionalLight *light, … … 1058 1118 mDownSampleFbo->Bind(); 1059 1119 1060 // prepare downsampled colorand normal texture for ssao1120 // prepare downsampled depth and normal texture for ssao 1061 1121 glDrawBuffers(2, mrt); 1062 1122 … … 1066 1126 PrintGLerror("prepareSsao"); 1067 1127 } 1068 1069 1128 1070 1129 … … 1197 1256 } 1198 1257 1258 1259 void DeferredRenderer::LenseFlare(FrameBufferObject *fbo) 1260 { 1261 ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 1262 1263 FlipFbos(fbo); 1264 1265 sCgLenseFlareProgram->SetTexture(0, colorsTex); 1266 sCgLenseFlareProgram->SetTexture(1, sBurstTex); 1267 sCgLenseFlareProgram->SetTexture(2, sHaloTex[0]); 1268 sCgLenseFlareProgram->SetTexture(3, sHaloTex[1]); 1269 sCgLenseFlareProgram->SetValue1f(4, sHaloTex[2]); 1270 sCgLenseFlareProgram->SetValue1f(5, sHaloTex[3]); 1271 1272 DrawQuad(sCgLenseFlareProgram); 1273 1274 PrintGLerror("LenseFlare"); 1275 } 1276 1277 1199 1278 } // namespace
Note: See TracChangeset
for help on using the changeset viewer.