Changeset 3230 for GTP/trunk/App/Demos


Ignore:
Timestamp:
12/22/08 16:07:19 (16 years ago)
Author:
mattausch
Message:

fast and cool
not using kernel for high convergence

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj

    r3225 r3230  
    112112                                EnableFiberSafeOptimizations="true" 
    113113                                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" 
    115115                                StringPooling="true" 
    116116                                RuntimeLibrary="2" 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env

    r3227 r3230  
    9494# ssao sample intensity 
    9595#ssaoSampleIntensity=0.2f 
    96 ssaoSampleIntensity=1.0f 
     96ssaoSampleIntensity=0.8f 
    9797# ssao temporal coherence factor 
    98 tempCohFactor=1000.0f 
     98tempCohFactor=2000.0f 
    9999# ssao filter radius 
    100100ssaoFilterRadius=12.0f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp

    r3229 r3230  
    66using namespace CHCDemoEngine; 
    77 
    8 //HaltonSequence PoissonDiscSampleGenerator2D::sHalton(2); 
    9 //HaltonSequence RandomSampleGenerator2D::sHalton(2); 
    10 //HaltonSequence QuadraticDiscSampleGenerator2D::sHalton(2); 
    11  
    128 
    139SampleGenerator::SampleGenerator(int numSamples, float radius): 
    1410mNumSamples(numSamples), mRadius(radius) 
    15 {} 
     11{ 
     12        mHalton = new HaltonSequence(2); 
     13} 
     14 
     15 
     16SampleGenerator::~SampleGenerator() 
     17{ 
     18        DEL_PTR(mHalton); 
     19} 
    1620 
    1721 
    1822PoissonDiscSampleGenerator2D::PoissonDiscSampleGenerator2D(int numSamples, float radius): 
    19 SampleGenerator(numSamples, radius), sHalton(HaltonSequence(2)) 
     23SampleGenerator(numSamples, radius) 
    2024{} 
    2125 
     
    5862 
    5963                        // note: should use halton, but seems somewhat broken 
    60                         sHalton.GetNext(r); 
     64                        mHalton->GetNext(r); 
    6165 
    6266                        // scale to -1 .. 1 
     
    106110 
    107111RandomSampleGenerator2D::RandomSampleGenerator2D(int numSamples, float radius): 
    108 SampleGenerator(numSamples, radius), sHalton(HaltonSequence(2)) 
     112SampleGenerator(numSamples, radius) 
    109113{} 
    110114 
     
    120124        while (numSamples < mNumSamples) 
    121125        { 
    122                 sHalton.GetNext(r); 
     126                mHalton->GetNext(r); 
    123127                 
    124128                const float rx = r[0] * 2.0f - 1.0f; 
     
    165169QuadraticDiscSampleGenerator2D::QuadraticDiscSampleGenerator2D(int numSamples, float radius): 
    166170PoissonDiscSampleGenerator2D(numSamples, radius) 
    167 //SampleGenerator(numSamples, radius),  
    168 //sHalton(HaltonSequence(2)),  
    169 //mPoisson(PoissonDiscSampleGenerator2D(numSamples, radius)) 
    170171{} 
    171172 
     
    179180        for (int i = 0; i < mNumSamples; ++ i) 
    180181        { 
    181                 sHalton.GetNext(r); 
     182                mHalton->GetNext(r); 
    182183 
    183184                // create samples over disc: the sample density 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.h

    r3229 r3230  
    3838        virtual void Generate(float *samples) const = 0; 
    3939 
     40        virtual ~SampleGenerator(); 
     41 
    4042protected: 
    4143 
    4244        SampleGenerator() {}; 
    4345 
     46        HaltonSequence *mHalton; 
    4447        int mNumSamples; 
    4548        float mRadius; 
     
    5457 
    5558        virtual void Generate(float *samples) const; 
    56  
    57 protected: 
    58  
    59         HaltonSequence &sHalton; 
    6059}; 
    6160 
     
    7271 
    7372        virtual void Generate(float *samples) const; 
    74  
    75 protected: 
    76  
    77         HaltonSequence &sHalton; 
    7873}; 
    7974 
     
    9085 
    9186        virtual void Generate(float *samples) const; 
    92  
    93 protected: 
    94  
    95         //PoissonDiscSampleGenerator2D &mPoisson; 
    96         //HaltonSequence &sHalton; 
    9787}; 
    9888 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3227 r3230  
    77 
    88//#define NUM_SAMPLES 8 
    9 #define NUM_SAMPLES 16 
     9//#define NUM_SAMPLES 16 
    1010//#define NUM_SAMPLES 24 
    11 //#define NUM_SAMPLES 48 
     11#define NUM_SAMPLES 48 
     12 
     13#define MIN_SAMPLES 8 
    1214 
    1315#define DISTANCE_SCALE 1e-2f 
     
    2729//-- reprojection 
    2830 
    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 
    3134 
    3235 
     
    5760#define NUM_DOWNSAMPLES 9 
    5861 
    59 #define DYNAMIC_OBJECTS_THRESHOLD 1e-8f 
    6062 
    6163 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/common.h

    r3227 r3230  
    5959        return rpt; 
    6060} 
     61 
     62 
     63#define USE_GTX 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r3227 r3230  
    230230        // compute position from old frame for dynamic objects + translational portion 
    231231        //const float3 translatedPos = difVec - oldEyePos + worldPos.xyz; 
    232         const float3 translatedPos = - oldEyePos + worldPos.xyz; 
     232        const float3 translatedPos = -oldEyePos + worldPos.xyz; 
    233233 
    234234 
     
    276276                pixelValid = pixelNotValid; 
    277277        } 
    278         else if (!((oldEyeSpaceDepth > 1e10f) || (projectedEyeSpaceDepth > 1e10f)) && 
     278        else if (//!((oldEyeSpaceDepth > 1e10f) || (projectedEyeSpaceDepth > 1e10f)) && 
    279279                // check if changed from dynamic to not dynamic object 
    280280                ((oldDynamic && !newDynamic) || (!oldDynamic && newDynamic) || 
    281281                // check if we have a dynamic object and is a depth discontinuity 
    282282                ( 
    283                 //(oldDynamic || newDynamic) &&  
     283                (oldDynamic || newDynamic) &&  
     284                //(depthDif > 1e-5f)))) 
    284285                (depthDif > MIN_DEPTH_DIFF)))) 
    285286        {        
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg

    r3212 r3230  
    186186        currentPos /= currentPos.w; 
    187187         
    188         const float currentDepth = currentPos.z * PRECISION_SCALE; 
     188        const float currentDepth = currentPos.z; 
    189189 
    190190        /////////// 
     
    203203 
    204204        // the current depth projected into the old frame 
    205         const float projDepth = projPos.z * PRECISION_SCALE; 
     205        const float projDepth = projPos.z; 
    206206 
    207207        // fit from unit cube into 0 .. 1 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3227 r3230  
    9393        const float depthDif = abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth); 
    9494 
    95         //const float xOffs = 1.0f / 1024.0f; const float yOffs = 1.0f / 768.0f; const float eps = 1e-6f; 
    96  
    9795        // the weight of the accumulated samples from the previous frames 
    9896        float w; 
     
    102100 
    103101        if (1 
    104         //      && (oldTexCoords.x + eps >= xOffs) && (oldTexCoords.x <= 1.0f - xOffs + eps) 
    105         //      && (oldTexCoords.y + eps >= yOffs) && (oldTexCoords.y <= 1.0f - yOffs + eps) 
    106102                && (oldTexCoords.x > 0) && (oldTexCoords.x < 1.0f) 
    107103                && (oldTexCoords.y > 0) && (oldTexCoords.y < 1.0f) 
     
    232228                        float3 tr,  
    233229                        float3 viewDir, 
    234                         float newWeight, 
     230                        float convergence, 
    235231                        float sampleIntensity, 
    236232                        bool isMovingObject 
     
    243239        for (int i = 0; i < NUM_SAMPLES; ++ i)  
    244240        { 
    245                 const float2 offset = samples[i]; 
    246  
    247                 float2 offsetTransformed; 
     241                float2 offset; 
    248242 
    249243                //////////////////// 
     
    251245                //-- (affects performance for some reason!) 
    252246 
    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                } 
    257257                 
    258258                // weight with projected coordinate to reach similar kernel size for near and far 
    259                 const float2 texcoord = IN.texCoord.xy + offsetTransformed * scaleFactor; 
     259                const float2 texcoord = IN.texCoord.xy + offset * scaleFactor; 
    260260 
    261261                const float4 sampleColor = tex2Dlod(colors, float4(texcoord, .0f, .0f)); 
     
    299299                // we can bail out early and use a minimal #samples) 
    300300                // if some conditions are met as long as the hardware supports it 
    301                 if (numSamples >= 8) 
     301                if (numSamples >= MIN_SAMPLES) 
    302302                { 
     303                        //break; 
    303304                        // if the pixel belongs to a static object and all the samples stay valid in the current frame 
    304305                        if (!isMovingObject && (validSamples < 1.0f)) break; 
    305306                        // if the pixel belongs to a dynamic object but the #accumulated samples for this pixel is sufficiently high  
    306307                        // (=> there was no discontinuity recently) 
    307                         else if (isMovingObject && (newWeight > NUM_SAMPLES * 5)) break; 
     308                        else if (isMovingObject && (convergence > NUM_SAMPLES * 5)) break; 
    308309                } 
    309310#endif 
Note: See TracChangeset for help on using the changeset viewer.