Ignore:
Timestamp:
10/02/08 16:34:58 (16 years ago)
Author:
mattausch
Message:

what todo with tone mapping: manually donwsample??
or manually downsample ssao?? or use smaller rendertarget for ssao solution??

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

    r2990 r2991  
    6464                   uniform sampler2D positions, 
    6565                   uniform sampler2D normals, 
    66                    uniform float3 lightDir, 
    67                   uniform sampler2D oldColors 
     66                   uniform float3 lightDir 
     67                  //, uniform sampler2D oldColors 
    6868                   ) 
    6969{ 
     
    8383        OUT.color = col; 
    8484         
    85 #if 1 
     85#if 0 
    8686 
    8787        OUT.color.w = color.w; 
     
    9292        //-- write out logaritmic luminance for tone mapping 
    9393 
    94         float4 oldColor = tex2Dlod(colors, float4(IN.texCoord.xy, 0, MAX_LOD_LEVEL)); 
     94        // the old loglum is stored in the hightest mipmap-level 
     95        float oldLogLum = tex2Dlod(colors, float4(IN.texCoord.xy, 0, MAX_LOD_LEVEL)).w; 
    9596 
    9697        const float3 w = float3(0.299f, 0.587f, 0.114f); 
     
    102103        float logLumScaled = logLum * INV_LOGLUM_RANGE - logLumOffset; 
    103104 
    104         if (oldColor.w > 0) 
    105                 OUT.color.w = lerp(oldColor.w, logLumScaled, 0.1f); 
     105        if (oldLogLum > 0) 
     106                OUT.color.w = lerp(oldLogLum, logLumScaled, 0.1f); 
    106107        else 
    107108                OUT.color.w = logLumScaled; 
     
    164165                                  uniform sampler2D noiseTexture, 
    165166                                  uniform float2 samples[NUM_PCF_TABS], 
    166                                   uniform float3 lightDir, 
    167                                   uniform sampler2D oldColors 
     167                                  uniform float3 lightDir 
     168                                  //, uniform sampler2D oldColors 
    168169                                  ) 
    169170{ 
     
    190191        //if ((emmisive < 1.5f) // hack: prevent shadowing the sky       
    191192        if ( 
    192                 (position.w > 1e19f) 
     193                (position.w < 1e19f) 
    193194                && (angle > 1e-3f) // shadow only if diffuse color has some minimum intensity 
    194195                ) 
     
    216217        //-- write out logaritmic luminance for tone mapping 
    217218 
    218         float4 oldColor = tex2Dlod(colors, float4(IN.texCoord.xy, 0, MAX_LOD_LEVEL)); 
     219#if 0 
     220 
     221        OUT.color.w = color.w; 
     222 
     223#else 
     224 
     225        float oldLogLum = tex2Dlod(colors, float4(IN.texCoord.xy, 0, MAX_LOD_LEVEL)).w; 
    219226 
    220227        const float3 w = float3(0.299f, 0.587f, 0.114f); 
     
    226233        float logLumScaled = logLum * INV_LOGLUM_RANGE - logLumOffset; 
    227234 
    228         if (oldColor.w > 0) 
    229                 OUT.color.w = lerp(oldColor.w, logLumScaled, 0.1f); 
     235        if (oldLogLum > 0) 
     236                OUT.color.w = lerp(oldLogLum, logLumScaled, 0.1f); 
    230237        else 
    231238                OUT.color.w = logLumScaled; 
    232          
     239#endif   
    233240        return OUT; 
    234241} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg

    r2990 r2991  
    4444 
    4545 
    46 float3 Interpol(float2 w, float3 bl, float3 br, float3 tl, float3 tr) 
    47 { 
    48         //float3 x1 = lerp(oldColor.w, logLumScaled, 0.1f); 
    49         float3 x1 = lerp(bl, tl, w.y); //bl * (1.0f - w.x) + br * w.x; 
    50         float3 x2 = lerp(br, tr, w.y); //tl * (1.0f - w.x) + tr * w.x; 
    51  
    52         float3 v = lerp(x1, x2, w.x); //x1 * (1.0f - w.y) + x2 * w.y; 
     46 
     47inline float3 Interpol(float2 w, float3 bl, float3 br, float3 tl, float3 tr) 
     48{ 
     49        float3 x1 = lerp(bl, tl, w.y); 
     50        float3 x2 = lerp(br, tr, w.y);  
     51        float3 v = lerp(x1, x2, w.x);  
    5352 
    5453        return v; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r2990 r2991  
    3434inline float3 Interpol(float2 w, float3 bl, float3 br, float3 tl, float3 tr) 
    3535{ 
    36         //float3 x1 = lerp(oldColor.w, logLumScaled, 0.1f); 
    37         float3 x1 = lerp(bl, tl, w.y); //bl * (1.0f - w.x) + br * w.x; 
    38         float3 x2 = lerp(br, tr, w.y); //tl * (1.0f - w.x) + tr * w.x; 
    39  
    40         float3 v = lerp(x1, x2, w.x); //x1 * (1.0f - w.y) + x2 * w.y; 
     36        float3 x1 = lerp(bl, tl, w.y); 
     37        float3 x2 = lerp(br, tr, w.y);  
     38        float3 v = lerp(x1, x2, w.x);  
    4139 
    4240        return v; 
     
    4442 
    4543 
    46 inline float3 ReconstructSamplePosition(uniform sampler2D colors, float2 texcoord, float3 bl, float3 br, float3 tl, float3 tr) 
     44inline float3 ReconstructSamplePosition(float3 eyePos,  
     45                                                                                uniform sampler2D colors, 
     46                                                                                float2 texcoord,  
     47                                                                                float3 bl, float3 br, float3 tl, float3 tr) 
    4748{ 
    4849        /*float eyeSpaceDepth = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).w; 
     
    5051        // reconstruct world space position 
    5152        float3 rotView = normalize(Interpol(texcoord, bl, br, tl, tr)); 
    52         float3 sample_position = eyePos - rotView * eyeSpaceDepth; 
    53         */ 
     53        float3 sample_position = eyePos - rotView * eyeSpaceDepth;*/ 
    5454        float3 sample_position = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz; 
    5555 
     
    102102                        ++ numSamples; 
    103103 
    104                 float3 sample_position = ReconstructSamplePosition(colors, texcoord, bl, br, tl, tr); 
     104                float3 sample_position = ReconstructSamplePosition(eyePos, colors, texcoord, bl, br, tl, tr); 
    105105 
    106106                float3 vector_to_sample = sample_position - centerPosition.xyz; 
     
    174174 
    175175        //const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos); 
    176         const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, /*viewDir, */eyePos, bl, br, tl, tr); 
     176        const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, eyePos, bl, br, tl, tr); 
    177177                 
    178178 
     
    208208                (tex.y >= 0.0f) && (tex.y < 1.0f) &&  
    209209                (abs(depthDif) < 1e-4f)  
    210                 // check if visibility changed in the surrounding area: 
    211                 // then we have to recompute 
    212                 && ((newWeight < 10) || (oldNumSamples > 0.9f * newNumSamples)) 
     210                // if visibility changed in the surrounding area we have to recompute 
     211                && (oldNumSamples > 0.8f * newNumSamples) 
    213212                //&& (oldAvgDepth / newAvgDepth > 0.99) 
    214213                ) 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg

    r2975 r2991  
    105105        return OUT; 
    106106} 
     107 
     108 
     109pixel CalcAvgLogLum(frag IN, uniform sampler2D colors) 
     110{ 
     111        //////////// 
     112        //-- write out logaritmic luminance for tone mapping 
     113 
     114        pixel OUT; 
     115 
     116        // the old loglum is stored in the hightest mipmap-level 
     117        float4 color = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 
     118        float oldLogLum = tex2Dlod(colors, float4(IN.texCoord.xy, 0, MAX_LOD_LEVEL)).w; 
     119 
     120        // the intensity weights 
     121        const float3 w = float3(0.299f, 0.587f, 0.114f); 
     122 
     123        float lum = dot(color.rgb, w); 
     124        float logLum = log(1e-5f + lum); 
     125 
     126        float logLumOffset = MINLOGLUM * INV_LOGLUM_RANGE; 
     127        float logLumScaled = logLum * INV_LOGLUM_RANGE - logLumOffset; 
     128 
     129        OUT.color = color; 
     130 
     131        if (oldLogLum > 0) 
     132                OUT.color.w = lerp(oldLogLum, logLumScaled, 0.1f); 
     133        else 
     134                OUT.color.w = logLumScaled; 
     135} 
Note: See TracChangeset for help on using the changeset viewer.