Last active
October 7, 2019 13:09
-
-
Save julhe/9c8a93f627aff7eb4d2084d79dd44ff3 to your computer and use it in GitHub Desktop.
shadowacne.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//based on: | |
//http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-16-shadow-mapping/ | |
float biasScale = abs(unity_WorldToShadow[0][2][2]); | |
float NdotL_Sat_sqr = NdotL_Sat * NdotL_Sat; | |
float bias = rsqrt(NdotL_Sat_sqr / (1.0 - NdotL_Sat_sqr)); //suggested by @TastyTexel: https://twitter.com/TastyTexel/status/1180983378394439681?s=20 | |
bias *= biasScale * 0.25; //adjust 0.25 to personal need | |
#if UNITY_REVERSED_Z | |
o._ShadowCoord.z += bias; | |
#else | |
o._ShadowCoord.z -= bias; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment