Jump to content

  • Log In with Google      Sign In   
  • Create Account

VSM severe acne

  • You cannot reply to this topic
No replies to this topic

#1 cifa   Members   -  Reputation: 194


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?



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