Advertisement

Shadow lightening close to occluders and light bleeding

Started by May 20, 2021 04:26 PM
4 comments, last by RobM 3 years, 6 months ago

I've been around the houses several times now on implementing shadow maps into my engine. I feel like I've tried practically everything including some hybrid and novel approaches that worked in my head but didn't amount to the right effect when implemented. I've tried (for cascaded shadow maps), PCF, VSM and ESM but I simply cannot get anything looking acceptable. VSMs get close but the lightening of the shadow where the occluder is close to the surface being shadows just drives me crazy. I've spent countless hours trying to darken it whilst not affecting other shadowed areas to no avail. I'm also put off by the light bleeding. No matter how I play with the values in Chebyshev's inequality algorithm, I can't get anything I like.

I've researched til I'm blue in the face and most of the stuff I've read through is from 5-10 years ago. Does anyone know if there are any latest advances that I can try to get an acceptable representation.

Actually I didn't manage to get a good result from ESM (and I haven't tried EVSM) but I can't find any good examples of this online - my maths isn't bad but it's not quite good enough to convert the original papers into code.

Thanks

Some images of your issues would be interesting.

And what have you done for sampling? AFAIK it became pretty standard to use advanced techniques here, like using a precomputed kernel of Poisson samples and rotating it randomly per pixel. Helps a lot with quality but i don't remember resources on this.

Advertisement

Here are some images. The first one looks fine, but you can see the highlighted “peter panning” which I think looks pretty bad. This is currently VSM - I just write out the usual depth, depth * depth and use the ubiquitous Chebyshev inequality algorithm. I use 0.4, 1.0 and 0.0002 for the params. I just do a two-pass gaussian blur on the shadowmap and then read it with bilinear filtering. If I include any other object in the scene which is significantly higher than this one, i.e. to increase the depth of the shadow volume, this shadow gets increasingly lighter which I guess is from precision issues.

When you say a precomputed kernel of Poisson samples, do you mean for PCF?

RobMadison said:
When you say a precomputed kernel of Poisson samples, do you mean for PCF?

Yes. Found one tutorial covering the idea here, but no idea what sample count is needed (surely more than 4) and parctical: http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-16-shadow-mapping/#poisson-sampling

Other than that there would be SS contact hardening to fight peter panning.

But tbh i wonder myself why games show so little artifacts in practice. Probably manual tuning and artist experience​ to design around those limitations.

Poisson samples can be an adaptive sequence, so if calculated with that property, you can take the first N of M samples, and those N are nicely distributed. See here for the idea: http://www.cemyuksel.com/cyCodeBase/soln/poisson_disk_sampling.html

VSM always seemed attractive to me, but there are downsides of requiring to add static background even if we need it only for dynamic models, and those bad artifacts with large depth discontinuities. So PCF with some good sampling strategy might still be the best and most general solution.

Thanks, I’ll have a look at those, I think I’d rather some noise and sacrifice the smooth shading than have incorrect and light bleeding shadows. Based on your link I also noticed PCSS, which to be honest when I was researching I just thought was PCF with a larger kernel but it looks really interesting.

This topic is closed to new replies.

Advertisement