Ignore:
Timestamp:
12/01/08 18:38:36 (16 years ago)
Author:
mattausch
Message:

only adapting filter size left ...

File:
1 edited

Legend:

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

    r3199 r3203  
    174174        float total_ao = .0f; 
    175175        float numSamples = .0f; 
     176        float validSamples = .0f; 
    176177 
    177178        for (int i = 0; i < NUM_SAMPLES; ++ i)  
     
    233234#endif 
    234235                // check if the samples have been valid in the last frame 
    235                 //numSamples += (1.0f - step(1.0f, lengthToSample)) * sampleColor.x; 
     236                validSamples += (1.0f - step(1.0f, lengthToSample)) * sampleColor.x; 
     237 
    236238                ++ numSamples; 
    237239        } 
     
    239241        total_ao /= numSamples; 
    240242 
    241         return float3(max(0.0f, 1.0f - total_ao), .0f, numSamples); 
     243        return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples); 
    242244} 
    243245 
     
    287289                const float2 texcoord = IN.texCoord.xy + offsetTransformed * scaleFactor; 
    288290 
    289                 const float4 sampleColor = tex2Dlod(colors, float4(texcoord, 0, 0)); 
     291                const float4 sampleColor = tex2Dlod(colors, float4(texcoord, .0f, .0f)); 
    290292                const float3 samplePos = ReconstructSamplePos(sampleColor.w, texcoord, bl, br, tl, tr); 
    291293                 
     
    303305                // angle between current normal and direction to sample controls AO intensity. 
    304306                const float cosAngle = max(dot(dirSample, normal), .0f); 
    305          
    306                 // the distance_scale offset is used to avoid singularity that occurs at global illumination when  
    307                 // the distance to a sample approaches zero 
    308                 //const float aoContrib = SAMPLE_INTENSITY / (DISTANCE_SCALE + lengthToSample * lengthToSample); 
    309307                const float aoContrib = SAMPLE_INTENSITY / sqrLen; 
    310308                //const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f; 
     
    321319 
    322320                // check if the samples have been valid in the last frame 
    323                 validSamples += (1.0f - step(1.0f, lengthToSample)) * sampleColor.x; 
     321                // hack: the distance measure can fail in some cases => choose something different 
     322                const float tooFarAway = step(1.0f, lengthToSample); 
     323                validSamples += (1.0f - tooFarAway) * sampleColor.x; 
    324324                //validSamples += sampleColor.x; 
    325325 
    326326                ++ numSamples; 
    327                 //if ((validSamples < 1.0f) && (newWeight > 20) && (numSamples >= 8)) break; 
     327 
     328                //if ((validSamples < 1.0f) && (newWeight > 200) && (numSamples >= 8)) break; 
     329                if ((validSamples < 1.0f) && (numSamples >= 8)) break; 
    328330        } 
    329331 
     
    401403        if (eyeSpaceDepth < 1e10f) 
    402404        { 
    403                 //ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight); 
    404                 ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals); 
     405                ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight); 
     406                //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals); 
    405407        } 
    406408        else 
Note: See TracChangeset for help on using the changeset viewer.