Ignore:
Timestamp:
08/27/08 20:05:41 (16 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r2874 r2876  
    6565        float total_ao = 0.0; 
    6666 
    67         for (int i = 0; i < NUM_SAMPLES; i ++)  
     67        for (int i = 0; i < NUM_SAMPLES; ++ i)  
    6868        { 
    6969                float2 offset = samples[i]; 
     
    8585 
    8686                float3 vector_to_sample = sample_position - centerPosition.xyz; 
    87                 float length_to_sample = length(vector_to_sample); 
     87                const float length_to_sample = length(vector_to_sample); 
     88 
    8889                float3 direction_to_sample = vector_to_sample / length_to_sample; 
    8990 
    9091                // Angle between current normal and direction to sample controls AO intensity. 
    91                 float cos_angle = dot(direction_to_sample, currentNormal); 
    92                 cos_angle = max(cos_angle, 0.0f); 
     92                const float cos_angle = max(dot(direction_to_sample, currentNormal), 0.0f); 
    9393 
    9494                // distance between current position and sample position controls AO intensity. 
    95                 float distance_intensity =  
     95                const float distance_intensity =  
    9696                        (SAMPLE_INTENSITY * DISTANCE_SCALE) / (DISTANCE_SCALE + length_to_sample * length_to_sample); 
    9797 
    9898                // if surface normal perpenticular to view dir, some samples probably count less  
    9999                // => compensate for this 
    100                 float view_correction = 1.0f + VIEW_CORRECTION_SCALE * (1.0f - dot(currentViewDir, currentNormal)); 
     100                const float view_correction = 1.0f + VIEW_CORRECTION_SCALE * (1.0f - dot(currentViewDir, currentNormal)); 
    101101 
    102102                total_ao += cos_angle * distance_intensity * view_correction; 
     
    104104 
    105105        return max(0.0f, 1.0f - total_ao); 
    106         //return dot(currentViewDir, currentNormal); 
    107106} 
    108107 
     
    165164        if ((tex.x >= 0.0f) && (tex.x < 1.0f) &&  
    166165                (tex.y >= 0.0f) && (tex.y < 1.0f) &&  
    167                 (abs(depthDif)  < 1e-3f)) 
     166                (abs(depthDif) < 1e-3f)) 
    168167        { 
    169168                OUT.illum_col.x = ao * expFactor + oldCol.x * (1.0f - expFactor); 
     
    177176        OUT.illum_col.w = currentDepth; 
    178177 
    179         //OUT.combined_col = float4(newDepth / oldDepth * 100, 0, 0, 1) ; 
    180         //OUT.combined_col = float4(newDepth, 0, 0, 1) ; 
    181  
    182178        return OUT; 
    183179} 
Note: See TracChangeset for help on using the changeset viewer.