Changeset 3104 for GTP/trunk/App/Demos/Vis
- Timestamp:
- 11/06/08 13:31:58 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3103 r3104 321 321 sCgGiProgram = sm->CreateFragmentProgram("globillum", "main", "giFrag"); 322 322 sCgCombineIllumProgram = sm->CreateFragmentProgram("globillum", "combine", "combineGi"); 323 sCgCombineSsaoProgram = sm->CreateFragmentProgram("combineSsao", "combine", "combineSsao"); 323 //sCgCombineSsaoProgram = sm->CreateFragmentProgram("combineSsao", "combine", "combineSsao"); 324 sCgCombineSsaoProgram = sm->CreateFragmentProgram("ssao", "combine", "combineSsao"); 324 325 sCgAntiAliasingProgram = sm->CreateFragmentProgram("antialiasing", "main", "antiAliasing"); 325 326 sCgToneProgram = sm->CreateFragmentProgram("tonemap", "ToneMap", "toneMap"); … … 327 328 sCgLogLumProgram = sm->CreateFragmentProgram("tonemap", "CalcAvgLogLum", "avgLogLum"); 328 329 329 int i; 330 331 i = 0; 332 sCgSsaoProgram->AddParameter("colors", i ++); 333 sCgSsaoProgram->AddParameter("normals", i ++); 334 sCgSsaoProgram->AddParameter("oldTex", i ++); 335 sCgSsaoProgram->AddParameter("noiseTex", i ++); 336 sCgSsaoProgram->AddParameter("temporalCoherence", i ++); 337 sCgSsaoProgram->AddParameter("samples", i ++); 338 sCgSsaoProgram->AddParameter("bl", i ++); 339 sCgSsaoProgram->AddParameter("br", i ++); 340 sCgSsaoProgram->AddParameter("tl", i ++); 341 sCgSsaoProgram->AddParameter("tr", i ++); 342 sCgSsaoProgram->AddParameter("modelViewProj", i ++); 343 sCgSsaoProgram->AddParameter("oldModelViewProj", i ++); 344 345 sCgSsaoProgram->AddParameter("oldEyePos", i ++); 346 sCgSsaoProgram->AddParameter("oldbl", i ++); 347 sCgSsaoProgram->AddParameter("oldbr", i ++); 348 sCgSsaoProgram->AddParameter("oldtl", i ++); 349 sCgSsaoProgram->AddParameter("oldtr", i ++); 350 351 i = 0; 352 sCgGiProgram->AddParameter("colors", i ++); 353 sCgGiProgram->AddParameter("normals", i ++); 354 sCgGiProgram->AddParameter("noiseTex", i ++); 355 sCgGiProgram->AddParameter("oldSsaoTex", i ++); 356 sCgGiProgram->AddParameter("oldIllumTex", i ++); 357 sCgGiProgram->AddParameter("temporalCoherence", i ++); 358 sCgGiProgram->AddParameter("samples", i ++); 359 sCgGiProgram->AddParameter("bl", i ++); 360 sCgGiProgram->AddParameter("br", i ++); 361 sCgGiProgram->AddParameter("tl", i ++); 362 sCgGiProgram->AddParameter("tr", i ++); 363 sCgGiProgram->AddParameter("oldModelViewProj", i ++); 364 sCgGiProgram->AddParameter("modelViewProj", i ++); 365 366 sCgAntiAliasingProgram->AddParameter("colors", 0); 367 sCgAntiAliasingProgram->AddParameter("normals", 1); 368 369 sCgDeferredProgram->AddParameter("colors", 0); 370 sCgDeferredProgram->AddParameter("normals", 1); 371 sCgDeferredProgram->AddParameter("lightDir", 2); 330 331 /////////////////// 332 //-- initialize program parameters 333 334 string ssaoParams[] = 335 {"colors", "normals", "oldTex", "noiseTex", "temporalCoherence", 336 "samples", "bl", "br", "tl", "tr", "modelViewProj", "oldModelViewProj", 337 "oldEyePos", "oldbl", "oldbr", "oldtl", "oldtr"}; 338 sCgSsaoProgram->AddParameters(ssaoParams, 0, 17); 339 340 string giParams[] = 341 {"colors", "normals", "noiseTex", "oldSsaoTex", "oldIllumTex", 342 "temporalCoherence", "samples", "bl", "br", "tl", "tr", "oldModelViewProj", "modelViewProj"}; 343 sCgGiProgram->AddParameters(giParams, 0, 13); 344 345 string toneParams[] = {"colors", "imageKey", "whiteLum", "middleGrey"}; 346 sCgToneProgram->AddParameters(toneParams, 0, 4); 347 348 349 //////////////// 350 351 string deferredShadowParams[] = 352 {"colors", "normals", "shadowMap", "noiseTex", "shadowMatrix", 353 "sampleWidth", "lightDir", "eyePos", "samples", "weights"}; 354 355 sCgDeferredShadowProgram->AddParameters(deferredShadowParams, 0, 10); 356 357 //////////////// 358 359 string combineIllumParams[] = {"colorsTex", "ssaoTex", "illumTex"}; 360 sCgCombineIllumProgram->AddParameters(combineIllumParams, 0, 3); 361 362 //////////////// 363 364 string combineSsaoParams[] = {"colorsTex", "ssaoTex", "filterOffs", "filterWeights"}; 365 sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 4); 366 367 ////////////// 368 369 string deferredParams[] = {"colors", "normals", "lightDir"}; 370 sCgDeferredProgram->AddParameters(deferredParams, 0, 3); 371 372 /////////////////// 373 374 string aaParams[] = {"colors", "normals"}; 375 sCgAntiAliasingProgram->AddParameters(aaParams, 0, 2); 376 377 ///////////////////// 378 379 string downSampleParams[] = {"colors", "downSampleOffs"}; 380 sCgDownSampleProgram->AddParameters(downSampleParams, 0, 2); 381 382 //////////// 372 383 373 384 sCgLogLumProgram->AddParameter("colors", 0); 374 385 375 sCgToneProgram->AddParameter("colors", 0); 376 sCgToneProgram->AddParameter("imageKey", 1); 377 sCgToneProgram->AddParameter("whiteLum", 2); 378 sCgToneProgram->AddParameter("middleGrey", 3); 379 380 sCgDownSampleProgram->AddParameter("colors", 0); 381 sCgDownSampleProgram->AddParameter("downSampleOffs", 1); 382 383 sCgDeferredShadowProgram->AddParameter("colors", 0); 384 sCgDeferredShadowProgram->AddParameter("normals", 1); 385 sCgDeferredShadowProgram->AddParameter("shadowMap", 2); 386 sCgDeferredShadowProgram->AddParameter("noise", 3); 387 sCgDeferredShadowProgram->AddParameter("shadowMatrix", 4); 388 sCgDeferredShadowProgram->AddParameter("sampleWidth", 5); 389 sCgDeferredShadowProgram->AddParameter("lightDir", 6); 390 sCgDeferredShadowProgram->AddParameter("eyePos", 7); 391 sCgDeferredShadowProgram->AddParameter("samples", 8); 392 sCgDeferredShadowProgram->AddParameter("weights", 9); 393 394 sCgCombineIllumProgram->AddParameter("colors", 0); 395 sCgCombineIllumProgram->AddParameter("ssaoTex", 1); 396 sCgCombineIllumProgram->AddParameter("illumTex", 2); 397 398 sCgCombineSsaoProgram->AddParameter("colorsTex", 0); 399 sCgCombineSsaoProgram->AddParameter("normalsTex", 1); 400 sCgCombineSsaoProgram->AddParameter("ssaoTex", 2); 401 sCgCombineSsaoProgram->AddParameter("filterOffs", 3); 402 sCgCombineSsaoProgram->AddParameter("filterWeights", 4); 386 387 388 /////////// 389 403 390 404 391 PoissonDiscSampleGenerator2 poisson(NUM_SSAO_FILTERSAMPLES, 1.0f); … … 744 731 glDrawBuffers(1, mrt + colorBufferIdx); 745 732 746 sCgCombineSsaoProgram->SetTexture(0, colorsTex); 747 sCgCombineSsaoProgram->SetTexture(1, normalsTex); 748 sCgCombineSsaoProgram->SetTexture(2, ssaoTex); 749 750 sCgCombineSsaoProgram->SetArray2f(3, (float *)ssaoFilterOffsets, NUM_SSAO_FILTERSAMPLES); 751 sCgCombineSsaoProgram->SetArray1f(4, (float *)ssaoFilterWeights, NUM_SSAO_FILTERSAMPLES); 733 int i = 0; 734 sCgCombineSsaoProgram->SetTexture(i ++, colorsTex); 735 //sCgCombineSsaoProgram->SetTexture(i ++, normalsTex); 736 sCgCombineSsaoProgram->SetTexture(i ++, ssaoTex); 737 738 sCgCombineSsaoProgram->SetArray2f(i ++, (float *)ssaoFilterOffsets, NUM_SSAO_FILTERSAMPLES); 739 sCgCombineSsaoProgram->SetArray1f(i ++, (float *)ssaoFilterWeights, NUM_SSAO_FILTERSAMPLES); 752 740 753 741 DrawQuad(sCgCombineSsaoProgram); … … 976 964 Matrix4x4 matViewing, matProjection; 977 965 966 // hack: temporarily change far to improve precision 967 const float oldFar = mCamera->GetFar(); 968 mCamera->SetFar(1e3f); 969 //mCamera->SetFar(1e2f); 970 971 978 972 //mCamera->GetModelViewMatrix(matViewing); 979 973 mCamera->GetViewOrientationMatrix(matViewing); … … 1017 1011 glPushAttrib(GL_VIEWPORT_BIT); 1018 1012 glViewport(0, 0, mWidth, mHeight); 1013 // revert to old far plane 1014 mCamera->SetFar(oldFar); 1019 1015 } 1020 1016 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderProgram.cpp
r3046 r3104 363 363 364 364 365 void ShaderProgram::AddParameters(std::string params[], 366 int startIdx, 367 int numElements) 368 { 369 for (int i = 0; i < numElements; ++ i) 370 { 371 AddParameter(params[i], startIdx + i); 372 } 373 } 374 375 365 376 CGparameter ShaderProgram::GetOrCreateParameter(const string &name) 366 377 { -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderProgram.h
r3046 r3104 199 199 */ 200 200 CGparameter AddParameter(const std::string &name, int idx); 201 201 /** Comvenience method that adds an array of parameters beginning with 202 index i of size numElements 203 */ 204 void AddParameters(std::string params[], int startIdx, int numElements); 202 205 203 206 ////////////// -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r3099 r3104 231 231 const float currentDepth = currentPos.z * precisionScale; 232 232 233 const float2 ao = ssao(IN, colors, noise , samples, normal,233 const float2 ao = ssao(IN, colors, noiseTex, samples, normal, 234 234 eyeSpacePos, w, bl, br, tl, tr, normalize(viewDir)); 235 235 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg
r3103 r3104 254 254 255 255 pixel combine(fragment IN, 256 uniform sampler2D colors ,256 uniform sampler2D colorsTex, 257 257 uniform sampler2D ssaoTex, 258 258 uniform sampler2D illumTex … … 261 261 pixel OUT; 262 262 263 float4 col = tex2Dlod(colors , float4(IN.texCoord, 0, 0));263 float4 col = tex2Dlod(colorsTex, float4(IN.texCoord, 0, 0)); 264 264 float ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)).x; 265 265 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3103 r3104 354 354 return OUT; 355 355 } 356 357 float Filter(float2 texCoord, 358 uniform sampler2D ssaoTex, 359 uniform float2 filterOffs[NUM_SSAO_FILTERSAMPLES], 360 uniform float filterWeights[NUM_SSAO_FILTERSAMPLES]) 361 { 362 float average = .0f; 363 float w = .0f; 364 365 for (int i = 0; i < NUM_SSAO_FILTERSAMPLES; ++ i) 366 { 367 average += filterWeights[i] * tex2Dlod(ssaoTex, float4(texCoord + filterOffs[i], 0, 0)).x; 368 w += filterWeights[i]; 369 } 370 371 average *= 1.0f / (float)w; 372 373 return average; 374 } 375 376 377 pixel combine(fragment IN, 378 uniform sampler2D colorsTex, 379 uniform sampler2D ssaoTex, 380 uniform float2 filterOffs[NUM_SSAO_FILTERSAMPLES], 381 uniform float filterWeights[NUM_SSAO_FILTERSAMPLES] 382 ) 383 { 384 pixel OUT; 385 386 float4 col = tex2Dlod(colorsTex, float4(IN.texCoord, 0, 0)); 387 float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 388 389 //if (ao.y < 10.0f) ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights); 390 391 //OUT.illum_col = col * ao.x; 392 //OUT.illum_col = float4(ao.y, ao.y, ao.y, col.w); 393 //OUT.illum_col = float4(ao.x, ao.x, ao.x, col.w); 394 OUT.illum_col.xyz = float3(1.0f - ao.x, 1.0f - ao.y * 1e-2f, 1); 395 //OUT.illum_col.xyz = float3(1.0f - ao.x, ao.y, 0); 396 OUT.illum_col.w = col.w; 397 398 return OUT; 399 }
Note: See TracChangeset
for help on using the changeset viewer.