Fix bounds antialiasing on text

Previously the gradient was being calculated before taking the boundaries into account, resulting in the edges being too hard or too soft
This commit is contained in:
Andrew Cassidy 2020-09-26 19:39:44 -07:00
parent d705a92b0d
commit eb7bb211ab
No known key found for this signature in database
GPG Key ID: 963017B38FD477A1
2 changed files with 4 additions and 4 deletions

View File

@ -6,7 +6,6 @@ float _OutlineWidth;
void surf(DecalSurfaceInput IN, inout SurfaceOutput o) {
float4 color = _DecalColor;
float dist = _Cutoff - tex2D(_Decal, IN.uv_decal).r; // text distance
float ddist = SDFdDist(dist); // distance gradient magnitude
#ifdef DECAL_OUTLINE
// Outline
@ -16,7 +15,7 @@ void surf(DecalSurfaceInput IN, inout SurfaceOutput o) {
#ifdef DECAL_FILL
// Outline and Fill
float outlineDist = -dist - outlineOffset;
float outlineFactor = SDFAA(outlineDist, ddist);
float outlineFactor = SDFAA(outlineDist);
dist -= outlineOffset;
color = lerp(_DecalColor, _OutlineColor, outlineFactor);
#else
@ -28,6 +27,7 @@ void surf(DecalSurfaceInput IN, inout SurfaceOutput o) {
#endif
dist = max(dist, BoundsDist(IN.uv, IN.vertex_normal, _DecalNormal));
float ddist = SDFdDist(dist); // distance gradient magnitude
o.Alpha = _DecalOpacity * SDFAA(dist, ddist);
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4b9f1df541672d2c5aa8b7900bbba84d7845a72104b08e7be776c65fcf698f8f
size 888707
oid sha256:92429ce733ae3a02250d831b6d1ebbcef733467be87f1ef10604964374d8b6f7
size 890502