mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-06-11 05:54:07 +00:00
Fix repeating on text shader and add outline-only support
This commit is contained in:
parent
bb965580db
commit
bd2e0c93bd
|
@ -6,22 +6,32 @@ float _OutlineWidth;
|
|||
|
||||
void surf(DecalSurfaceInput IN, inout SurfaceOutput o) {
|
||||
float4 color = _DecalColor;
|
||||
|
||||
float bias = _Cutoff - (_Weight / 4);
|
||||
#ifdef DECAL_OUTLINE
|
||||
bias -= _OutlineWidth * 0.25;
|
||||
#endif
|
||||
float dist = bias - tex2D(_Decal, IN.uv_decal).r;
|
||||
float ddist = SDFdDist(dist);
|
||||
float dist = bias - tex2D(_Decal, IN.uv_decal).r; // text distance
|
||||
float ddist = SDFdDist(dist); // distance gradient magnitude
|
||||
|
||||
#ifdef DECAL_OUTLINE
|
||||
float outlineDist = (_OutlineWidth * 0.5) + dist;
|
||||
float outline = SDFAA(outlineDist, -ddist);
|
||||
color = lerp(color, _OutlineColor, outline);
|
||||
// Outline
|
||||
float outlineOffset = _OutlineWidth * 0.25;
|
||||
float outlineRadius = _OutlineWidth * 0.5;
|
||||
|
||||
#ifdef DECAL_FILL
|
||||
// Outline and Fill
|
||||
float outlineDist = -dist - outlineOffset;
|
||||
float outlineFactor = SDFAA(outlineDist, ddist);
|
||||
dist -= outlineOffset;
|
||||
color = lerp(_DecalColor, _OutlineColor, outlineFactor);
|
||||
#else
|
||||
// Outline Only
|
||||
float outlineDist = abs(dist) - outlineOffset;
|
||||
dist = outlineDist;
|
||||
color = _OutlineColor;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
||||
dist = max(dist, BoundsDist(IN.uv, IN.vertex_normal, _DecalNormal));
|
||||
o.Alpha = _DecalOpacity * SDFAA(dist, ddist);
|
||||
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
||||
|
||||
#ifdef DECAL_BASE_NORMAL
|
||||
float3 normal = IN.normal;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
Properties
|
||||
{
|
||||
[Header(Decal)]
|
||||
[Toggle(DECAL_FILL)] _Fill ("Fill", int) = 0
|
||||
_Decal("Decal Texture", 2D) = "gray" {}
|
||||
_DecalColor("Decal Color", Color) = (1,1,1,1)
|
||||
|
||||
|
@ -64,6 +65,7 @@
|
|||
#pragma multi_compile_local __ DECAL_BASE_NORMAL
|
||||
#pragma multi_compile_local __ DECAL_SPECMAP
|
||||
#pragma multi_compile_local __ DECAL_OUTLINE
|
||||
#pragma multi_compile_local __ DECAL_FILL
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "DecalsCommon.cginc"
|
||||
|
@ -93,6 +95,7 @@
|
|||
#pragma multi_compile_local __ DECAL_BASE_NORMAL
|
||||
#pragma multi_compile_local __ DECAL_SPECMAP
|
||||
#pragma multi_compile_local __ DECAL_OUTLINE
|
||||
#pragma multi_compile_local __ DECAL_FILL
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "DecalsCommon.cginc"
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:896ba723c5fdcc40b2432099d76081a1f808e6876a6dd4f8e88c0c9d59143082
|
||||
size 732519
|
||||
oid sha256:85fe782b12791cf0ec4a1626bdb246dc1875477fd6328e3c313a2cb5488935ec
|
||||
size 892252
|
||||
|
|
Loading…
Reference in New Issue
Block a user