Skip to content

Instantly share code, notes, and snippets.

@belzecue
Forked from romainPechot/DualMap.shader
Created June 29, 2018 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save belzecue/fe121a0008fe1c5b25cc0cab09a81b46 to your computer and use it in GitHub Desktop.
Save belzecue/fe121a0008fe1c5b25cc0cab09a81b46 to your computer and use it in GitHub Desktop.
Dual Maps Shader. Use last texture like a filter. Show first texture if pixel transparent, second if pixel is full visible (crossfade if value is inbetween)
Shader "DualMaps"
{
Properties
{
_MainTex("Main (RGB)", 2D) = "black" {}
_SecTex("Main (RGB)", 2D) = "white" {}
_FilTex("Filter (Alpha)", 2D) = "black"{}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _SecTex;
sampler2D _FilTex;
struct Input
{
float2 uv_MainTex;
float2 uv_SecTex;
float2 uv_FilTex;
};
void surf(Input IN, inout SurfaceOutput o)
{
fixed4 main = tex2D(_MainTex, IN.uv_MainTex);
fixed4 sec = tex2D(_SecTex, IN.uv_SecTex);
fixed4 filter = tex2D(_FilTex, IN.uv_FilTex);
o.Albedo = lerp(main.rgb, sec.rgb, filter.a);
o.Alpha = main.a;
}
ENDCG
}
FallBack "Diffuse"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment