- Timestamp:
- 08/27/08 20:05:41 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r2874 r2876 65 65 float total_ao = 0.0; 66 66 67 for (int i = 0; i < NUM_SAMPLES; i ++)67 for (int i = 0; i < NUM_SAMPLES; ++ i) 68 68 { 69 69 float2 offset = samples[i]; … … 85 85 86 86 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 88 89 float3 direction_to_sample = vector_to_sample / length_to_sample; 89 90 90 91 // 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); 93 93 94 94 // distance between current position and sample position controls AO intensity. 95 float distance_intensity =95 const float distance_intensity = 96 96 (SAMPLE_INTENSITY * DISTANCE_SCALE) / (DISTANCE_SCALE + length_to_sample * length_to_sample); 97 97 98 98 // if surface normal perpenticular to view dir, some samples probably count less 99 99 // => 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)); 101 101 102 102 total_ao += cos_angle * distance_intensity * view_correction; … … 104 104 105 105 return max(0.0f, 1.0f - total_ao); 106 //return dot(currentViewDir, currentNormal);107 106 } 108 107 … … 165 164 if ((tex.x >= 0.0f) && (tex.x < 1.0f) && 166 165 (tex.y >= 0.0f) && (tex.y < 1.0f) && 167 (abs(depthDif) 166 (abs(depthDif) < 1e-3f)) 168 167 { 169 168 OUT.illum_col.x = ao * expFactor + oldCol.x * (1.0f - expFactor); … … 177 176 OUT.illum_col.w = currentDepth; 178 177 179 //OUT.combined_col = float4(newDepth / oldDepth * 100, 0, 0, 1) ;180 //OUT.combined_col = float4(newDepth, 0, 0, 1) ;181 182 178 return OUT; 183 179 }
Note: See TracChangeset
for help on using the changeset viewer.