Changeset 2876 for GTP


Ignore:
Timestamp:
08/27/08 20:05:41 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
Files:
2 edited

Legend:

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

    r2875 r2876  
    8787 
    8888                float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, 1)).xyz; 
    89                 float3 sample_color = tex2Dlod(colors, float4(texcoord, 0, 1)).xyz; 
     89                float3 sample_color = tex2Dlod(colors, float4(texcoord, 0, 2)).xyz; 
    9090 
    9191                float3 vector_to_sample = sample_position - centerPosition.xyz; 
    92                 float length_to_sample = length(vector_to_sample); 
     92                const float length_to_sample = length(vector_to_sample); 
     93 
    9394                float3 direction_to_sample = vector_to_sample / length_to_sample; 
    9495 
    9596                // Angle between current normal and direction to sample controls AO intensity. 
    96                 float cos_angle = dot(direction_to_sample, currentNormal); 
    97                 cos_angle = max(cos_angle, 0.0f); 
     97                float cos_angle = max(dot(direction_to_sample, currentNormal), 0); 
    9898 
    9999                // distance between current position and sample position controls AO intensity. 
    100                 float distance_intensity =  
     100                const float distance_intensity =  
    101101                        (SAMPLE_INTENSITY * DISTANCE_SCALE) / (DISTANCE_SCALE + length_to_sample * length_to_sample); 
    102102 
    103103                // if normal perpenticular to view dir, only half of the samples count 
    104                 float view_correction = 1.0f + VIEW_CORRECTION_SCALE * (1.0f - dot(currentViewDir, currentNormal)); 
     104                const float view_correction = 1.0f + VIEW_CORRECTION_SCALE * (1.0f - dot(currentViewDir, currentNormal)); 
    105105 
    106106                total_color.w -= cos_angle * distance_intensity * view_correction; 
  • 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.