Jump to content

  • Log In with Google      Sign In   
  • Create Account


soft shadows problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 michaelmk86   Members   -  Reputation: 189

Like
0Likes
Like

Posted 21 March 2013 - 04:25 AM


Hi,
I am trying to implement the Brute-Force Implementation ( as described here http://http.developer.nvidia.com/GPUGems/gpugems_ch11.html) but the shadows do not display correctly (wrong place, orientation), although the shadows appear to look with antialiasing.

 

the code

 float3 offset_lookup(sampler map, float4 loc, float2 offset){
        float2 texmapscale = float2(1/xResolution.x, 1/xResolution.y);
        return tex2Dproj(map, float4(loc.xy + offset * texmapscale * loc.w, loc.z, loc.w));
 }

 float ShadowedArea(int subFrustum, float diffuseLightingFactor, float distanceFromCamera, SSceneVertexToPixel PSIn)
 {
        float depthStoredInShadowMap;
        float sum = 0;
        float x, y;

        for (y = -1.5; y <= 1.5; y += 1.0)
            for (x = -1.5; x <= 1.5; x += 1.0)
                sum += offset_lookup(xShadowMapSubFrustum0_Sampler, PSIn.Pos2DAsSeenByLight[subFrustum], float2(x, y));
        depthStoredInShadowMap = sum / 16.0;
        
        float realDistance = PSIn.Pos2DAsSeenByLight[subFrustum].z/xMaxDepth[subFrustum];

        if((realDistance - 1.0f/100.0f) <= depthStoredInShadowMap){
            //light can see
        }else{
            if(dot(PSIn.Normal, xLightDirection) >= 0){
                //covered by object, and light can't see
                float shadowFade = ShadowFade(diffuseLightingFactor, distanceFromCamera);
                if(shadowFade < diffuseLightingFactor)
                    diffuseLightingFactor = shadowFade;
            }else{
                //not facing the light, and light can't see
                diffuseLightingFactor = 0;
            }
        }
    return diffuseLightingFactor;
 }

 

when I reverse the sign to the loc.y, and divide the (loc.xy + offset * texmapscale * loc.w) with /2.0 + 0.5 the shadows display correctly, but with not antialiasing for some reason(they look pixelated, the same way they were before the soft shadows implementation)

 float3 offset_lookup(sampler map, float4 loc, float2 offset){
        float2 texmapscale = float2(1/xResolution.x, 1/xResolution.y);
        loc.y = -loc.y; 
        return tex2Dproj(map, float4((loc.xy + offset * texmapscale * loc.w)/2.0 + 0.5, loc.z, loc.w));
 }

 


Edited by michaelmk86, 24 March 2013 - 03:40 PM.


Sponsor:

#2 Tournicoti   Prime Members   -  Reputation: 683

Like
0Likes
Like

Posted 22 March 2013 - 01:28 AM

Sorry, I misread your code


Edited by Tournicoti, 22 March 2013 - 01:36 AM.


#3 michaelmk86   Members   -  Reputation: 189

Like
0Likes
Like

Posted 24 March 2013 - 03:42 PM

"original post update"



#4 michaelmk86   Members   -  Reputation: 189

Like
0Likes
Like

Posted 01 April 2013 - 06:22 AM

bump






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS