Created
October 25, 2017 07:20
-
-
Save MohammedAlsayedOmar/604827683b6e1b20627b9e8ae2b87e19 to your computer and use it in GitHub Desktop.
5 Materials Dissolve Shader - Unity
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
//Reference: http://halisavakis.com/my-take-on-shaders-dissolve-shader/ | |
//Special Thanks to Jack Raymond (https://www.facebook.com/john.raymond.125) | |
Shader "Custom/Dissolve" { | |
Properties{ | |
_Color("Color", Color) = (1,1,1,1) | |
_MainTex1("Albedo (RGB)", 2D) = "white" {} | |
_SliceGuide1("Slice Guide (RGB)", 2D) = "white" {} | |
_SliceAmount1("Slice Amount", Range(0.0, 1.0)) = 0 | |
_MainTex2("Albedo 2 (RGB)", 2D) = "white" {} | |
_SliceGuide2("Slice Guide 2 (RGB)", 2D) = "white" {} | |
_SliceAmount2("Slice Amount 2", Range(0.0, 1.0)) = 0 | |
_MainTex3("Albedo 3 (RGB)", 2D) = "white" {} | |
_SliceGuide3("Slice Guide 3 (RGB)", 2D) = "white" {} | |
_SliceAmount3("Slice Amount 3", Range(0.0, 1.0)) = 0 | |
_MainTex4("Albedo 4 (RGB)", 2D) = "white" {} | |
_SliceGuide4("Slice Guide 4 (RGB)", 2D) = "white" {} | |
_SliceAmount4("Slice Amount 4", Range(0.0, 1.0)) = 0 | |
_MainTex5("Albedo 5 (RGB)", 2D) = "white" {} | |
_SliceGuide5("Slice Guide 5 (RGB)", 2D) = "white" {} | |
_SliceAmount5("Slice Amount 5", Range(0.0, 1.0)) = 0 | |
} | |
SubShader{ | |
Tags{ "RenderType" = "Opaque" } | |
LOD 200 | |
Cull Off | |
CGPROGRAM | |
#pragma surface surf Lambert addshadow | |
#pragma target 3.5 | |
fixed4 _Color; | |
sampler2D _MainTex1; | |
sampler2D _SliceGuide1; | |
float _SliceAmount1; | |
sampler2D _MainTex2; | |
sampler2D _SliceGuide2; | |
float _SliceAmount2; | |
sampler2D _MainTex3; | |
sampler2D _SliceGuide3; | |
float _SliceAmount3; | |
sampler2D _MainTex4; | |
sampler2D _SliceGuide4; | |
float _SliceAmount4; | |
sampler2D _MainTex5; | |
sampler2D _SliceGuide5; | |
float _SliceAmount5; | |
struct Input { | |
float2 uv_MainTex1; | |
float2 uv_MainTex2; | |
float2 uv_MainTex3; | |
float2 uv_MainTex4; | |
float2 uv_MainTex5; | |
INTERNAL_DATA | |
float3 viewDir; | |
}; | |
void surf(Input IN, inout SurfaceOutput o) { | |
half mask1 = 1 - round((tex2D(_SliceGuide1, IN.uv_MainTex1).rgb - _SliceAmount1 + 0.5)); | |
fixed4 col1 = tex2D(_MainTex1, IN.uv_MainTex1) * mask1; | |
half mask2 = 1 - round((tex2D(_SliceGuide2, IN.uv_MainTex2).rgb - _SliceAmount2 + 0.5)); | |
fixed4 col2 = tex2D(_MainTex2, IN.uv_MainTex2) * mask2 + col1 * (1 - mask2); | |
half mask3 = 1 - round((tex2D(_SliceGuide3, IN.uv_MainTex3).rgb - _SliceAmount3 + 0.5)); | |
fixed4 col3 = tex2D(_MainTex3, IN.uv_MainTex3) * mask3 + col2 * (1 - mask3); | |
half mask4 = 1 - round((tex2D(_SliceGuide4, IN.uv_MainTex4).rgb - _SliceAmount4 + 0.5)); | |
fixed4 col4 = tex2D(_MainTex4, IN.uv_MainTex4) * mask4 + col3 * (1 - mask4); | |
half mask5 = 1 - round((tex2D(_SliceGuide5, IN.uv_MainTex5).rgb - _SliceAmount5 + 0.5)); | |
fixed4 col5 = tex2D(_MainTex5, IN.uv_MainTex5) * mask5; | |
fixed4 c = (col5 * mask5 + col4 * (1 - mask5)) * _Color; | |
o.Albedo = c.rgb; | |
o.Alpha = c.a; | |
} | |
ENDCG | |
} | |
FallBack "Diffuse" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment