• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# VSM severe acne

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.

No replies to this topic

### #1cifa  Members

Posted 28 June 2014 - 04:51 AM

********** EDIT: I've found a bug in the CPU side that wasn't my fault, I'm investigating and then update the topic, for now the following description is not valid anymore, if mods want to  close the topic it's fine to me ****************

I'm implementing a VSM algorithm. My code is pretty much like everything is online.

//coords is after the w divide and 0.5 + 0.5* corrections
float VSM(vec3 coords, float dist){

vec2 moments = texture(shadowTexture, coords.xy).rg;

if(dist <= moments.x) return 1.0;
float variance = moments.y - (moments.x*moments.x);
variance = max(variance, 0.001);

float d = (dist) - moments.x;
float P_max = variance / (variance + d*d);

return pMax;
}


Here if I use a small value to clamp the variance as done in almost every source I found the result is a terrible acne:

If I start increasing the max value for the variance the acne diminish, although still evident. Also the proper shadow is definitely lighten (too much)

Eventually if I keep increasing such value the proper shadow disappear. Moreover the value to produce this image above is 6.0! Way higher than everything I saw around.

Similarly I've tried something like:

	float d = (dist + bias) - moments.x;


but I found no value that solve the problem, although not tried that many.

The depth map is I think fine because with PCF I get a good result.

What can be the issue here?

Thanks!

Edited by cifa, 28 June 2014 - 06:03 AM.

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.