mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Fix repeating on text shader and add outline-only support
This commit is contained in:
parent
7ec4c85e8c
commit
53f8e74836
@ -6,22 +6,32 @@ float _OutlineWidth;
|
|||||||
|
|
||||||
void surf(DecalSurfaceInput IN, inout SurfaceOutput o) {
|
void surf(DecalSurfaceInput IN, inout SurfaceOutput o) {
|
||||||
float4 color = _DecalColor;
|
float4 color = _DecalColor;
|
||||||
|
|
||||||
float bias = _Cutoff - (_Weight / 4);
|
float bias = _Cutoff - (_Weight / 4);
|
||||||
#ifdef DECAL_OUTLINE
|
float dist = bias - tex2D(_Decal, IN.uv_decal).r; // text distance
|
||||||
bias -= _OutlineWidth * 0.25;
|
float ddist = SDFdDist(dist); // distance gradient magnitude
|
||||||
#endif
|
|
||||||
float dist = bias - tex2D(_Decal, IN.uv_decal).r;
|
|
||||||
float ddist = SDFdDist(dist);
|
|
||||||
|
|
||||||
#ifdef DECAL_OUTLINE
|
#ifdef DECAL_OUTLINE
|
||||||
float outlineDist = (_OutlineWidth * 0.5) + dist;
|
// Outline
|
||||||
float outline = SDFAA(outlineDist, -ddist);
|
float outlineOffset = _OutlineWidth * 0.25;
|
||||||
color = lerp(color, _OutlineColor, outline);
|
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
|
#endif
|
||||||
|
|
||||||
|
dist = max(dist, BoundsDist(IN.uv, IN.vertex_normal, _DecalNormal));
|
||||||
|
o.Alpha = _DecalOpacity * SDFAA(dist, ddist);
|
||||||
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
||||||
o.Alpha = _DecalOpacity * SDFAA(dist, ddist);
|
|
||||||
|
|
||||||
#ifdef DECAL_BASE_NORMAL
|
#ifdef DECAL_BASE_NORMAL
|
||||||
float3 normal = IN.normal;
|
float3 normal = IN.normal;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
Properties
|
Properties
|
||||||
{
|
{
|
||||||
[Header(Decal)]
|
[Header(Decal)]
|
||||||
|
[Toggle(DECAL_FILL)] _Fill ("Fill", int) = 0
|
||||||
_Decal("Decal Texture", 2D) = "gray" {}
|
_Decal("Decal Texture", 2D) = "gray" {}
|
||||||
_DecalColor("Decal Color", Color) = (1,1,1,1)
|
_DecalColor("Decal Color", Color) = (1,1,1,1)
|
||||||
|
|
||||||
@ -64,6 +65,7 @@
|
|||||||
#pragma multi_compile_local __ DECAL_BASE_NORMAL
|
#pragma multi_compile_local __ DECAL_BASE_NORMAL
|
||||||
#pragma multi_compile_local __ DECAL_SPECMAP
|
#pragma multi_compile_local __ DECAL_SPECMAP
|
||||||
#pragma multi_compile_local __ DECAL_OUTLINE
|
#pragma multi_compile_local __ DECAL_OUTLINE
|
||||||
|
#pragma multi_compile_local __ DECAL_FILL
|
||||||
|
|
||||||
#include "UnityCG.cginc"
|
#include "UnityCG.cginc"
|
||||||
#include "DecalsCommon.cginc"
|
#include "DecalsCommon.cginc"
|
||||||
@ -93,6 +95,7 @@
|
|||||||
#pragma multi_compile_local __ DECAL_BASE_NORMAL
|
#pragma multi_compile_local __ DECAL_BASE_NORMAL
|
||||||
#pragma multi_compile_local __ DECAL_SPECMAP
|
#pragma multi_compile_local __ DECAL_SPECMAP
|
||||||
#pragma multi_compile_local __ DECAL_OUTLINE
|
#pragma multi_compile_local __ DECAL_OUTLINE
|
||||||
|
#pragma multi_compile_local __ DECAL_FILL
|
||||||
|
|
||||||
#include "UnityCG.cginc"
|
#include "UnityCG.cginc"
|
||||||
#include "DecalsCommon.cginc"
|
#include "DecalsCommon.cginc"
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user