Changeset 2863


Ignore:
Timestamp:
08/24/08 12:48:59 (16 years ago)
Author:
mattausch
Message:

repaired view vector correction for ssao

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.cpp

    r2861 r2863  
    149149        swap(mNewFbo, mOldFbo);  
    150150 
    151         FirstPass(fbo, expFactor); 
     151        ComputeSsao(fbo, expFactor); 
    152152        // the second pass just renders the combined solution 
    153         SecondPass(fbo); 
    154 } 
    155  
    156  
    157 void SsaoShader::FirstPass(FrameBufferObject *fbo, float expFactor) 
     153        DisplayTexture(); 
     154} 
     155 
     156 
     157void SsaoShader::ComputeSsao(FrameBufferObject *fbo, float expFactor) 
    158158{ 
    159159        GLuint colorsTex = fbo->GetColorBuffer(0)->GetTexture(); 
     
    259259 
    260260 
    261 void SsaoShader::SecondPass(FrameBufferObject *fbo) 
     261void SsaoShader::DisplayTexture() 
    262262{ 
    263263        glEnable(GL_TEXTURE_2D); 
     
    309309        mCamera->ComputePoints(ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr); 
    310310 
    311 #if 0 // matT: debug this!! 
    312          
    313         bl = Normalize(nbl - fbl); 
    314         br = Normalize(nbr - fbr); 
    315         tl = Normalize(ftl - ntl); 
    316         tr = Normalize(ftr - ntr); 
     311#if 1 // matT: debug this!! 
     312         
     313        bl = -Normalize(nbl - fbl); 
     314        br = -Normalize(nbr - fbr); 
     315        tl = -Normalize(ntl - ftl); 
     316        tr = -Normalize(ntr - ftr); 
    317317 
    318318#else // just take camera direction 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.h

    r2861 r2863  
    4848protected: 
    4949 
    50         void FirstPass(FrameBufferObject *fbo, float expFactor); 
     50        void ComputeSsao(FrameBufferObject *fbo, float expFactor); 
    5151 
    52         void SecondPass(FrameBufferObject *fbo); 
     52        void DisplayTexture(); 
    5353 
    5454        void CreateNoiseTex2D(); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r2861 r2863  
    77 
    88// rule of thumb: approx 1 / NUM_SAMPLES 
    9 #define SAMPLE_INTENSITY 0.2 
    10 //#define SAMPLE_INTENSITY 0.125f 
     9//#define SAMPLE_INTENSITY 0.2 
     10#define SAMPLE_INTENSITY 0.125f 
    1111 
    1212#define AREA_SIZE 9e-1f 
    13 #define VIEW_CORRECTION_SCALE 0.3f 
     13//#define VIEW_CORRECTION_SCALE 0.3f 
     14#define VIEW_CORRECTION_SCALE 1.0f 
    1415#define DISTANCE_SCALE 1e-6f 
    1516 
     
    5152 
    5253 
     54/** The ssao shader returning the an intensity value between 0 and 1 
     55*/ 
    5356float ssao(fragment IN, 
    5457                   uniform sampler2D positions, 
     
    101104                        (SAMPLE_INTENSITY * DISTANCE_SCALE) / (DISTANCE_SCALE + length_to_sample * length_to_sample); 
    102105 
    103                 // if normal perpenticular to view dir, only half of the samples count 
     106                // if surface normal perpenticular to view dir, the samples count less => compensate for this 
    104107                float view_correction = 1.0f + VIEW_CORRECTION_SCALE * (1.0f - dot(currentViewDir, currentNormal)); 
    105108 
     
    108111 
    109112        return (1.0f - total_ao); 
     113        //return float4(dot(currentViewDir, currentNormal)); 
    110114} 
    111115 
     
    226230        // expand normal 
    227231        normal = normalize(normal * 2.0f - 1.0f); 
     232        /// the current view direction 
    228233        float3 viewDir = normalize(IN.view * 2.0f - float3(1.0f)); 
    229234 
     
    235240        float ao = ssao(IN, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition); 
    236241        float4 attenuated_color = ao * col; 
     242        //float4 attenuated_color = ao; 
    237243 
    238244        //float4 new_col = globIllum(IN, colors, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition);  
    239         //float ao = new_col.w; 
    240245        //float4 attenuated_color = ao * col + new_col; 
    241246         
     
    266271        } 
    267272 
     273        //OUT.color.xyz = viewDir; 
     274        //OUT.color = attenuated_color; 
     275         
    268276        OUT.color.w = tex2D(colors, IN.texCoord.xy).w; 
    269277 
Note: See TracChangeset for help on using the changeset viewer.