Ignore:
Timestamp:
09/02/08 00:56:48 (16 years ago)
Author:
mattausch
Message:

shadowing partly working

File:
1 edited

Legend:

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

    r2892 r2893  
    8080                                  uniform sampler2D normals,                
    8181                                  uniform sampler2D shadowMap, 
    82                                   uniform float4x4 shadowMatrix 
     82                                  uniform float4x4 shadowMatrix, 
     83                                  uniform float maxDepth 
    8384                                  ) 
    8485{ 
     
    8990        float4 position = tex2D(positions, IN.texCoord.xy); 
    9091 
    91         float4 lightSpacePos = mul(shadowMatrix, position); 
    92  
    93         float shadowDepth = tex2D(shadowMap, IN.texCoord.xy); 
    9492 
    9593        // an ambient color term 
     
    9997        float4 col = shade(IN, color, position, normal, amb); 
    10098         
     99        position *= maxDepth; 
     100        position.w = 1.0f; 
     101         
     102        float4 lightSpacePos = mul(shadowMatrix, position); 
     103 
     104        float shadowDepth = tex2D(shadowMap, lightSpacePos.xy); 
     105 
    101106        OUT.color = col; 
    102107         
    103         if (lightSpacePos.z / lightSpacePos.w < shadowDepth) 
     108        // hack: prevent shadowing the sky 
     109        if ((amb < 0.9) &&       
     110                (lightSpacePos.z / lightSpacePos.w > shadowDepth)) 
    104111        { 
    105112                OUT.color *= 0.1f; 
    106113        } 
    107114         
    108         //OUT.color = float4(lightSpacePos.z / lightSpacePos.w); 
     115        //OUT.color = lightSpacePos;//float4(lightSpacePos.z / lightSpacePos.w); 
    109116        //OUT.color = float4(shadowDepth); 
    110117        OUT.color.w = color.w; 
Note: See TracChangeset for help on using the changeset viewer.