How to darken a projector part under a mesh ?

Because a picture can resume a long explanation, here is an example : (see attachement)

What I would like is to darken the part of the projected texture “under” the boat. But I don’t really know on what object I have to work : the boat shader (actually the basic Diffuse one) , the projector shader, or something else.

The shader I made for the projector is this one : (I’m beginning with shaders)

Shader "Projector/Target" {
  Properties {
  	  _Color ("Main Color", Color) = (1,1,1,1)   	
     _ShadowTex ("Cookie", 2D) = "" { TexGen ObjectLinear }
  }
  Subshader {
     Pass {
		ZWrite Off
		ZTest Always
       	Blend SrcColor One
		Offset -1, -1
        SetTexture [_ShadowTex] 
        {
        	constantColor [_Color]
		  	combine texture alpha * constant
           	Matrix [_Projector]
        }     
    }
}

Any idea ?

Thanks in advance !

Do I understand the scene correctly in that the projector should not project onto the boat but only onto the ground?

Thus, “under the boat” really means “inside the boat”?

In that case I think I would just use two projectors: the current one would get a lower intensity which is visible inside the boat.

And a second projector would add additional light but use a standard ZTest such that it adds the light only if the surface it projects onto is visible.

“Inside the boat” is more correct than “under the boat”, you’re right.

I didn’t think to use 2 projectors. I will try your solution, thanks :slight_smile:

Oh, now I see, the boat is upside down. Thus, “under” makes sense.
I thought it was a submarine. :slight_smile:

Ok, it works, with only one projector ! :slight_smile:

I started with 2 projectors when I realize I could merge the shader code.

Shader "Projector/Dodge" {
  Properties {
  	  _ColorV ("Visible Color", Color) = (1,1,1,1)   
  	  _ColorH ("Hidden Color", Color) = (0,0,0,1)	
     _ShadowTex ("Cookie", 2D) = "" { TexGen ObjectLinear }
  }
  Subshader 
  {
  	Lighting Off

  	// Invisible Pass
  	Pass 
  	{
		ZWrite Off
		ZTest GEqual
		Blend DstColor One
		Offset -1, -1
		SetTexture [_ShadowTex] 
		{
			constantColor [_ColorH]
		  	combine texture alpha * constant
		   	Matrix [_Projector]
		}
	}
    
    // Visible Pass 
	Pass 
	{
		ZWrite Off
		ZTest LEqual
		Blend SrcColor One
		Offset -1, -1
		SetTexture [_ShadowTex] 
		    {
		    	constantColor [_ColorV]
			  	combine texture alpha * constant
		       	Matrix [_Projector]
		    }
	 }
  }
}

It could probably be improved but it’s seems to work. For this simple case at least :slight_smile:

Thanks for the help !