Solved, forgot to attach a depth texture (since PCF i used only a depth and i was too quick when changing to VSM with RG32F )
Sorry for pointless post…
Hello, i have a depth error when i calculate the shadow texture coordinates only when trying VSM.
I am moving from PCF shadowing which worked great, i can also quickly do a test and change the sampler from sampler2D
to sampler2DShadow (skipping the 2 moments) just to verify that the shadow map is correct.
The shadow acne in screenshot is on purpose to illustrate, the non acne elimates the shadow completely
[ATTACH=CONFIG]1123[/ATTACH]
shader in summary
Shader used to store shadow map
basic variant:
moment1 = gl_FragCoord.z;
moment2 = moment1 * moment1;
vFragColor = vec2(moment1,moment2);
I have also tried…
GPU Gems 3 sample:
vec3 pos = clipSpacePos.xyz/clipSpacePos.w;
//add some offset to remove the shadow acne
// pos.z += 0.001; ( i want acne for the test!)
//get depth in 0 to 1 range
float depth = (pos.z +1)*0.5;
//store the depth as first moment
float moment1 = depth;
//from chap 8 - GPU Gems 3
float dx = dFdx(depth);
float dy = dFdy(depth);
float moment2 = depth*depth + 0.25*(dx*dx + dy*dy);
//store the first and second moment in the red and green channel of the output colour
vFragColor = vec2(moment1,moment2);
Light shader stage:
vec4 shadowCoord = shadowSpotView * vec4(fragment.ws_coord,1);
shadowCoord.xyz /= shadowCoord.w;
shadowCoord.xyz = shadowCoord.xyz * vec3 (0.5f) + vec3 (0.5f);
if ( texture( ShadowMapSpot, shadowCoord.xy ).x < shadowCoord.z) {
visible = 0.0f;
}
// Yes i skipped the actual VSM on purpose!
Quick code sample on the c++ side
shadowSpotView = (shadow.projection * shadow.view) * rb->cameraEntity()->inverseView();
As i mentioned in the shader code, i want to render the shadow acne as its a good demonstrate of what happens!
I have also written a quick forward renderer for a test and have zero issues there…
Any input is greatly appreciated