Changeset 3230 for GTP/trunk/App/Demos/Vis/FriendlyCulling
- Timestamp:
- 12/22/08 16:07:19 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
r3225 r3230 112 112 EnableFiberSafeOptimizations="true" 113 113 AdditionalIncludeDirectories="libs;libs/GL;libs/Devil/include;src;libs/Zlib/include;"$(CG_INC_PATH)"" 114 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SET ;NOT_USE_GTX"114 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SET" 115 115 StringPooling="true" 116 116 RuntimeLibrary="2" -
GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
r3227 r3230 94 94 # ssao sample intensity 95 95 #ssaoSampleIntensity=0.2f 96 ssaoSampleIntensity= 1.0f96 ssaoSampleIntensity=0.8f 97 97 # ssao temporal coherence factor 98 tempCohFactor= 1000.0f98 tempCohFactor=2000.0f 99 99 # ssao filter radius 100 100 ssaoFilterRadius=12.0f -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp
r3229 r3230 6 6 using namespace CHCDemoEngine; 7 7 8 //HaltonSequence PoissonDiscSampleGenerator2D::sHalton(2);9 //HaltonSequence RandomSampleGenerator2D::sHalton(2);10 //HaltonSequence QuadraticDiscSampleGenerator2D::sHalton(2);11 12 8 13 9 SampleGenerator::SampleGenerator(int numSamples, float radius): 14 10 mNumSamples(numSamples), mRadius(radius) 15 {} 11 { 12 mHalton = new HaltonSequence(2); 13 } 14 15 16 SampleGenerator::~SampleGenerator() 17 { 18 DEL_PTR(mHalton); 19 } 16 20 17 21 18 22 PoissonDiscSampleGenerator2D::PoissonDiscSampleGenerator2D(int numSamples, float radius): 19 SampleGenerator(numSamples, radius) , sHalton(HaltonSequence(2))23 SampleGenerator(numSamples, radius) 20 24 {} 21 25 … … 58 62 59 63 // note: should use halton, but seems somewhat broken 60 sHalton.GetNext(r);64 mHalton->GetNext(r); 61 65 62 66 // scale to -1 .. 1 … … 106 110 107 111 RandomSampleGenerator2D::RandomSampleGenerator2D(int numSamples, float radius): 108 SampleGenerator(numSamples, radius) , sHalton(HaltonSequence(2))112 SampleGenerator(numSamples, radius) 109 113 {} 110 114 … … 120 124 while (numSamples < mNumSamples) 121 125 { 122 sHalton.GetNext(r);126 mHalton->GetNext(r); 123 127 124 128 const float rx = r[0] * 2.0f - 1.0f; … … 165 169 QuadraticDiscSampleGenerator2D::QuadraticDiscSampleGenerator2D(int numSamples, float radius): 166 170 PoissonDiscSampleGenerator2D(numSamples, radius) 167 //SampleGenerator(numSamples, radius),168 //sHalton(HaltonSequence(2)),169 //mPoisson(PoissonDiscSampleGenerator2D(numSamples, radius))170 171 {} 171 172 … … 179 180 for (int i = 0; i < mNumSamples; ++ i) 180 181 { 181 sHalton.GetNext(r);182 mHalton->GetNext(r); 182 183 183 184 // create samples over disc: the sample density -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.h
r3229 r3230 38 38 virtual void Generate(float *samples) const = 0; 39 39 40 virtual ~SampleGenerator(); 41 40 42 protected: 41 43 42 44 SampleGenerator() {}; 43 45 46 HaltonSequence *mHalton; 44 47 int mNumSamples; 45 48 float mRadius; … … 54 57 55 58 virtual void Generate(float *samples) const; 56 57 protected:58 59 HaltonSequence &sHalton;60 59 }; 61 60 … … 72 71 73 72 virtual void Generate(float *samples) const; 74 75 protected:76 77 HaltonSequence &sHalton;78 73 }; 79 74 … … 90 85 91 86 virtual void Generate(float *samples) const; 92 93 protected:94 95 //PoissonDiscSampleGenerator2D &mPoisson;96 //HaltonSequence &sHalton;97 87 }; 98 88 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
r3227 r3230 7 7 8 8 //#define NUM_SAMPLES 8 9 #define NUM_SAMPLES 169 //#define NUM_SAMPLES 16 10 10 //#define NUM_SAMPLES 24 11 //#define NUM_SAMPLES 48 11 #define NUM_SAMPLES 48 12 13 #define MIN_SAMPLES 8 12 14 13 15 #define DISTANCE_SCALE 1e-2f … … 27 29 //-- reprojection 28 30 29 #define MIN_DEPTH_DIFF 5e-3f 30 #define PRECISION_SCALE 1e-1f 31 //#define MIN_DEPTH_DIFF 5e-3f 32 #define MIN_DEPTH_DIFF 1e-3f 33 #define DYNAMIC_OBJECTS_THRESHOLD 1e-8f 31 34 32 35 … … 57 60 #define NUM_DOWNSAMPLES 9 58 61 59 #define DYNAMIC_OBJECTS_THRESHOLD 1e-8f60 62 61 63 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/common.h
r3227 r3230 59 59 return rpt; 60 60 } 61 62 63 #define USE_GTX -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r3227 r3230 230 230 // compute position from old frame for dynamic objects + translational portion 231 231 //const float3 translatedPos = difVec - oldEyePos + worldPos.xyz; 232 const float3 translatedPos = - 232 const float3 translatedPos = -oldEyePos + worldPos.xyz; 233 233 234 234 … … 276 276 pixelValid = pixelNotValid; 277 277 } 278 else if ( !((oldEyeSpaceDepth > 1e10f) || (projectedEyeSpaceDepth > 1e10f)) &&278 else if (//!((oldEyeSpaceDepth > 1e10f) || (projectedEyeSpaceDepth > 1e10f)) && 279 279 // check if changed from dynamic to not dynamic object 280 280 ((oldDynamic && !newDynamic) || (!oldDynamic && newDynamic) || 281 281 // check if we have a dynamic object and is a depth discontinuity 282 282 ( 283 //(oldDynamic || newDynamic) && 283 (oldDynamic || newDynamic) && 284 //(depthDif > 1e-5f)))) 284 285 (depthDif > MIN_DEPTH_DIFF)))) 285 286 { -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg
r3212 r3230 186 186 currentPos /= currentPos.w; 187 187 188 const float currentDepth = currentPos.z * PRECISION_SCALE;188 const float currentDepth = currentPos.z; 189 189 190 190 /////////// … … 203 203 204 204 // the current depth projected into the old frame 205 const float projDepth = projPos.z * PRECISION_SCALE;205 const float projDepth = projPos.z; 206 206 207 207 // fit from unit cube into 0 .. 1 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3227 r3230 93 93 const float depthDif = abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth); 94 94 95 //const float xOffs = 1.0f / 1024.0f; const float yOffs = 1.0f / 768.0f; const float eps = 1e-6f;96 97 95 // the weight of the accumulated samples from the previous frames 98 96 float w; … … 102 100 103 101 if (1 104 // && (oldTexCoords.x + eps >= xOffs) && (oldTexCoords.x <= 1.0f - xOffs + eps)105 // && (oldTexCoords.y + eps >= yOffs) && (oldTexCoords.y <= 1.0f - yOffs + eps)106 102 && (oldTexCoords.x > 0) && (oldTexCoords.x < 1.0f) 107 103 && (oldTexCoords.y > 0) && (oldTexCoords.y < 1.0f) … … 232 228 float3 tr, 233 229 float3 viewDir, 234 float newWeight,230 float convergence, 235 231 float sampleIntensity, 236 232 bool isMovingObject … … 243 239 for (int i = 0; i < NUM_SAMPLES; ++ i) 244 240 { 245 const float2 offset = samples[i]; 246 247 float2 offsetTransformed; 241 float2 offset; 248 242 249 243 //////////////////// … … 251 245 //-- (affects performance for some reason!) 252 246 253 float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 254 //float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord, 0, 0)).xy; 255 //offsetTransformed = myreflect(offset, mynoise); 256 offsetTransformed = myrotate(offset, mynoise.x); 247 if (convergence < 700) 248 { 249 float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 250 //offsetTransformed = myreflect(offset, mynoise); 251 offset = myrotate(samples[i], mynoise.x); 252 } 253 else 254 { 255 offset = samples[i]; 256 } 257 257 258 258 // weight with projected coordinate to reach similar kernel size for near and far 259 const float2 texcoord = IN.texCoord.xy + offset Transformed* scaleFactor;259 const float2 texcoord = IN.texCoord.xy + offset * scaleFactor; 260 260 261 261 const float4 sampleColor = tex2Dlod(colors, float4(texcoord, .0f, .0f)); … … 299 299 // we can bail out early and use a minimal #samples) 300 300 // if some conditions are met as long as the hardware supports it 301 if (numSamples >= 8)301 if (numSamples >= MIN_SAMPLES) 302 302 { 303 //break; 303 304 // if the pixel belongs to a static object and all the samples stay valid in the current frame 304 305 if (!isMovingObject && (validSamples < 1.0f)) break; 305 306 // if the pixel belongs to a dynamic object but the #accumulated samples for this pixel is sufficiently high 306 307 // (=> there was no discontinuity recently) 307 else if (isMovingObject && ( newWeight> NUM_SAMPLES * 5)) break;308 else if (isMovingObject && (convergence > NUM_SAMPLES * 5)) break; 308 309 } 309 310 #endif
Note: See TracChangeset
for help on using the changeset viewer.