Created
October 4, 2017 06:14
-
-
Save iendsl/a9e9583cb192857a8c8f2f99f8f88326 to your computer and use it in GitHub Desktop.
Shader Used in A Good Gardener
This file contains hidden or 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
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' | |
Shader "Custom/Cutout/ShadowNoLight" { | |
Properties { | |
_Color ("Main Color", Color) = (1,1,1,1) | |
_MainTex ("Base (RGB)", 2D) = "white" {} | |
_Cutoff ("Alpha Cutoff", Float) = 0.5 | |
} | |
SubShader { | |
Tags {"Queue" = "Geometry" "RenderType" = "Transparent"} | |
Pass { | |
Tags {"LightMode" = "ForwardBase"} | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#pragma multi_compile_fwdbase | |
#pragma multi_compile_fwdadd_fullshadows | |
#pragma fragmentoption ARB_fog_exp2 | |
#pragma fragmentoption ARB_precision_hint_fastest | |
//#pragma target 3.0 | |
#include "UnityCG.cginc" | |
#include "AutoLight.cginc" | |
uniform Float _Cutoff; | |
fixed4 _Color; | |
struct v2f | |
{ | |
float4 pos : SV_POSITION; | |
float2 uv : TEXCOORD0; | |
LIGHTING_COORDS(1,2) | |
}; | |
float4 _MainTex_ST; | |
v2f vert (appdata_base v) | |
{ | |
v2f o; | |
o.pos = UnityObjectToClipPos( v.vertex); | |
o.uv = TRANSFORM_TEX (v.texcoord, _MainTex).xy; //v.texcoord.xy; | |
TRANSFER_VERTEX_TO_FRAGMENT(o); | |
return o; | |
} | |
sampler2D _MainTex; | |
fixed4 frag(v2f i) : COLOR | |
{ | |
fixed atten = LIGHT_ATTENUATION(i); // Light attenuation + shadows. | |
//fixed atten = SHADOW_ATTENUATION(i); // Shadows ONLY. | |
float4 textureColor = tex2D(_MainTex, i.uv); | |
if(textureColor.a < _Cutoff) | |
{ | |
discard; | |
} | |
textureColor *= _Color; | |
textureColor *= atten; | |
return textureColor; | |
} | |
ENDCG | |
} | |
} | |
FallBack "Transparent/Cutout/Diffuse" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment