Blend Two Textures in Vertex Shader .... I dont get it :((

Hello Guys,

please help me, I stick at this issue for more than two ours, I just don’t get it. :frowning: .

I just want to extend this shader to have a “blend texture”, a black-and-white texture, that gets multiplied with the normal shader.

Just this:

Shader "XXX" {
  Properties 
  {
		_MainTex ("Base (RGB)", 2D) = "white" {}
		_Color ("Main Color", COLOR) = (1,1,1,1)
		_Shininess ("Shininess", Range (0.01, 1)) = 1.0
  }

  SubShader 
  {
    Tags { "RenderType"="Opaque" }
    Pass {
	  Lighting Off
      CGPROGRAM
      #pragma vertex vert
      #pragma fragment frag

      #include "UnityCG.cginc"

      float4 _Color;
      sampler2D _MainTex;

      struct v2f 
      {
        float4  pos : SV_POSITION;
        float2  uv : TEXCOORD0;
      };

      float4 _MainTex_ST;
      float _Shininess;
      float _LinearPow;

      v2f vert (appdata_base v)
      {
        v2f o;
        o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
        o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
        return o;
      }

      half4 frag (v2f i) : COLOR
      {
        half4 texcol = tex2D (_MainTex, i.uv) * _Color
        ;
        texcol.a = _Shininess;
        
        return texcol;
      }
      ENDCG
    }
  }
  Fallback "Diffuse"
}

Can someone please please show me how to include a black and white texture in the shader above so that it works like in the picture?

That would be so great !!! …

Thank you, …
valle

Or if your blend texture is all the same alpha use:

        texcol.rgb *= blendCol.rgb;

Hey Duney, Hey meh11,

thanks for your reply !
Unfortunately your solution doesn’t work - the whole shader just gets darkened. What’s wrong?? Do you need some UVs or something? :frowning: :confused:

thanks for your time !

EDIT: Maybe I should add that I use the shader for shader replacement for the camera calling Camera.RenderWithShader()
When I add the shader to a simple plane it seems to work.

I’m not sure about this, but it looks like the new shader isn’t using the same material properties as the original. How are you setting _BlendTex in the new replacement shader?

Hey jRocket, what do you mean exactly?
The new shader of meh11 uses a blend texture as a new property. but thats what I wanted. the problem is:
The shader doesn’t work for rendering the cam with shader replacement!

I dont know why, can somebody help me? :confused:

thanks meh11 !, now I understand what he meant!

Unfortunately its not working like expected… :frowning: Indeed I can see a black ring in the rendered image now as i wanted, but its not moving with the camera. It is just “printed” (fixed) on the geometry.

Let me explain it with this image:

The left part of the image is the rendertexture, that is being rendered with shader replacement. It’s getting updated every frame. I just want to “convert” it to the right image, so I just want to multiply the black-and-white “ring texture”, no matter whats being rendered.
I just wand to add that “black ring” on top of the rendered rendertexture! …

I would be glad if someone gives me a hint, I hope I don’t annoy you guys. I hope it’s now clear what I want to do.

Thanks! :confused:
Valle

Hey Guys,

thanks for your help but I think I’m going to solve it in another way. Shaders are **** me up :smile: :confused:

Thanks to all of you! :slight_smile: