-
-
Save jimfleming/ad643ef3aca7d0e8a743 to your computer and use it in GitHub Desktop.
Simple diffuse/dissolve shader.
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/DiffuseDissolve" { | |
Properties { | |
_DissolveTime ("Dissolve Time", Range (-1, 1)) = -1 | |
_DissolveGuide ("Dissolve Guide (RGB)", 2D) = "white" {} | |
_MainTex ("Texture 1", 2D) = "white" {} | |
_Texture2 ("Texture 2", 2D) = "black" {} | |
} | |
SubShader { | |
Tags { | |
"RenderType" = "Opaque" | |
} | |
LOD 200 // equiv: Diffuse | |
CGPROGRAM | |
#pragma surface surf Lambert addshadow dualforward | |
struct Input { | |
float2 uv_MainTex; | |
float2 uv_DissolveGuide; | |
}; | |
// NOTE: Using _MainTex so the property names line up in fallback case | |
sampler2D _MainTex; | |
sampler2D _Texture2; | |
sampler2D _DissolveGuide; | |
float _DissolveTime; | |
void surf(Input IN, inout SurfaceOutput o) { | |
fixed3 _MainTexColor = tex2D(_MainTex, IN.uv_MainTex).rgb; | |
fixed3 _Texture2Color = tex2D(_Texture2, IN.uv_MainTex).rgb; | |
fixed _DissolveAmount = tex2D(_DissolveGuide, IN.uv_MainTex).a; | |
float _DissolveAmountByTime = clamp(_DissolveAmount + _DissolveTime, 0, 1); | |
o.Albedo = lerp(_MainTexColor, _Texture2Color, _DissolveAmountByTime); | |
} | |
ENDCG | |
} | |
FallBack "Diffuse" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment