Skip to content

Instantly share code, notes, and snippets.

@increpare
Created April 13, 2015 12:35
Show Gist options
  • Save increpare/53619afa60bc4ed7da8a to your computer and use it in GitHub Desktop.
Save increpare/53619afa60bc4ed7da8a to your computer and use it in GitHub Desktop.
// simple "dissolving" shader by genericuser (radware.wordpress.com)
// clips materials, using an image as guidance.
// use clouds or random noise as the slice guide for best results.
//@increpare with separate color and lighting disabled
Shader "Custom/Dissolve" {
Properties {
_MainTex ("Texture (RGB)", 2D) = "white" {}
_SliceGuide ("Slice Guide (RGB)", 2D) = "white" {}
_SliceAmount ("Slice Amount", Range(0.0, 1.0)) = 0.5
_Color ("Main Color", Color) = (1,.5,.5,1)
}
SubShader {
Tags { "RenderType" = "Opaque" }
Cull Off
Lighting Off
CGPROGRAM
//if you're not planning on using shadows, remove "addshadow" for better performance
#pragma surface surf Lambert addshadow
struct Input {
float2 uv_MainTex;
float2 uv_SliceGuide;
float _SliceAmount;
};
sampler2D _MainTex;
sampler2D _SliceGuide;
float _SliceAmount;
float4 _Color;
void surf (Input IN, inout SurfaceOutput o) {
clip(tex2D (_SliceGuide, IN.uv_SliceGuide).rgb - _SliceAmount);
o.Emission = tex2D (_MainTex, IN.uv_MainTex).rgb*_Color;
}
ENDCG
}
Fallback "Diffuse"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment