Slope scaled depth bias for shadows?

Is there still the problem with shadows on surfaces near-parallel to the direction, like this?:

http://i.imgur.com/7aJcD.png

I think it was called “shadow acne”? I think I installed the nightly build, and it seemed like it was still not fully solved. I use a custom shader, but I copy-pasted the shadow techniques from the latest lighting.j3md and slightly modified the variable names for my shader.

Assuming that the problem is present:

I’m assuming that the PolyOffset is supposed to partly fix this problem. Without it (or changing it to 0 0 from 5 0), you would get this:

http://i.imgur.com/LukJG.png

With an adjusted PolyOffset, you would get something like the first image, which is much better except it still has problems for certain surfaces.

I read a little on shadows (particularly mapping), and I found a thing called “slope scaled depth bias”, which I guess changes the offset depending on the slope from light perspective. This and this briefly mentions it. I’m guessing this is better than the one static PolyOffset way.

I would like to know how to do this for the JME shadows, but I thought other people, especially the person who made them (@nehon?), would know how to do this the most.

I think it’s highly likely that @nehon would already know about slope scaled depth bias and just hasn’t done it yet or something, but throwing it out there just in case.

From what I gathered from my readings, slope scale depth bias is exactly the same as polyoffset.

Polyoffset only exists for opengl, all articles you found about slope scale depth bias are for Directx that lacks the polyoffset feature.



If you want to fix the first picture artifact you’ll have to look into pixel accurate shadow filtering, or temporal reprojection.



A way to make it less noticeable, with current implementation, is to have high frequency textures (no plain color as in you screen shot).

This thread might interest you too:

http://hub.jmonkeyengine.org/groups/user-code-projects/forum/topic/new-landscape-shadow-system

@nehon said:
From what I gathered from my readings, slope scale depth bias is exactly the same as polyoffset.
Polyoffset only exists for opengl, all articles you found about slope scale depth bias are for Directx that lacks the polyoffset feature.

If you want to fix the first picture artifact you'll have to look into pixel accurate shadow filtering, or temporal reprojection.

A way to make it less noticeable, with current implementation, is to have high frequency textures (no plain color as in you screen shot).

I looked around more, and I think you're right about PolyOffset being the same. There were some sites saying something like this, and I also added this to the preshadow.frag with PolyOffset 0 0:
[java]
float dx = dFdx(gl_FragCoord.z);
float dy = dFdy(gl_FragCoord.z);
gl_FragDepth = gl_FragCoord.z + sqrt( dx*dx + dy*dy );
[/java]
which I found on some other site, which produced:
http://imgur.com/sKLiO
Still has artifacts.
At first I thought they were different things since the first link I mentioned had this slide:
http://imgur.com/dUp2h
To me, it sounded like the two bullets were two different methods with different pros/cons.
Ignoring edge filtering, now it seems like the solution is to adjust PolyOffset to the best numbers.