Jump to content

  • Log In with Google      Sign In   
  • Create Account


Jittered Soft Shadows


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 gboxentertainment   Members   -  Reputation: 766

Like
3Likes
Like

Posted 31 August 2013 - 03:55 AM

I've been able to implement a fast approximated soft shadows algorithm into my engine by using a noise texture for jittered sampling and then a screen-space gaussian blur rendered into a quad. I then render this into my forward renderer by sampling using gl_FragCoord.xy/vec2(screenwidth,screenheight):

 

giboxshadows0.jpg

 

Looks plausible at first, but there are some artifacts which occur - such as light bleeding at intersecting edges:

 

giboxshadows1.jpg

 

There's also the light bleeding at the edges caused by the gaussian blurring of the screen-space shadow texture:

 

giboxshadows2.jpg

 

I have tried addressing the second issue by using edge detection to prevent gaussian blurring of the edges, which had very little effect.

 

The only idea I can think of for resolving the first issue is to use ambient occlusion. I wonder if there is a faster alternative?

 

Is there a way of rendering a shadowmap that fades after a certain distance away from the occluder? Maybe I can use this to hide the artifacts?



Sponsor:

#2 Hodgman   Moderators   -  Reputation: 28476

Like
0Likes
Like

Posted 31 August 2013 - 08:27 AM

Regarding the first issue, do you know what the cause is? Is it taking samples that are 'inside' some solid geo?
When you render you depth maps, do you draw back or front faces.

Regarding the second issue, this should definitely be fixable. "Bilateral blurring" is very common for smoothing out noisy shadow data. IIRC I've done this in the past by measuring the difference in screen depth between the central sample and the each blur sample, then weighting the samples by 1/depth_diff.
How do you implement the 'edge detection'?

#3 gboxentertainment   Members   -  Reputation: 766

Like
1Likes
Like

Posted 31 August 2013 - 10:22 AM

Thanks for the reply.

Actually, I managed to solve the second problem by using a laplacian filter to get the edges in screen-space (based on a different value assigned to each object in model space):

 

giboxshadows3-1.jpg giboxshadows3-2.jpg

 

Then I apply a gaussian blur in screen-space to only the values in the edge texture that are zero, so edges of objects do not get blurred:

 

giboxshadows3-3.jpg giboxshadows3-4.jpg

 

However, I've still got the first problem, which can't seemed to be resolved with a simple edge method.

 

 

Regarding the first issue, do you know what the cause is? Is it taking samples that are 'inside' some solid geo?
When you render you depth maps, do you draw back or front faces.

 

 

I cull the front faces - not doing this resolves the leaking problem but then leads to overshadowing in the wrong areas:

 

giboxshadows4.jpg

 

The cause must be something to do with the jittering, but im not sure why it causes light leaking only when objects intersect.



#4 gboxentertainment   Members   -  Reputation: 766

Like
1Likes
Like

Posted 31 August 2013 - 10:56 PM

Okay, so I've figured out that the light leaking when objects intersect is because when I cull the front faces when rendering the depth map, the intersecting face no longer becomes visible when it intersects - thus leading to that part not being occluded.

 

 

If I don't cull the front faces, shadow acne occurs. For a non-jittered shadowmap, adding a depth bias eliminates it, but it doesn't work well for a jittered shadow.


Edited by gboxentertainment, 31 August 2013 - 11:09 PM.





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