Ignore:
Timestamp:
10/12/08 11:46:50 (16 years ago)
Author:
mattausch
Message:

worked on cg shader wrapper class

File:
1 edited

Legend:

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

    r3024 r3025  
    9191float CalcShadowTerm(fragment IN, 
    9292                                         uniform sampler2D shadowMap, 
    93                                          uniform float w, 
     93                                         uniform float scale, 
    9494                                         uniform float2 lightSpacePos, 
    9595                                         uniform float depth, 
    9696                                         uniform float2 samples[NUM_PCF_TABS], 
     97                                         uniform float weights[NUM_PCF_TABS], 
    9798                                         uniform sampler2D noiseTexture 
    9899                                         ) 
     
    101102        //return step(depth, shadowDepth); 
    102103 
    103         float total_d = 0.0; 
    104          
     104        float total_d = .0f; 
     105        float total_w = .0f; 
     106 
    105107        for (int i = 0; i < NUM_PCF_TABS; ++ i)  
    106108        { 
    107109                const float2 offset = samples[i]; 
     110                const float w = weights[i]; 
    108111 
    109112#if 1 
     
    117120#endif 
    118121                // weight with projected coordinate to reach similar kernel size for near and far 
    119                 float2 texcoord = lightSpacePos + offsetTransformed * w; 
     122                float2 texcoord = lightSpacePos + offsetTransformed * scale; 
    120123 
    121124                float shadowDepth = tex2D(shadowMap, texcoord).x; 
    122125 
    123                 total_d += step(depth, shadowDepth); 
     126                total_d += w * step(depth, shadowDepth); 
     127                total_w += w; 
    124128        } 
    125129 
    126         total_d /= (float)NUM_PCF_TABS; 
     130        total_d /= (float)total_w; 
    127131 
    128132        return total_d; 
    129133} 
     134 
    130135 
    131136inline float3 Interpol(float2 w, float3 bl, float3 br, float3 tl, float3 tr) 
     
    195200 
    196201                float shadowTerm = CalcShadowTerm(IN, shadowMap, sampleWidth, lightSpacePos.xy, lightSpacePos.z, samples, weights, noiseTexture); 
     202                //float shadowTerm = CalcShadowTerm(IN, shadowMap, sampleWidth, lightSpacePos.xy, lightSpacePos.z, samples, noiseTexture); 
    197203 
    198204                diffuse *= shadowTerm; 
Note: See TracChangeset for help on using the changeset viewer.