Ignore:
Timestamp:
12/20/08 09:00:10 (16 years ago)
Author:
mattausch
Message:

worked on submission

File:
1 edited

Legend:

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

    r3225 r3226  
    225225        total_ao /= numSamples; 
    226226 
    227 #if 1 
     227#if 0 
    228228        // if surface normal perpenticular to view dir, approx. half of the samples will not count 
    229229        // => compensate for this (on the other hand, projected sampling area could be larger!) 
    230230        const float viewCorrection = 1.0f + VIEW_CORRECTION_SCALE * max(dot(viewDir, normal), 0.0f); 
    231         total_ao += cosAngle * aoContrib * viewCorrection; 
     231        total_ao *= viewCorrection; 
    232232 
    233233#endif 
    234234 
    235         return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples); 
     235        //return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples); 
     236        return float3(total_ao, validSamples, numSamples); 
    236237} 
    237238 
     
    260261                        float newWeight, 
    261262                        float sampleIntensity, 
    262                         bool isMovingObject 
     263                        bool isMovingObject, 
     264                        sampler2D normalTex 
    263265                        ) 
    264266{ 
     
    288290                 
    289291 
     292                // the normal of the current sample 
     293                //const float3 sampleNormal = tex2Dlod(normalTex, float4(texcoord, 0, 0)).xyz; 
     294                // angle between current normal and direction to sample controls AO intensity. 
     295                //float cosAngle2 = .5f + dot(sampleNormal, -normal) * 0.5f; 
     296 
    290297                //////////////// 
    291298                //-- compute contribution of sample using the direction and angle 
     
    303310                //const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f; 
    304311 
     312                //total_ao += cosAngle2 * cosAngle * aoContrib; 
    305313                total_ao += cosAngle * aoContrib; 
    306314 
     
    318326                validSamples = max(validSamples, (1.0f - tooFarAway) * pixelValid); 
    319327 
    320 #ifdef USE_GTX 
     328#if 1//#ifdef U//USE_GTX 
    321329                // we can bail out early and use a minimal #samples) 
    322330                // if some conditions are met as long as the hardware supports it 
     
    343351 
    344352        return float3(total_ao, validSamples, numSamples); 
     353        //return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples); 
    345354} 
    346355 
     
    417426        if (eyeSpaceDepth < 1e10f) 
    418427        { 
    419                 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity, isMovingObject); 
     428                ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity, isMovingObject, normals); 
    420429                //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals, sampleIntensity); 
    421430        } 
     
    446455                else if (ao.y > partlyResetThres) 
    447456                { 
    448                         //oldWeight = min(oldWeight, 4.0f * newWeight); 
    449                         oldWeight = .0f;  
     457                        oldWeight = min(oldWeight, 4.0f * newWeight); 
     458                        //oldWeight = .0f;  
    450459                } 
    451460        } 
     
    458467        //-- blend ao between old and new samples (and avoid division by zero) 
    459468 
    460         OUT.illum_col.x = (ao.x * newWeight + oldSsao * oldWeight) / max(1e-6f, newWeight + oldWeight); 
     469        //OUT.illum_col.x = (ao.x * newWeight + oldSsao * oldWeight) / max(1e-6f, newWeight + oldWeight); 
     470        OUT.illum_col.x = (ao.x * newWeight + oldSsao * oldWeight) / (newWeight + oldWeight); 
    461471 
    462472        OUT.illum_col.y = combinedWeight; 
Note: See TracChangeset for help on using the changeset viewer.