Created
November 27, 2020 14:18
-
-
Save findstr/671bb5368a6122b36d10675a5539b5c4 to your computer and use it in GitHub Desktop.
WorldMap
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
Shader "WorldMap/Hightlight" | |
{ | |
Properties | |
{ | |
_MainTex ("Texture", 2D) = "white" {} | |
_Color("Color", Color) = (0,1,0) | |
_Scale("Scale", Float) = 1 | |
_Brightness("Brightness", Float) = 1 | |
} | |
SubShader | |
{ | |
Tags { "Queue"="Transparent" "LightMode" = "ForwardBase"} | |
Blend SrcAlpha OneMinusSrcAlpha | |
ZWrite Off | |
Pass | |
{ | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#include "UnityCG.cginc" | |
sampler2D _MainTex; | |
float4 _MainTex_ST; | |
float3 _Color; | |
float _Scale; | |
float _Brightness; | |
struct a2v { | |
float4 vertex: POSITION; | |
float2 tex1: TEXCOORD1; | |
}; | |
struct v2f { | |
float4 pos: SV_POSITION; | |
float2 uv: TEXCOORD0; | |
}; | |
v2f vert(a2v v) { | |
v2f o; | |
o.pos = UnityObjectToClipPos(v.vertex); | |
o.uv.xy = TRANSFORM_TEX(v.tex1, _MainTex); | |
return o; | |
} | |
fixed4 frag(v2f i) : SV_Target { | |
fixed3 color; | |
fixed3 liuming = fixed3(0.299, 0.587, 0.114); | |
fixed4 albedo = tex2D(_MainTex, i.uv); | |
fixed3 base = albedo.xyz * 255; | |
fixed3 blend = _Scale * _Color * 255; | |
fixed gray = dot(albedo.rgb, liuming); | |
fixed3 one = fixed3(255, 255, 255); | |
if (gray < 0.5) | |
color = base * blend / 128; | |
else | |
color = one - (one - base) * (one - blend) / 128; | |
return fixed4(color / 255 * _Brightness, albedo.a); | |
} | |
ENDCG | |
} | |
} | |
Fallback off | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment