Ignore:
Timestamp:
07/07/08 18:41:45 (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/deferred.cg

    r2820 r2821  
    11#define NUM_SAMPLES 8 
    2 #define SAMPLE_INTENSITY 0.6 
     2#define SAMPLE_INTENSITY 0.5f 
     3//#define SAMPLE_INTENSITY 0.2f 
    34#define AREA_SIZE 3e-1f 
     5 
    46// kustls magic sample positions 
    57/*static const float2 samples[NUM_SAMPLES] = 
     
    5759 
    5860 
     61float2 rotate(float2 pt, float2 n) 
     62{ 
     63  float2 ptTransformed; 
     64  ptTransformed.x = n.r * pt.x - n.g * pt.y; 
     65  ptTransformed.y = n.g * pt.x + n.r * pt.y; 
     66 
     67  return ptTransformed; 
     68} 
     69 
     70 
    5971//based on kustls shader         
    6072float ssao(fragment IN, 
     
    88100     
    89101    //sample noisetex; r stores costheta, g stores sintheta 
    90     float3 noise = tex2D(noiseTexture, IN.texCoord.xy).xyz * 2.0f - 1.0f; 
     102    float2 noise = tex2D(noiseTexture, IN.texCoord.xy).xy * 2.0f - 1.0f; 
    91103         
    92104    // rotation 
    93105    //float2 offsetTransformed = offset; 
    94     float2 offsetTransformed; 
    95     offsetTransformed.x = noise.r * offset.x - noise.g * offset.y; 
    96     offsetTransformed.y = noise.g * offset.x + noise.r * offset.y; 
     106    float2 offsetTransformed = rotate(offset, noise); 
     107    //float2 offsetTransformed = reflect(offset, noise); 
     108 
     109    //offsetTransformed.x = noise.r * offset.x - noise.g * offset.y; 
     110    //offsetTransformed.y = noise.g * offset.x + noise.r * offset.y; 
    97111                 
    98112    // weight with projected coordinate to reach similar kernel size for near and far 
     
    114128 
    115129    float distance_intensity = maxdist - length_to_sample; 
     130    distance_intensity = max(distance_intensity, 0.0f); 
     131    // quadratic influence 
    116132    distance_intensity *= distance_intensity; 
    117     distance_intensity = max(distance_intensity, 0.0f); 
    118133     
    119134    total_ao += cos_angle * SAMPLE_INTENSITY * distance_intensity; 
     
    155170 
    156171 
     172pixel main_ssao(fragment IN,  
     173               uniform sampler2D colors, 
     174               uniform sampler2D positions, 
     175               uniform sampler2D normals, 
     176               uniform sampler2D noiseTexture, 
     177               uniform float2 samples[NUM_SAMPLES]) 
     178{ 
     179  pixel OUT; 
     180 
     181  float4 col = shade(IN, colors, positions, normals); 
     182  float ao = ssao(IN, positions, normals, noiseTexture, samples); 
     183   
     184  //OUT.color = tex2D(positions, IN.texCoord.xy); 
     185  //OUT.color = ao; 
     186  //OUT.color =  col; 
     187  OUT.color = ao * col; 
     188 
     189  return OUT; 
     190} 
     191 
     192 
    157193pixel main(fragment IN,  
    158194           uniform sampler2D colors, 
    159195           uniform sampler2D positions, 
    160            uniform sampler2D normals, 
    161            uniform sampler2D noiseTexture, 
    162            uniform float2 samples[NUM_SAMPLES]) 
     196           uniform sampler2D normals) 
    163197{ 
    164198  pixel OUT; 
    165199 
    166   float4 col = Shade(IN, positions, normals); 
    167   float ao = ssao(IN, positions, normals, noiseTexture, samples); 
    168   //float ao = 1.0f; 
    169   OUT.color = ao * col;  
    170   //OUT.color = ao * (ambient + diffuse) * color; 
    171   //OUT.color = (ambient + diffuse) * color; 
    172        
     200  float4 col = shade(IN, colors, positions, normals); 
     201  OUT.color = col; 
     202 
    173203  return OUT; 
    174204} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r2819 r2821  
    5656   OUT.position = mul(ModelViewProj, OUT.worldPos); 
    5757 
    58    OUT.worldPos = IN.position; 
    59  
    6058   OUT.normal = IN.normal; 
    6159 
    6260   return OUT; 
    6361} 
    64  
    65 /*struct Material 
    66 { 
    67   float4 diffuse; 
    68 }*/ 
    6962 
    7063 
Note: See TracChangeset for help on using the changeset viewer.