- Home /
3 texture blend shader
Hello. Here is my modified 2 texture blend shader. I trying to add third texture but it is not working.
Shader "3 Texture Blend" {
Properties {
_Blend ("Blend", Range (0, 2)) = 0
_MainTex1 ("Base1 (RGB)", 2D) = "white"
_MainTex2 ("Base2 (RGB)", 2D) = "black"
_MainTex3 ("Base3 (RGB)", 2D) = "red"
}
SubShader {
Pass {
SetTexture [_MainTex1]{}
SetTexture [_MainTex2] {
constantColor (0, 0, 0, [_Blend])
combine texture lerp (constant) previous }
SetTexture [_MainTex3] {
constantColor (0, 0, 0, [_Blend])
combine texture lerp (constant) previous }
}
}
}
Help me please. I think maybe problem is in [_Blend].
CG-user ins$$anonymous$$d of shaderLab (what you are using,) but: To test if it's working at all, substitute 0.4(?) for [_Blend]
Should probably have a blend2 variable, for controlling how #3 blends with (#1+#2). Otherwise you can't have a little bit of #2 and a lot of #3.
Then _Blend makes more sense from only 0-1 (the "in between" range of lerp.)
Answer by KingMan · May 12, 2013 at 05:04 PM
Finally i figured how it can be.Thanks all! But now i dont know how to add Light Affection to Shader)
Properties {
_Color ("Color Tint (A = Opacity)", Color) = (1,1,1,1)
_Blend1 ("Blend", Range (0, 1)) = 0.0
_Blend2 ("Blend", Range (0, 1)) = 0.0
_MainTex1 ("Base (RGB)", 2D) = "red"
_MainTex2 ("Base (RGB)", 2D) = "blue"
_MainTex3 ("Base (RGB)", 2D) = "green"
}
SubShader {
Pass {
Lighting On
ZWrite On
Material {
Diffuse [_Color]
Ambient [_Color]
}
SetTexture [_MainTex1]{}
SetTexture [_MainTex2] {
constantColor (0, 0, 0, [_Blend1])
combine texture lerp (constant) previous
}
SetTexture [_MainTex3] {
constantColor (0, 0, 0, [_Blend2])
combine texture lerp (constant) previous
}
}
}
}
@$$anonymous$$ingman
Fantastic little shader. Would there be a way of manipulating the mix on a vertice level ins$$anonymous$$d of the whole mesh? For example, having texture 2 blending in and out based on height? Or having texture 3 fading in and out based on normal direction?
This could be a great base for a terrain texturizer without the need for splatmaps.
Answer by spiritworld · Dec 19, 2020 at 05:45 PM
I created a leaf shader that should blend between _Maintex (normal green) and _FallTex (yellow) and _WinterTex (bare branches) and came up with this
float4 texA = tex2D(_MainTex, uv_MainTex);
float4 texB = tex2D(_FallTex, uv_MainTex);
float4 texC = tex2D(_WinterTex, uv_MainTex);
float4 color = lerp(texA, lerp(texB, texC, step(0.6, _Blend)), step(0.3, _Blend));
Moving the _Blend value over 0.3 will show texB, and moving over 0.6 will show texC.
Your answer
Follow this Question
Related Questions
Shader for texture blending with a sharp outline. 1 Answer
Blitting to RenderTexture does not seem to be accurate 0 Answers
Blending between arbitrary numbers of textures on the same material 0 Answers
How can I combine a color texture with a b&w texture and get color? 2 Answers
Trying to blend 3 textures in shader 1 Answer