Help creating Shader to control blending of Detail

I so wished I understood Shader coding :frowning: so I need some help here… please

I want a shader that allows me to control the blending of the detail texture with the main texture.

Here is what I have so far which is missing the blending part

Edit: What I am actually looking for is the ability to control how much of the detail texture is showing on top of the main texture. Not an actual blend between the two like Lerp for instance would produce at 0.5 value.

Shader "Custom/Diffuse Bump Detail Blending" {

    Properties {
 
        _MainTex ("Main Texture", 2D) = ""
        _Detail ("Detail Texture", 2D) = ""
        _BumpMap ("Normal Map", 2D) = "bump" {}
	_Blend ("Blend", Range(0, 2)) = 0.5		

    }

    SubShader {

      Tags { "RenderType" = "Opaque" }

      CGPROGRAM

      #pragma surface surf Lambert

      struct Input {

        float2 uv_MainTex;
	float2 uv_Detail;	
        float2 uv_BumpMap;

      };

      float _Blend;

      sampler2D _MainTex;
      sampler2D _Detail;
      sampler2D _BumpMap;	

      void surf (Input IN, inout SurfaceOutput o) {

        //o.Albedo = lerp( tex2D (_MainTex, IN.uv_MainTex).rgb, tex2D (_Detail, IN.uv_MainTex).rgb, _Blend);
	o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
	float3 detail = tex2D (_Detail, IN.uv_Detail).rgb * _Blend;
	o.Albedo *= detail;
	//o.Alpha = _Blend;
        o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));

      }

      ENDCG

    } 

    Fallback "Diffuse"

  }

Use lerp and assign that to Albedo, with something like lerp(tex.rgb, tex2.rgb, 0.5);

This will blend tex2.rgb with tex.rgb by the third parameter (so 0.5 means 50/50 in this example). You could implement a shader parameter to use as the third parameter so you could control the blending with a slider.

Hope this helps :slight_smile:

Lerp does blend which I had used but I was looking for a way to have _MainTex be 100% visible and to sort of fade the _Detail over it.

Like this works pretty good …

o.Albedo = _MainTex.rgb + ((_Detail.rgb - 0.5) * _Blend);