Skip to content

Instantly share code, notes, and snippets.

@romainPechot
Last active February 7, 2020 07:55
Show Gist options
  • Save romainPechot/ade3a97fb9112c87da6c to your computer and use it in GitHub Desktop.
Save romainPechot/ade3a97fb9112c87da6c 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"
}
@real-marco-b
Copy link

Perfect! Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment