Created
September 28, 2015 15:13
-
-
Save nevarman/cf79794ad2a378d3efef to your computer and use it in GitHub Desktop.
Round fill shader for Unity3D
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 "Custom/Fill-Round" { | |
Properties { | |
_MainTex ("Base (RGB)", 2D) = "white" {} | |
_Color ("Color", Color) = (1,1,1,1) | |
_Center ("Center", Vector) = (0,0,0,0) | |
_FillRate ("FillRate", Range(0.0, 1.0)) = 1.0 | |
} | |
SubShader { | |
Tags { "RenderType"="Opaque" } | |
LOD 100 | |
CGPROGRAM | |
#pragma surface surf Unlit | |
sampler2D _MainTex; | |
float _FillRate; | |
float4 _Center; | |
float4 _Color; | |
struct Input { | |
float2 uv_MainTex; | |
}; | |
half4 LightingUnlit(SurfaceOutput s, half3 lightDir, half atten) | |
{ | |
return half4(s.Albedo/1.35, s.Alpha); | |
} | |
void surf (Input IN, inout SurfaceOutput o) { | |
half2 uv = IN.uv_MainTex.xy; | |
half2 _textCord = uv; | |
float _distance = distance(uv, _Center); | |
if ( _distance <= _FillRate ) | |
{ | |
half4 c = tex2D(_MainTex, _textCord); | |
o.Albedo = c.rgb * _Color; | |
} | |
else | |
{ | |
o.Albedo = _Color; | |
} | |
} | |
ENDCG | |
} | |
FallBack "Diffuse" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment