Ignore:
Timestamp:
09/26/08 10:31:58 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r2974 r2975  
    8181         
    8282        OUT.color = col; 
    83         OUT.color.w = color.w; 
    84  
    85         // write out logaritmic luminance for tone mapping 
     83         
     84 
     85        //////////// 
     86        //-- write out logaritmic luminance for tone mapping 
     87 
    8688        const float3 w = float3(0.299f, 0.587f, 0.114f); 
    8789 
     
    8991        float logLum = log(1e-5f + lum); 
    9092 
    91         float invLogLumRange =  1 / (MAXLOGLUM + MINLOGLUM); 
    92         float logLumOffset = MINLOGLUM * invLogLumRange; 
    93         float logLumScaled = logLum * invLogLumRange + logLumOffset; 
     93        float logLumOffset = MINLOGLUM * INV_LOGLUM_RANGE; 
     94        float logLumScaled = logLum * INV_LOGLUM_RANGE - logLumOffset; 
    9495 
    9596        OUT.color.w = logLumScaled; 
     
    194195        OUT.color = (emmisive > 1.5f) ? color: (ambient + diffuse) * color; 
    195196 
    196         // write out logaritmic luminance for tone mapping 
     197        //////////// 
     198        //-- write out logaritmic luminance for tone mapping 
     199 
    197200        const float3 w = float3(0.299f, 0.587f, 0.114f); 
    198201 
     
    200203        float logLum = log(1e-5f + lum); 
    201204 
    202         OUT.color.w = 100;//logLum; 
     205        float logLumOffset = MINLOGLUM * INV_LOGLUM_RANGE; 
     206        float logLumScaled = logLum * INV_LOGLUM_RANGE - logLumOffset; 
     207 
     208        OUT.color.w = logLumScaled; 
    203209         
    204210        return OUT; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg

    r2974 r2975  
    5252                                 uniform float2 samples[NUM_SAMPLES], 
    5353                                 uniform float3 currentNormal, 
    54                                  uniform float3 currentViewDir, 
    55                                  uniform float4 centerPosition 
     54                                 uniform float4 centerPosition, 
     55                                 float w 
     56                                 //, uniform float3 currentViewDir 
    5657                                 ) 
    5758{ 
    5859        GiStruct gi; 
    59  
    60         // the w coordinate from the persp. projection 
    61         float w = centerPosition.w; 
    6260 
    6361        // Check in a circular area around the current position. 
     
    117115        } 
    118116 
    119         gi.illum = saturate(total_color); 
     117        gi.illum = total_color; 
    120118        gi.ao = float2(max(0.0f, 1.0f - total_ao), numSamples); 
    121119 
     
    143141 
    144142        float4 norm = tex2D(normals, IN.texCoord.xy); 
    145          
    146         // the ambient term 
     143        float3 normal = normalize(norm.xyz);     
     144        // something like a constant ambient term 
    147145        const float amb = norm.w; 
    148  
    149         // expand normal 
    150         float3 normal = normalize(norm.xyz); 
    151  
    152146        /// the current view direction 
    153         float3 viewDir;// = normalize(IN.view); 
    154  
     147        //float3 viewDir = normalize(IN.view); 
     148 
     149        // the w coordinate from the persp. projection 
     150        float w = norm.w; 
    155151        // the current world position 
    156152        const float4 centerPosition = tex2D(positions, IN.texCoord.xy); 
    157          
    158153        // the current color 
    159154        const float4 currentCol = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 
    160155        // the current depth is stored in the w component 
    161         const float currentDepth = currentCol.w; 
    162  
    163         GiStruct gi = globIllum(IN, colors, positions, noiseTexture, samples, normal, viewDir, centerPosition); 
     156        const float currentDepth = centerPosition.w; 
     157 
     158        GiStruct gi = globIllum(IN, colors, positions, noiseTexture, samples, normal, centerPosition, w); //, viewDir); 
    164159         
    165160 
     
    186181 
    187182        const float oldNumSamples = oldSsao.y; 
     183        const float oldAvgDepth = oldSsao.z; 
    188184 
    189185        if ((temporalCoherence > 0.0f) && 
    190186                (tex.x >= 0.0f) && (tex.x < 1.0f) &&  
    191187                (tex.y >= 0.0f) && (tex.y < 1.0f) &&  
    192                 (abs(depthDif)  < 1e-3f) 
    193                 && (oldNumSamples > gi.ao.y - 1.5f) // check if something happened in the surrounding area 
     188                (abs(depthDif) < 1e-3f) 
     189                // check if something changed in the surrounding area 
     190                && (oldNumSamples > 0.2 * gi.ao.y) 
     191                && (oldAvgDepth / newAvgDepth > 0.99) 
    194192                ) 
    195193        { 
     
    218216                          uniform sampler2D ssaoTex, 
    219217                          uniform sampler2D illumTex 
    220                    ) 
     218                          ) 
    221219{ 
    222220        pixel OUT; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r2974 r2975  
    117117 
    118118        float4 norm = tex2D(normals, IN.texCoord.xy); 
    119          
    120         // expand normal 
    121119        float3 normal = normalize(norm.xyz); 
    122          
     120 
    123121        // a constant ambient term 
    124122        const float amb = norm.w; 
    125123        // the w coordinate from the persp. projection 
    126124        float w = norm.w; 
    127  
    128125        // the current world position 
    129126        const float4 centerPosition = tex2D(positions, IN.texCoord.xy); 
    130          
    131127        // the current color 
    132128        const float currentDepth = centerPosition.w; 
     
    141137        realPos.w = 1.0f; 
    142138 
    143         // reproject 
     139 
     140        /////////// 
     141        //-- reprojection from new frame into old one 
     142 
    144143        float4 oldPos = mul(oldModelViewProj, realPos); 
    145144 
     
    161160                (tex.y >= 0.0f) && (tex.y < 1.0f) &&  
    162161                (abs(depthDif) < 1e-3f)  
    163                 && (oldNumSamples > ao.y - 1.5f) // check if something happened in the surrounding area 
     162                // check if visibility changed in the surrounding area: 
     163                // then we have to recompute 
     164                && (oldNumSamples > ao.y - 1.5f)  
    164165                ) 
    165166        { 
    166167                // increase the weight for convergence 
    167168                newWeight = oldWeight + 1.0f; 
    168  
    169                 //OUT.illum_col = (float4)ao * expFactor + oldCol.x * (1.0f - expFactor); 
    170169                OUT.illum_col.xy = (ao.xy + oldCol.xy * oldWeight) / newWeight; 
    171170 
     
    193192 
    194193        float4 col = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 
    195         float depth = tex2Dlod(positions, float4(IN.texCoord.xy, 0, 0)).w; 
    196194        float4 ao = tex2D(ssaoTex, IN.texCoord.xy); 
    197195 
    198196        OUT.illum_col = col * ao.x; 
    199         OUT.illum_col.w = ao.w; 
     197        //OUT.illum_col.w = ao.w; 
     198        OUT.illum_col.w = col.w; 
    200199 
    201200        return OUT; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg

    r2974 r2975  
    9090        // obtain new image key from highest mipmap level 
    9191        float logLumScaled = tex2Dlod(colors, float4(.5f, .5f, 0, 99)).w; 
    92  
    93         float logLumRange = MAXLOGLUM + MINLOGLUM; 
    94         //float logLumOffset = MINLOGLUM * logLumRange; 
    95         float logLum = logLumScaled * logLumRange - MINLOGLUM; 
     92        float logLum = logLumScaled * LOGLUM_RANGE + MINLOGLUM; 
    9693 
    9794        float newImageKey = exp(logLum); 
Note: See TracChangeset for help on using the changeset viewer.