Changeset 2985


Ignore:
Timestamp:
10/01/08 11:35:23 (16 years ago)
Author:
mattausch
Message:

trying out linear depth instead of positions

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

Legend:

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

    r2984 r2985  
    5353static CGparameter sModelViewProjMatrixParam; 
    5454static CGparameter sMaxDepthParam; 
     55static CGparameter sEyePosParam; 
    5556static CGparameter sSamplesParam;  
    5657static CGparameter sOldTexParam; 
     
    340341                sPositionsTexParam = cgGetNamedParameter(sCgSsaoProgram, "positions");   
    341342                sColorsTexParam = cgGetNamedParameter(sCgSsaoProgram, "colors");   
     343                sEyePosParam = cgGetNamedParameter(sCgSsaoProgram, "eyePos"); 
    342344                sNormalsTexParam = cgGetNamedParameter(sCgSsaoProgram, "normals");   
    343345                sNoiseTexParam = cgGetNamedParameter(sCgSsaoProgram, "noiseTexture"); 
     
    664666         
    665667        cgGLSetParameter1f(sMaxDepthParam, mScaleFactor); 
     668 
     669        Vector3 pos = mCamera->GetPosition(); 
     670        cgGLSetParameter3f(sEyePosParam, pos.x, pos.y, pos.z); 
    666671         
    667672        cgGLSetParameter1f(sTemporalCoherenceParam, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2984 r2985  
    963963                glDrawBuffers(3, mrt2); 
    964964        } 
     965 
    965966        sCurrentMrtSet = 1 - sCurrentMrtSet; 
    966967} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r2982 r2985  
    2828//#define ILLUM_INTENSITY 9e-1f; 
    2929 
    30 #define SSAO_MIPMAP_LEVEL 1 
     30#define SSAO_MIPMAP_LEVEL 0//1 
    3131#define GI_MIPMAP_LEVEL 0//2 
    3232 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r2984 r2985  
    8282         
    8383        OUT.color = col; 
    84          
     84 
     85OUT.color.w = color.w; 
     86 
    8587 
    8688        //////////// 
    8789        //-- write out logaritmic luminance for tone mapping 
    88  
     90/* 
    8991        float4 oldColor = tex2Dlod(colors, float4(IN.texCoord.xy, 0, MAX_LOD_LEVEL)); 
    9092 
     
    101103        else 
    102104                OUT.color.w = logLumScaled; 
    103  
     105*/ 
    104106        return OUT; 
    105107} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r2982 r2985  
    3636*/ 
    3737float2 ssao(fragment IN, 
    38                    uniform sampler2D positions, 
     38                   uniform sampler2D colors, 
    3939                   uniform sampler2D noiseTexture, 
    4040                   uniform float2 samples[NUM_SAMPLES], 
    4141                   uniform float3 currentNormal, 
    4242                   uniform float4 centerPosition, 
    43                    uniform float scaleFactor 
    44                    //,uniform float3 currentViewDir 
     43                   uniform float scaleFactor, 
     44                   uniform float3 viewDir, 
     45                   uniform float3 eyePos 
    4546                   ) 
    4647{ 
     
    5960                //////////////////// 
    6061                // add random noise: reflect around random normal vector (warning: slow!) 
     62 
    6163                float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy).xy; 
    6264                const float2 offsetTransformed = myreflect(offset, mynoise); 
     
    7173 
    7274                // sample downsampled texture in order to speed up texture accesses 
    73                 float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz; 
    74                 //float3 sample_position = tex2D(positions, texcoord).xyz; 
     75                float eyeSpaceDepth = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).w; 
     76 
     77                float3 sample_position = eyePos - viewDir * eyeSpaceDepth;  
     78                 
    7579 
    7680                float3 vector_to_sample = sample_position - centerPosition.xyz; 
     
    112116                   const uniform float4x4 oldModelViewProj, 
    113117                   uniform float maxDepth, 
    114                    uniform float temporalCoherence 
     118                   uniform float temporalCoherence, 
     119                   uniform float3 eyePos 
    115120                   ) 
    116121{ 
     
    129134        const float currentDepth = centerPosition.w; 
    130135 
    131         const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w);//, viewDir); 
     136        /// the current view direction 
     137        float3 viewDir = normalize(IN.view); 
     138 
     139        const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos); 
    132140                 
    133141 
Note: See TracChangeset for help on using the changeset viewer.