Greetings, people. I’m beginner in making shaders, so I can’t manage with one thing at the moment. The deal is about realization some extraordinary texture transition effect, kinda in attached animation. I’d like to have two different textures using in a shader, then one texture starts appearing in random pixels which, in a turn, combining in growing areas and without any blend effects, just appears at once by zones. This is a snag for me, I would be glad of any help, please forward me on the way. Thank you in advance.
I don’t think this can be done completely randomly, but you can certainly do it with a texture guide. If the average of the Guide texture’s RGB values for a pixel are above the threshold, that pixel will sample the colour of the detail texture. Otherwise it will sample the main texture.
Shader "Custom/Transition" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_DetailTex ("Detail (RGB)", 2D) = "white" {}
_Guide ("Guide (RGB)", 2D) = "white" {}
_Threshold("Threshold",Range(0,1))=0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _DetailTex;
sampler2D _Guide;
float _Threshold;
struct Input {
float2 uv_MainTex;
float2 uv_DetailTex;
float2 uv_Guide;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
half4 d = tex2D (_DetailTex, IN.uv_DetailTex);
half4 g = tex2D (_Guide, IN.uv_Guide);
if((g.r+g.g+g.b)*0.33333f<_Threshold)
o.Albedo = d.rgb;
else
o.Albedo = c.rgb
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
Example images:
You can use your own texture guide to achieve exactly the kind of effect you want.