Changeset 3215 for GTP/trunk/App/Demos/Vis/FriendlyCulling
- Timestamp:
- 12/08/08 23:13:38 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
r3212 r3215 12 12 # triangles per bvh leaf (influences hierarchy depth vs. occlusion power) 13 13 trianglesPerVirtualLeaf=300 14 14 # max depth for searching for nodes for tight bounds 15 15 maxDepthForTestingChildren=3 16 16 … … 34 34 #camDirection=1 0 0 35 35 36 #camPosition=468.025 267.591 182.478 37 #camDirection=0.937282 0.348573 -0 38 39 # bad view point (culling bug!) 40 camPosition=469.381 267.293 184.778 41 camDirection=0.142006 0.645885 -0.750111 42 43 #camPosition=458.412 255.767 182.632 44 #camDirection=0.891691 0.42723 0.149535 45 46 #camPosition=740.137 487.855 188.506 47 #camDirection=0.669256 0.727829 0.149535 48 49 #camPosition=492.678 249.827 187.232 50 #camDirection=-0.651041 -0.693292 -0.309017 36 camPosition=468.025 267.591 182.478 37 camDirection=0.937282 0.348573 -0 51 38 52 39 #lightDirection=-0.8f 1.0f -0.7f … … 57 44 # window options 58 45 59 //winWidth=80060 //winHeight=60046 #winWidth=800 47 #winHeight=600 61 48 62 49 winWidth=1024 … … 83 70 useAA=1 84 71 72 # show lense flare 73 useLenseFlare=1 74 85 75 # use ssao / color bleeding 86 76 useAdvancedShading=1 … … 89 79 turbitity=3.0f 90 80 91 #second bad view point92 //camPosition=465.626 248.788 184.97893 //camDirection=0.0592959 0.998021 0.020942594 95 81 ssaoKernelRadius=8e-1f 96 82 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3214 r3215 328 328 mSortSamples(true), 329 329 mKernelRadius(1e-8f), 330 mSampleIntensity(0.2f) 330 mSampleIntensity(0.2f), 331 mSunVisiblePixels(0) 331 332 { 332 333 /////////// … … 393 394 glDeleteTextures(1, &noiseTex1D); 394 395 } 395 396 397 void DeferredRenderer::SetUseTemporalCoherence(bool temporal)398 {399 mUseTemporalCoherence = temporal;400 }401 402 396 403 397 … … 501 495 string lenseFlareParams[] = 502 496 {"colorsTex", "flareTex1", "flareTex2", "flareTex3", "flareTex4", 503 "flareTex5", "vectorToLight", "distanceToLight" };504 505 sCgLenseFlareProgram->AddParameters(lenseFlareParams, 0, 8);497 "flareTex5", "vectorToLight", "distanceToLight", "sunVisiblePixels"}; 498 499 sCgLenseFlareProgram->AddParameters(lenseFlareParams, 0, 9); 506 500 507 501 … … 555 549 bool useToneMapping, 556 550 bool useAntiAliasing, 557 bool lightSourceVisible,558 551 ShadowMap *shadowMap 559 552 ) … … 597 590 } 598 591 599 600 if (lightSourceVisible) 601 LenseFlare(fbo, light); 592 /// compute lense flare 593 LenseFlare(fbo, light); 602 594 603 595 // multisampling is difficult / costly with deferred shading … … 989 981 990 982 991 void DeferredRenderer::SetSamplingMethod(SAMPLING_METHOD s)992 {993 if (s != mSamplingMethod)994 {995 mSamplingMethod = s;996 mRegenerateSamples = true;997 }998 }999 1000 1001 void DeferredRenderer::SetShadingMethod(SHADING_METHOD s)1002 {1003 if (s != mShadingMethod)1004 {1005 mShadingMethod = s;1006 mRegenerateSamples = true;1007 }1008 }1009 1010 1011 #if TODO1012 1013 void DeferredRenderer::SetNumSamples(int numSamples)1014 {1015 mNumSamples = numSamples;1016 }1017 1018 #endif1019 1020 1021 void DeferredRenderer::SetSampleIntensity(float sampleIntensity)1022 {1023 mSampleIntensity = sampleIntensity;1024 }1025 1026 1027 void DeferredRenderer::SetKernelRadius(float kernelRadius)1028 {1029 mKernelRadius = kernelRadius;1030 }1031 1032 1033 983 void DeferredRenderer::ComputeToneParameters(FrameBufferObject *fbo, 1034 984 DirectionalLight *light, … … 1273 1223 1274 1224 void DeferredRenderer::LenseFlare(FrameBufferObject *fbo, 1275 DirectionalLight *light 1225 DirectionalLight *light 1276 1226 ) 1277 1227 { 1228 // light source not visible 1229 if (!mSunVisiblePixels) return; 1230 1278 1231 // the sun is a large distance in the reverse light direction 1279 1232 // => extrapolate light pos … … 1285 1238 projLightPos = projLightPos * 0.5f + Vector3(0.5f); 1286 1239 1287 //Vector3 dummy = mProjViewMatrix * lightPos;1288 1289 // check if light out of image range1290 /*if ((projLightPos.x < -0.2f) || (projLightPos.y < -0.2f) ||1291 (projLightPos.x >= 1.2f) || (projLightPos.y >= 1.2f) ||1292 (w < .0f))1293 return;1294 */1295 1240 // vector to light from screen center in texture space 1296 1241 Vector3 vectorToLight = projLightPos - Vector3(0.5f); … … 1318 1263 sCgLenseFlareProgram->SetValue2f(i ++, vectorToLight.x, vectorToLight.y); 1319 1264 sCgLenseFlareProgram->SetValue1f(i ++, distanceToLight); 1265 sCgLenseFlareProgram->SetValue1f(i ++, (float)mSunVisiblePixels); 1320 1266 1321 1267 DrawQuad(sCgLenseFlareProgram); … … 1325 1271 1326 1272 1273 1274 void DeferredRenderer::SetUseTemporalCoherence(bool temporal) 1275 { 1276 mUseTemporalCoherence = temporal; 1277 } 1278 1279 1280 void DeferredRenderer::SetSamplingMethod(SAMPLING_METHOD s) 1281 { 1282 if (s != mSamplingMethod) 1283 { 1284 mSamplingMethod = s; 1285 mRegenerateSamples = true; 1286 } 1287 } 1288 1289 1290 void DeferredRenderer::SetShadingMethod(SHADING_METHOD s) 1291 { 1292 if (s != mShadingMethod) 1293 { 1294 mShadingMethod = s; 1295 mRegenerateSamples = true; 1296 } 1297 } 1298 1299 1300 #if TODO 1301 1302 void DeferredRenderer::SetNumSamples(int numSamples) 1303 { 1304 mNumSamples = numSamples; 1305 } 1306 1307 #endif 1308 1309 1310 void DeferredRenderer::SetSampleIntensity(float sampleIntensity) 1311 { 1312 mSampleIntensity = sampleIntensity; 1313 } 1314 1315 1316 void DeferredRenderer::SetKernelRadius(float kernelRadius) 1317 { 1318 mKernelRadius = kernelRadius; 1319 } 1320 1321 1322 void DeferredRenderer::SetSortSamples(bool sortSamples) 1323 { 1324 mSortSamples = sortSamples; 1325 } 1326 1327 1328 void DeferredRenderer::SetSunVisiblePixels(int pixels) 1329 { 1330 mSunVisiblePixels = pixels; 1331 } 1332 1333 1334 1327 1335 } // namespace -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h
r3214 r3215 42 42 bool useToneMapping, 43 43 bool useAntiAliasing, 44 bool isLightSourceVisible,45 44 ShadowMap *shadowMap = NULL 46 45 ); … … 50 49 51 50 enum SAMPLING_METHOD {SAMPLING_POISSON, SAMPLING_QUADRATIC, SAMPLING_DEFAULT}; 51 52 52 enum SHADING_METHOD {DEFAULT, SSAO, GI}; 53 53 54 /** Set the samplig method for the indirect illumination 54 55 */ … … 58 59 void SetShadingMethod(SHADING_METHOD s); 59 60 60 void SetSortSamples(bool sortSamples) { mSortSamples = sortSamples; }61 void SetSortSamples(bool sortSamples); 61 62 62 63 void SetSampleIntensity(float sampleIntensity); 63 64 64 65 void SetKernelRadius(float kernelRadius); 66 /** Sets the number of visible pixels of the sun 67 */ 68 void SetSunVisiblePixels(int visiblePixels); 65 69 66 70 … … 125 129 //////////// 126 130 131 /// deferred shading output image width 127 132 int mWidth; 133 /// deferred shading output image height 128 134 int mHeight; 129 135 … … 139 145 140 146 int mIllumFboIndex; 141 // the fbo for indirect illumination (ssao + color bleeding)147 /// the fbo for indirect illumination (ssao + color bleeding) 142 148 FrameBufferObject *mIllumFbo; 143 149 … … 161 167 float mKernelRadius; 162 168 float mSampleIntensity; 169 170 int mSunVisiblePixels; 163 171 }; 164 172 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r3154 r3215 449 449 } 450 450 451 } 451 452 453 Material *ResourceManager::CreateMaterial() 454 { 455 Material *mat = new Material(); 456 mMaterials.push_back(mat); 457 458 return mat; 459 } 460 461 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.h
r3127 r3215 50 50 */ 51 51 static void DelSingleton(); 52 /** Adds a scene entity to be handled by the resource mananger.52 /** Adds a scene entity to the resource mananger, which from now on is handled by the manager. 53 53 */ 54 54 void AddSceneEntity(SceneEntity *ent); 55 /** Adds a scene entity to be handled by the resource mananger.55 /** Creates a new transform. 56 56 */ 57 57 Transform3 *CreateTransform(const Matrix4x4 &m); 58 /** Creates a new default material that is handled by the manager. 59 */ 60 Material *CreateMaterial(); 58 61 59 62 /// giant hack: set this to true if the geometry to load has tangent data for normal mapping 60 63 bool mUseNormalMapping; 61 64 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3214 r3215 217 217 bool useHDR = true; 218 218 bool useAntiAliasing = true; 219 bool useLenseFlare = true; 219 220 220 221 PerfTimer frameTimer, algTimer; … … 276 277 void RenderVisibleObjects(); 277 278 278 boolTestSunVisible();279 int TestSunVisible(); 279 280 280 281 void Begin2D(); … … 391 392 env.GetBoolParam(string("useHDR"), useHDR); 392 393 env.GetBoolParam(string("useAA"), useAntiAliasing); 394 env.GetBoolParam(string("useLenseFlare"), useLenseFlare); 393 395 env.GetBoolParam(string("useAdvancedShading"), useAdvancedShading); 394 396 … … 418 420 cout << "render method: " << renderMethod << endl; 419 421 cout << "use antialiasing: " << useAntiAliasing << endl; 422 cout << "use lense flare: " << useLenseFlare << endl; 420 423 cout << "use advanced shading: " << useAdvancedShading << endl; 421 424 cout << "turbitity: " << turbitity << endl; … … 584 587 585 588 // toto clean up material 586 Material *mat = newMaterial();589 Material *mat = resourceManager->CreateMaterial(); 587 590 588 591 mat->GetTechnique(0)->SetDepthWriteEnabled(false); … … 591 594 sunBox = conv.ConvertBox(sbox, mat, trafo); 592 595 596 resourceManager->AddSceneEntity(sunBox); 597 598 /// create single occlusion query that handles sun visibility 593 599 glGenQueriesARB(1, &sunQuery); 594 600 … … 1158 1164 RenderVisibleObjects(); 1159 1165 } 1160 1161 1162 bool sunVisible = TestSunVisible(); 1166 1167 const bool useDeferred = 1168 ((renderMethod == RENDER_DEFERRED) || (renderMethod == RENDER_DEPTH_PASS_DEFERRED)); 1169 1170 // if no lense flare => just set sun to invisible 1171 int sunVisiblePixels = useLenseFlare && useDeferred ? TestSunVisible() : 0; 1163 1172 1164 1173 … … 1172 1181 1173 1182 1174 if ((renderMethod == RENDER_DEFERRED) || 1175 (renderMethod == RENDER_DEPTH_PASS_DEFERRED)) 1183 if (useDeferred) 1176 1184 { 1177 1185 FrameBufferObject::Release(); … … 1192 1200 shadingMethod = DeferredRenderer::DEFAULT; 1193 1201 1202 deferredShader->SetSunVisiblePixels(sunVisiblePixels); 1194 1203 deferredShader->SetShadingMethod(shadingMethod); 1195 1204 deferredShader->SetSamplingMethod(samplingMethod); … … 1200 1209 1201 1210 ShadowMap *sm = showShadowMap ? shadowMap : NULL; 1202 deferredShader->Render(fbo, ssaoTempCohFactor, light, useHDR, useAntiAliasing, s unVisible, sm);1211 deferredShader->Render(fbo, ssaoTempCohFactor, light, useHDR, useAntiAliasing, sm); 1203 1212 } 1204 1213 … … 1400 1409 useAntiAliasing = !useAntiAliasing; 1401 1410 break; 1402 /*case '?':1403 sortSamples = !sortSamples;1404 break;1405 */1411 case 'c': 1412 case 'C': 1413 useLenseFlare = !useLenseFlare; 1414 break; 1406 1415 default: 1407 1416 return; … … 2248 2257 } 2249 2258 2250 2251 bool TestSunVisible() 2259 /** This function returns the number of visible pixels of a 2260 bounding box representing the sun. 2261 */ 2262 int TestSunVisible() 2252 2263 { 2253 2264 // assume sun is at a far away point along the light vector … … 2267 2278 glGetQueryObjectuivARB(sunQuery, GL_QUERY_RESULT_ARB, &sampleCount); 2268 2279 2269 return (sampleCount > 0);2270 } 2280 return sampleCount; 2281 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/lenseFlare.cg
r3214 r3215 34 34 uniform sampler2D flareTex5, 35 35 uniform float2 vectorToLight, // vector to current light position 36 uniform float distanceToLight // distance to current light position 36 uniform float distanceToLight, // distance to current light position 37 uniform float sunVisiblePixels 37 38 ): COLOR 38 39 { … … 58 59 59 60 //result.xyz = float3(0); 61 sunVisiblePixels = clamp(sunVisiblePixels, .0f, 100.0f) * 0.01f; 62 60 63 for (int i = 0; i < 8; ++ i) 61 result.xyz += flare[i].xyz ;64 result.xyz += flare[i].xyz * sunVisiblePixels; 62 65 63 66 return result;
Note: See TracChangeset
for help on using the changeset viewer.