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

eye linear depth not working

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

Legend:

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

    r2986 r2988  
    8383        OUT.color = col; 
    8484 
    85         OUT.color.xyz = color.w / 1e3f; 
     85        OUT.color.xyz = color.w; 
    8686         
    8787#if 1 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r2984 r2988  
    9595        // hack: squeeze some information about ambient into the texture 
    9696        //pix.col.w = glstate.material.emission.x; 
    97         pix.col.w = length(currentPos - IN.worldPos); 
     97        pix.col.w = length((currentPos - IN.worldPos) * maxDepth); 
    9898 
    9999        return pix; 
     
    118118        // hack: squeeze some information about the ambient term into the target 
    119119        //pix.col.w = glstate.material.emission.x; 
    120         pix.col.w = length(currentPos - IN.worldPos); 
     120        pix.col.w = length((currentPos - IN.worldPos) * maxDepth); 
    121121 
    122122        return pix; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r2987 r2988  
    5555} 
    5656 
     57 
    5758float3 Interpol(float2 w, float3 bl, float3 br, float3 tl, float3 tr) 
    5859{ 
    5960        //float3 x1 = lerp(oldColor.w, logLumScaled, 0.1f); 
    60         float3 x1 = bl * (1.0f - w.x) + br * w.x; 
    61         float3 x2 = tl * (1.0f - w.x) + tr * w.x; 
    62  
    63         float3 v = x1 * (1.0f - w.y) + x2 * w.y; 
     61        float3 x1 = lerp(bl, tl, w.y); //bl * (1.0f - w.x) + br * w.x; 
     62        float3 x2 = lerp(br, tr, w.y); //tl * (1.0f - w.x) + tr * w.x; 
     63 
     64        float3 v = lerp(x1, x2, w.x); //x1 * (1.0f - w.y) + x2 * w.y; 
    6465 
    6566        return v; 
    6667} 
     68 
     69 
     70float2 Interpol2(float2 w, float2 bl, float2 br, float2 tl, float2 tr) 
     71{ 
     72        //float3 x1 = lerp(oldColor.w, logLumScaled, 0.1f); 
     73        float2 x1 = lerp(bl, tl, w.y); //bl * (1.0f - w.x) + br * w.x; 
     74        float2 x2 = lerp(br, tr, w.y); //tl * (1.0f - w.x) + tr * w.x; 
     75 
     76        float2 v = lerp(x1, x2, w.x); //x1 * (1.0f - w.y) + x2 * w.y; 
     77 
     78        return v; 
     79} 
     80 
    6781 
    6882/** The ssao shader returning the an intensity value between 0 and 1 
     
    8195                   uniform float3 br, 
    8296                   uniform float3 tl, 
    83                    uniform float3 tr, 
    84                    uniform float maxDepth 
     97                   uniform float3 tr 
    8598                   ) 
    8699{ 
     
    92105        float numSamples = 0; 
    93106 
    94         const float y_angle = 0.43633231299858239423092269212215; 
    95         const float x_angle = 0.58177641733144319230789692282954; 
    96107 
    97108        for (int i = 0; i < NUM_SAMPLES; ++ i)  
     
    117128                float eyeSpaceDepth = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).w; 
    118129 
    119                 float newOffs = 0.5f + offsetTransformed * 0.5f; 
     130                float2 newOffs = 0.5f + offsetTransformed * 0.5f; 
    120131 
    121132                float3 rotView = normalize(Interpol(newOffs, bl, br, tl, tr)); 
    122                 float3 sample_position = (eyePos - rotView * eyeSpaceDepth) / maxDepth; 
     133                float3 sample_position = eyePos - rotView * eyeSpaceDepth; 
    123134                //float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz; 
    124135 
     
    180191        // the current world position 
    181192        const float4 centerPosition = tex2D(positions, IN.texCoord.xy); 
    182         // the current color 
     193 
     194        const float eyeDepth = tex2D(colors, IN.texCoord.xy).w; 
     195        float3 view2 = normalize(Interpol(IN.texCoord.xy, bl, br, tl, tr)); 
     196         
     197        float4 centerPosition2; 
     198        centerPosition2.xyz = eyePos - view2 * eyeDepth; 
     199        // the current depth 
    183200        const float currentDepth = centerPosition.w; 
    184201 
     
    186203        float3 viewDir = normalize(IN.view); 
    187204 
    188 /*      const float eyeSpaceDepth = tex2D(colors, IN.texCoord.xy).w; 
    189  
    190         float3 sample_position = eyePos - viewDir * eyeSpaceDepth;  
    191  
    192         OUT.illum_col.xyz = centerPosition.xyz * maxDepth -  sample_position; 
    193         OUT.illum_col.w = currentDepth; 
    194         return OUT; 
    195 */ 
    196205        //const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos); 
    197         const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos, positions, 
    198                 bl, br, tl, tr, maxDepth); 
     206        const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition2, w, viewDir, eyePos, positions, 
     207                bl, br, tl, tr); 
    199208                 
    200209 
Note: See TracChangeset for help on using the changeset viewer.