Ignore:
Timestamp:
10/06/08 03:02:23 (16 years ago)
Author:
mattausch
Message:

tried downsampling

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

Legend:

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

    r3003 r3006  
    6262                                   uniform float2 samples[NUM_SAMPLES], 
    6363                                   uniform float3 currentNormal, 
    64                                    uniform float4 centerPosition, 
     64                                   uniform float3 centerPosition, 
    6565                                   float w, 
    6666                                   uniform float3 eyePos, 
     
    103103                //if ((texcoord.x <= 1.0f) && (texcoord.x >= 0.0f) && (texcoord.y <= 1.0f) && (texcoord.y >= 0.0f)) ++ numSamples; 
    104104 
    105                 // reconstruct world space position from sample 
     105                ////////// 
     106                //-- reconstruct world space position from sample 
     107 
    106108                float4 sample = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)); 
    107109                const float eyeSpaceDepth = sample.w; 
     
    118120                float3 direction_to_sample = vector_to_sample / length_to_sample; 
    119121 
    120                 // Angle between current normal and direction to sample controls AO intensity. 
     122                // use angle between current normal and direction to sample controls AO intensity. 
    121123                float cos_angle = max(dot(direction_to_sample, currentNormal), 0); 
    122124 
     
    153155                   uniform sampler2D oldIllumTex, 
    154156                   const uniform float4x4 oldModelViewProj, 
     157                   const uniform float4x4 modelViewProj, 
    155158                   uniform float maxDepth, 
    156159                   uniform float temporalCoherence, 
     
    166169        float4 norm = tex2D(normals, IN.texCoord.xy); 
    167170        float3 normal = normalize(norm.xyz);     
    168         // something like a constant ambient term 
    169         const float amb = norm.w; 
    170          
    171         /// the current view direction 
    172         //float3 viewDir = normalize(IN.view); 
    173171 
    174172        // the w coordinate from the persp. projection 
    175173        float w = norm.w; 
    176         // the current world position 
    177         const float4 centerPosition2 = tex2D(positions, IN.texCoord.xy); 
    178  
    179         /// reconstruct position from the eye space depth 
    180         float3 viewDir = normalize(IN.view); 
    181         const float eyeDepth = tex2D(colors, IN.texCoord.xy).w; 
    182          
    183         float4 centerPosition; 
     174 
     175 
     176        ///////////// 
     177        //-- reconstruct position from the eye space depth 
     178 
     179        float3 viewDir = Interpol(IN.texCoord.xy, bl, br, tl, tr);//IN.view; 
     180        const float eyeDepth = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)).w; 
     181         
     182        float3 centerPosition; 
    184183        centerPosition.xyz = eyePos - viewDir * eyeDepth; 
    185  
    186         centerPosition.w = centerPosition2.w; 
    187  
    188         // the current color 
    189         const float4 currentCol = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 
    190         // the current depth is stored in the w component 
    191         const float currentDepth = centerPosition.w; 
    192  
    193         GiStruct gi = globIllum(IN, colors, noiseTexture, samples, normal, centerPosition2, w, eyePos, bl, br, tl, tr); 
     184         
     185        //const float3 centerPosition = tex2D(positions, IN.texCoord.xy).xyz; 
     186 
     187 
     188        /////////// 
     189        //-- compute color bleeding + ao 
     190 
     191        GiStruct gi = globIllum(IN, colors, noiseTexture, samples, normal, centerPosition, w, eyePos, bl, br, tl, tr); 
    194192         
    195193 
     
    197195        //-- compute temporally smoothing 
    198196 
    199         float4 realPos = centerPosition * maxDepth; 
    200         realPos.w = 1.0f; 
    201  
    202         float4 oldPos = mul(oldModelViewProj, realPos); 
    203  
    204         const float newDepth = oldPos.z / oldPos.w; 
    205  
    206         float2 tex = (oldPos.xy / oldPos.w) * 0.5f + 0.5f; 
    207  
     197        float4 realPos = float4(centerPosition * maxDepth, 1.0f); 
     198 
     199 
     200        // calculcate the current projected depth for next frame 
     201        float4 currentPos = mul(modelViewProj, realPos); 
     202        currentPos /= currentPos.w; 
     203        const float currentDepth = currentPos.z; 
     204         
     205 
     206        /////////// 
     207        //-- reprojection new frame into old one  
     208         
     209        // calculate projected depth 
     210        float4 projPos = mul(oldModelViewProj, realPos); 
     211        projPos /= projPos.w; 
     212 
     213        // the current depth projected into the old frame 
     214        const float projDepth = projPos.z; 
     215 
     216        // fit from unit cube into 0 .. 1 
     217        float2 tex = (projPos.xy) * 0.5f + 0.5f; 
     218 
     219        // retrieve the sample from the last frame 
    208220        float4 oldSsao = tex2D(oldSsaoTex, tex); 
    209221        float4 oldIllum = tex2D(oldIllumTex, tex); 
    210222 
    211223        const float oldDepth = oldSsao.w; 
    212         const float depthDif = 1.0f - newDepth / oldDepth; 
     224        const float depthDif = 1.0f - projDepth / oldDepth; 
    213225 
    214226        float oldWeight = clamp(oldSsao.z, 0, temporalCoherence); 
     227 
    215228        float newWeight; 
    216229 
    217         const float oldNumSamples = oldSsao.y; 
    218         const float oldAvgDepth = oldSsao.z; 
     230        //const float oldNumSamples = oldSsao.y; 
     231        //const float oldAvgDepth = oldSsao.z; 
    219232 
    220233        if (//(temporalCoherence > 0.0f) && 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3005 r3006  
    66 
    77 
    8 #define USE_EYE_SPACE_DEPTH 0 
     8#define USE_EYE_SPACE_DEPTH 1 
    99 
    1010 
     
    7171                   uniform float2 samples[NUM_SAMPLES], 
    7272                   uniform float3 currentNormal, 
    73                    uniform float4 centerPosition, 
     73                   uniform float3 centerPosition, 
    7474                   uniform float scaleFactor, 
    7575                   uniform float3 eyePos, 
     
    161161        pixel OUT; 
    162162 
    163         float4 norm = tex2D(normals, IN.texCoord.xy); 
     163        float4 norm = tex2Dlod(normals, float4(IN.texCoord, 0 ,0)); 
    164164        float3 normal = normalize(norm.xyz); 
    165165 
    166         // a constant ambient term 
    167         const float amb = norm.w; 
    168166        // the w coordinate from the persp. projection 
    169167        float w = norm.w; 
     
    173171        /// reconstruct position from the eye space depth 
    174172        float3 viewDir = IN.view; 
    175         const float eyeDepth = tex2D(colors, IN.texCoord.xy).w; 
    176  
    177         float4 centerPosition; 
     173        const float eyeDepth = tex2Dlod(colors, float4(IN.texCoord, 0, 0)).w; 
     174 
     175        float3 centerPosition; 
    178176        centerPosition.xyz = eyePos - viewDir * eyeDepth; 
    179         centerPosition.w = centerPosition.w; 
    180177 
    181178        const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition, w, eyePos, bl, br, tl, tr); 
     
    183180 
    184181        // the current world position 
    185         const float4 centerPosition = tex2D(positions, IN.texCoord.xy); 
     182        const float3 centerPosition = tex2Dlod(positions, float4(IN.texCoord, 0, 0)).xyz; 
    186183 
    187184        const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, eyePos, bl, br, tl, tr); 
     
    192189        //-- compute temporally smoothing 
    193190 
    194         float4 realPos = centerPosition * maxDepth; 
    195         realPos.w = 1.0f; 
    196  
    197         // calulcate the current depth 
    198         //const float currentDepth = centerPosition.w; 
    199          
    200         // apply modelview matrix 
     191        float4 realPos = float4(centerPosition * maxDepth, 1.0f); 
     192 
     193 
     194        // calculcate the current projected depth for next frame 
    201195        float4 currentPos = mul(modelViewProj, realPos); 
    202196        currentPos /= currentPos.w; 
     
    217211        float2 tex = (projPos.xy) * 0.5f + 0.5f; 
    218212 
    219         // optain the sample from the last frame 
     213        // retrieve the sample from the last frame 
    220214        float4 oldCol = tex2D(oldTex, tex); 
    221215 
    222216        const float oldDepth = oldCol.w; 
     217        const float depthDif = 1.0f - projDepth / oldDepth; 
     218 
     219 
    223220        //const float oldNumSamples = oldCol.y; 
    224221        const float oldWeight = clamp(oldCol.z, 0, temporalCoherence); 
    225  
    226         const float depthDif = 1.0f - projDepth / oldDepth; 
    227222 
    228223        float newWeight; 
     
    264259        pixel OUT; 
    265260 
    266         float4 col = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 
    267         float4 ao = tex2D(ssaoTex, IN.texCoord.xy); 
     261        float4 col = tex2Dlod(colors, float4(IN.texCoord, 0, 0)); 
     262        float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
    268263 
    269264        OUT.illum_col = col * ao.x; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg

    r3005 r3006  
    2828    for(int i = 0; i < 4; ++ i) 
    2929    { 
    30         average += tex2D(colors, IN.texCoord + downSampleOffs[i]); 
     30        average += tex2Dlod(colors, float4(IN.texCoord + downSampleOffs[i],0,0)); 
    3131    } 
    3232         
    3333    average *= 1.0f / 4.0f; 
    3434 
    35     return tex2D(colors, IN.texCoord);//average; 
     35    return average; 
    3636} 
    3737     
Note: See TracChangeset for help on using the changeset viewer.