Changeset 2872 for GTP


Ignore:
Timestamp:
08/27/08 07:50:52 (16 years ago)
Author:
mattausch
Message:

working to incorporate indirect illumination

File:
1 edited

Legend:

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

    r2871 r2872  
    1010//#define SAMPLE_INTENSITY 0.125f 
    1111 
    12 #define AREA_SIZE 9e-1f 
    13 //#define VIEW_CORRECTION_SCALE 0.3f 
    14 #define VIEW_CORRECTION_SCALE 0.5f 
     12#define AREA_SIZE 7e-1f 
     13//#define AREA_SIZE 3e-1f 
     14#define VIEW_CORRECTION_SCALE 0.3f 
     15//#define VIEW_CORRECTION_SCALE 0.5f 
    1516#define DISTANCE_SCALE 1e-6f 
    1617 
     
    114115        } 
    115116 
    116         return (1.0f - total_ao); 
     117        return max(0.0f, 1.0f - total_ao); 
    117118        //return dot(currentViewDir, currentNormal); 
    118119} 
     
    121122/** Computes ambient occlusion + diffuse reflections 
    122123*/ 
    123 /* 
    124124float4 globIllum(fragment IN, 
    125125                                 uniform sampler2D colors, 
     
    140140        // Summing up these angles gives an estimation of the occlusion at the current position. 
    141141 
    142         float total_ao = 0.0; 
    143         float3 total_color = float3(0.0f); 
     142        // ao is in stored in the w 
     143        float4 total_color = float4(0, 0, 0, 1); 
    144144 
    145145        const float areaSize = 5e-1f; 
     
    153153 
    154154                // rotation 
    155                 float2 offsetTransformed = rotate(offset, mynoise); 
     155                float2 offsetTransformed = reflect(offset, mynoise); 
    156156 
    157157                // weight with projected coordinate to reach similar kernel size for near and far 
     
    159159 
    160160                float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, 1)).xyz; 
    161                 float3 sample_color = tex2D(colors, float4(texcoord, 0, 1)).xyz; 
     161                float3 sample_color = tex2Dlod(colors, float4(texcoord, 0, 1)).xyz; 
    162162 
    163163                float3 vector_to_sample = sample_position - centerPosition.xyz; 
     
    176176                float view_correction = 1.0f + VIEW_CORRECTION_SCALE * (1.0f - dot(currentViewDir, currentNormal)); 
    177177 
    178                 total_ao += cos_angle * distance_intensity * view_correction; 
    179                 float scale_factor = 0.3f; 
    180                 total_color += cos_angle * distance_intensity * view_correction * sample_color * scale_factor; 
    181         } 
    182  
    183         return float4(total_color, 1.0f - total_ao); 
    184 } 
    185 */ 
     178                total_color.w -= cos_angle * distance_intensity * view_correction; 
     179 
     180                const float scale_factor = 0.3f; 
     181                total_color.xyz += cos_angle * distance_intensity * view_correction * sample_color * scale_factor; 
     182        } 
     183 
     184        return saturate(total_color); 
     185} 
     186 
    186187 
    187188/** The mrt shader for screen space ambient occlusion 
     
    208209 
    209210        // expand normal 
    210         float3 normal = normalize(norm.xyz);// * 2.0f - 1.0f); 
     211        float3 normal = normalize(norm.xyz); 
    211212        /// the current view direction 
    212213        float3 viewDir = normalize(IN.view * 2.0f - float3(1.0f)); 
     
    219220        const float currentDepth = currentCol.w; 
    220221 
    221         float4 new_col = (float4)ssao(IN, positions, noiseTexture, samples, normal, viewDir, noiseMultiplier, centerPosition); 
    222         //float4 new_col = globIllum(IN, colors, positions, noiseTexture, samples, normal, viewDir, noiseMultiplier, centerPosition);  
     222        //float4 new_col = (float4)ssao(IN, positions, noiseTexture, samples, normal, viewDir, noiseMultiplier, centerPosition); 
     223        float4 new_col = globIllum(IN, colors, positions, noiseTexture, samples, normal, viewDir, noiseMultiplier, centerPosition);  
    223224         
    224225 
     
    250251        } 
    251252 
    252  
    253         OUT.combined_col = currentCol * OUT.illum_col; 
     253        //const float ao = OUT.illum_col.x; 
     254        const float ao = OUT.illum_col.w; 
     255 
     256        //OUT.combined_col = (currentCol + OUT.illum_col) * ao; 
     257        OUT.combined_col = currentCol * ao; 
    254258 
    255259        OUT.illum_col.w = currentDepth; 
Note: See TracChangeset for help on using the changeset viewer.