CarmenSandiego/Assets/Shaders/SDF The Chase.shader
Jamie Greunbaum c11a39d065 - Added markers to show players where to stand during round 2.
- Added a brick material and lined the walls of the alleyway with it.
- Added a concrete walkway to the alleyway.
- Map dots, map borders, and The Chase title are all now anti-aliased.
- Improved the look of the concrete material.
- Wood textures no longer use a transparency render queue.
2026-03-27 04:15:15 -04:00

131 lines
3.6 KiB
Plaintext

// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
// Simplified Diffuse shader. Differences from regular Diffuse one:
// - no Main Color
// - fully supports only 1 directional light. Other lights can affect it, but it will be per-vertex/SH.
Shader "Carmen/SDF/The Chase"
{
Properties
{
_MainTex ("SDF", 2D) = "white" {}
[ShowAsVector2] _Skew ("Skew", Vector) = (0.0, 0.0, 0.0, 0.0)
_LeftColour ("Left Colour", Color) = (1.0, 0.0, 0.0, 1.0)
_RightColour ("Right Colour", Color) = (0.0, 0.0, 1.0, 1.0)
_LeftLineColour ("Left Line Colour", Color) = (0.0, 0.0, 0.0, 1.0)
_RightLineColour ("Right Line Colour", Color) = (0.0, 0.0, 0.0, 1.0)
_LineThickness ("Line Thickness", float) = 0.25
_TextThickness ("Text Thickness", float) = 0.1
}
SubShader
{
Tags { "Queue"="Overlay" "RenderType"="Transparent" "CanUseSpriteAtlas"="True" }
LOD 200
Pass {
Cull Back
Lighting Off
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
//ZTest Always
CGPROGRAM
#include "UnityCG.cginc"
#pragma target 4.5
#pragma vertex vert
#pragma fragment frag
UNITY_DECLARE_TEX2D(_MainTex);
float4 _MainTex_ST;
half4 _Skew;
half4 _LeftColour;
half4 _RightColour;
half4 _LeftLineColour;
half4 _RightLineColour;
half _LineThickness;
half _TextThickness;
struct Data
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct V2F
{
float4 position : SV_POSITION;
float2 uv : TEXCOORD0;
};
V2F vert(Data v)
{
V2F o;
// Skew and scale as needed
float4x4 skewmatrix = float4x4(
1.0, _Skew.x, 0.0, 0.0,
_Skew.y, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
);
o.position = mul(skewmatrix, v.vertex);
o.position = mul(UNITY_MATRIX_P,
mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0))
+ float4(o.position.x, o.position.y, 0.0, 0.0)
* float4(
length(unity_ObjectToWorld._m00_m10_m20),
length(unity_ObjectToWorld._m01_m11_m21),
1.0, 1.0));
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
fixed4 frag(V2F i) : SV_TARGET
{
half sdf_sample = UNITY_SAMPLE_TEX2D(_MainTex, i.uv).r;
half sdf_halfchange = (abs(ddx(sdf_sample)) + abs(ddy(sdf_sample))) / 2.0;
half alphastep_loweredge = (1.0 - _LineThickness) - sdf_halfchange;
half alphastep_upperedge = (1.0 - _LineThickness) + sdf_halfchange;
half alphastep = saturate((sdf_sample - alphastep_loweredge) / (alphastep_upperedge - alphastep_loweredge));
half textstep_loweredge = (1.0 - _TextThickness) - sdf_halfchange;
half textstep_upperedge = (1.0 - _TextThickness) + sdf_halfchange;
half textstep = saturate((sdf_sample - textstep_loweredge) / (textstep_upperedge - textstep_loweredge));
half uvrange = i.uv.x % 1.0;
half3 outline = lerp(_LeftLineColour.rgb, _RightLineColour.rgb, uvrange);
half3 fill = lerp(_LeftColour.rgb, _RightColour.rgb, uvrange);
return fixed4(lerp(outline, fill, textstep).rgb, alphastep);
//half alphastep = step(texsample, _LineThickness);
//if (alphastep < 0.5) discard;
// half linestep = step(texsample, 0.1);
// half uvrange = i.uv.x % 1.0;
// return lerp(
// lerp(_LeftLineColour, _RightLineColour, uvrange),
// lerp(_LeftColour, _RightColour, uvrange),
// linestep);
}
ENDCG
}
}
FallBack "Diffuse"
}