- Timestamp:
- 12/08/08 18:48:21 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3213 r3214 79 79 static float ssaoFilterWeights[NUM_SSAO_FILTER_SAMPLES]; 80 80 81 static Texture *sHaloTex[ 4];81 static Texture *sHaloTex[5]; 82 82 83 83 int DeferredRenderer::colorBufferIdx = 0; … … 300 300 static void PrepareLenseFlare() 301 301 { 302 string textures[] = {" lens1.jpg", "lens2.jpg", "lens3.jpg", "lens4.jpg"};303 304 for (int i = 0; i < 4; ++ i)302 string textures[] = {"flare4.tga", "lens2.jpg", "lens3.jpg", "lens4.jpg", "lens1.jpg"}; 303 304 for (int i = 0; i < 5; ++ i) 305 305 { 306 306 sHaloTex[i] = new Texture(model_path + textures[i]); 307 307 308 sHaloTex[i]->SetBoundaryModeS(Texture:: CLAMP);309 sHaloTex[i]->SetBoundaryModeT(Texture:: CLAMP);308 sHaloTex[i]->SetBoundaryModeS(Texture::BORDER); 309 sHaloTex[i]->SetBoundaryModeT(Texture::BORDER); 310 310 311 311 sHaloTex[i]->Create(); … … 501 501 string lenseFlareParams[] = 502 502 {"colorsTex", "flareTex1", "flareTex2", "flareTex3", "flareTex4", 503 " vectorToLight", "distanceToLight"};504 505 sCgLenseFlareProgram->AddParameters(lenseFlareParams, 0, 7);503 "flareTex5", "vectorToLight", "distanceToLight"}; 504 505 sCgLenseFlareProgram->AddParameters(lenseFlareParams, 0, 8); 506 506 507 507 … … 555 555 bool useToneMapping, 556 556 bool useAntiAliasing, 557 bool lightSourceVisible, 557 558 ShadowMap *shadowMap 558 559 ) … … 567 568 if (mShadingMethod != 0) 568 569 { 569 // downsample fbo buffers 570 PrepareSsao(fbo); 570 PrepareSsao(fbo); // downsample fbo buffers 571 571 } 572 572 … … 584 584 CombineIllum(fbo); 585 585 break; 586 default: // DEFAULT586 default: 587 587 // do nothing: standard deferred shading 588 588 break; … … 598 598 599 599 600 LenseFlare(fbo, light); 600 if (lightSourceVisible) 601 LenseFlare(fbo, light); 601 602 602 603 // multisampling is difficult / costly with deferred shading … … 1277 1278 // the sun is a large distance in the reverse light direction 1278 1279 // => extrapolate light pos 1279 1280 1280 const Vector3 lightPos = light->GetDirection() * -1e3f; 1281 1281 1282 Vector3 projLightPos = mProjViewMatrix * lightPos * 0.5f + Vector3(0.5f); 1283 cout << "lightPos " << projLightPos << endl; 1284 1285 // check if light is visible in the image 1286 if ((projLightPos.x < -0.2f) || (projLightPos.y < -0.2f) || 1287 (projLightPos.x >= 1.2f) || (projLightPos.y >= 1.2f)) 1282 float w; 1283 Vector3 projLightPos = mProjViewMatrix.Transform(w, lightPos, 1.0f); 1284 projLightPos /= w; 1285 projLightPos = projLightPos * 0.5f + Vector3(0.5f); 1286 1287 //Vector3 dummy = mProjViewMatrix * lightPos; 1288 1289 // check if light out of image range 1290 /*if ((projLightPos.x < -0.2f) || (projLightPos.y < -0.2f) || 1291 (projLightPos.x >= 1.2f) || (projLightPos.y >= 1.2f) || 1292 (w < .0f)) 1288 1293 return; 1289 1294 */ 1290 1295 // vector to light from screen center in texture space 1291 1296 Vector3 vectorToLight = projLightPos - Vector3(0.5f); … … 1295 1300 vectorToLight /= distanceToLight; 1296 1301 1297 cout << "dist " << distanceToLight << " v " << vectorToLight << endl;1302 //cout << "dist " << distanceToLight << " v " << vectorToLight << endl; 1298 1303 1299 1304 … … 1310 1315 sCgLenseFlareProgram->SetTexture(i ++, sHaloTex[2]->GetId()); 1311 1316 sCgLenseFlareProgram->SetTexture(i ++, sHaloTex[3]->GetId()); 1317 sCgLenseFlareProgram->SetTexture(i ++, sHaloTex[4]->GetId()); 1312 1318 sCgLenseFlareProgram->SetValue2f(i ++, vectorToLight.x, vectorToLight.y); 1313 1319 sCgLenseFlareProgram->SetValue1f(i ++, distanceToLight);
Note: See TracChangeset
for help on using the changeset viewer.