Changeset 3199 for GTP/trunk/App/Demos/Vis
- Timestamp:
- 11/30/08 21:01:32 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3198 r3199 326 326 mDownSampleFbo = new FrameBufferObject(dsw, dsh, FrameBufferObject::DEPTH_NONE); 327 327 mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 328 329 FrameBufferObject::InitBuffer(mDownSampleFbo, 0); 328 // downsample buffer for the normal texture 329 mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST); 330 331 for (int i = 0; i < 2; ++ i) 332 { 333 FrameBufferObject::InitBuffer(mDownSampleFbo, i); 334 } 330 335 331 336 mFBOs.push_back(mDownSampleFbo); … … 459 464 460 465 string prepareSsaoParams[] = 461 {"colorsTex", " diffVals", "oldTex",466 {"colorsTex", "normalsTex", "diffVals", "oldTex", 462 467 "oldEyePos", "modelViewProj", "oldModelViewProj", 463 468 "oldbl", "oldbr", "oldtl", "oldtr"}; 464 469 465 sCgPrepareSsaoProgram->AddParameters(prepareSsaoParams, 0, 1 0);470 sCgPrepareSsaoProgram->AddParameters(prepareSsaoParams, 0, 11); 466 471 467 472 … … 640 645 641 646 642 void DeferredRenderer::ComputeSsao(FrameBufferObject *fbo, 643 float tempCohFactor) 647 void DeferredRenderer::ComputeSsao(FrameBufferObject *fbo, float tempCohFactor) 644 648 { 645 649 GLuint colorsTex, normalsTex, attribsTex; 646 650 647 651 if (0) 652 { 648 653 colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 654 normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 655 } 649 656 else 657 { 658 normalsTex = mDownSampleFbo->GetColorBuffer(1)->GetTexture(); 650 659 colorsTex = mDownSampleFbo->GetColorBuffer(0)->GetTexture(); 651 652 normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 660 } 661 653 662 attribsTex = fbo->GetColorBuffer(2)->GetTexture(); 654 663 … … 1024 1033 { 1025 1034 GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 1035 GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 1026 1036 GLuint diffVals = fbo->GetColorBuffer(2)->GetTexture(); 1027 1037 // flip flop between illumination buffers … … 1031 1041 1032 1042 sCgPrepareSsaoProgram->SetTexture(i ++, colorsTex); 1043 sCgPrepareSsaoProgram->SetTexture(i ++, normalsTex); 1033 1044 sCgPrepareSsaoProgram->SetTexture(i ++, diffVals); 1034 1045 sCgPrepareSsaoProgram->SetTexture(i ++, oldTex); … … 1052 1063 mDownSampleFbo->Bind(); 1053 1064 1054 glDrawBuffers(1, mrt); 1065 // prepare downsampled color and normal texture for ssao 1066 glDrawBuffers(2, mrt); 1055 1067 1056 1068 DrawQuad(sCgPrepareSsaoProgram); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
r3198 r3199 6 6 //-- ssao + gi parameters 7 7 8 #define NUM_SAMPLES 89 //#define NUM_SAMPLES 168 //#define NUM_SAMPLES 8 9 #define NUM_SAMPLES 16 10 10 //#define NUM_SAMPLES 24 11 11 12 #define SAMPLE_INTENSITY 0.5f13 //#define SAMPLE_INTENSITY 1.0f12 //#define SAMPLE_INTENSITY 0.5f 13 #define SAMPLE_INTENSITY 1.0f 14 14 15 15 #define SAMPLE_RADIUS 8e-1f -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r3198 r3199 280 280 281 281 282 float4PrepareSsao(fragment IN,282 pixel PrepareSsao(fragment IN, 283 283 uniform sampler2D colorsTex, 284 uniform sampler2D normalsTex, 284 285 uniform sampler2D diffVals, 285 286 uniform sampler2D oldTex, … … 291 292 uniform float3 oldtr, 292 293 uniform float3 oldEyePos 293 ) : COLOR0294 ) 294 295 { 296 pixel pix; 295 297 float4 color = tex2Dlod(colorsTex, float4(IN.texCoord, 0, 0)); 296 298 // store scaled view vector so wie don't have to normalize for e.g., ssao … … 298 300 299 301 const float4 difVec = tex2Dlod(diffVals, float4(IN.texCoord, 0, 0)); 302 const float3 normal = normalize(tex2Dlod(normalsTex, float4(IN.texCoord, 0, 0)).xyz); 300 303 301 304 // do reprojection and filter out the pixels that are not save … … 311 314 ); 312 315 313 color.x = pValid; 314 315 return color; 316 pix.color = color; 317 pix.color.x = pValid; 318 pix.normal = normal; 319 320 return pix; 316 321 } 317 322 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3198 r3199 205 205 206 206 float3 dirSample = samplePos - centerPosition; 207 const float lengthToSample = max(length(dirSample), 1e-6f); 207 208 const float sqrLen = max(SqrLen(dirSample), 1e-2f); 209 const float lengthToSample = sqrt(sqrLen); 210 //const float lengthToSample = max(length(dirSample), 1e-6f); 208 211 209 212 dirSample /= lengthToSample; // normalize … … 216 219 // the distance_scale offset is used to avoid singularity that occurs at global illumination when 217 220 // the distance to a sample approaches zero 218 const float aoContrib = SAMPLE_INTENSITY / (DISTANCE_SCALE + lengthToSample * lengthToSample); 221 //const float aoContrib = SAMPLE_INTENSITY / (DISTANCE_SCALE + lengthToSample * lengthToSample); 222 const float aoContrib = SAMPLE_INTENSITY / sqrLen; 219 223 //const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f; 220 224 … … 397 401 if (eyeSpaceDepth < 1e10f) 398 402 { 399 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight);400 //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals);403 //ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight); 404 ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals); 401 405 } 402 406 else
Note: See TracChangeset
for help on using the changeset viewer.