Replacement Shaders and Projectors

Hey everyone,

I am trying to render only the Projectors of my scene but I can’t, all I have is a black image and it seems logical as Projectors need other objects to be projected on.
For this I am using replaced shaders but it doesn’t work and to be honest, I don’t have any idea on how to render only my projectors of my scene… Is there a way to do that ?

Thanks a lot !

Even with Unity 5 and the framedebugger, I can’t retrieve the projector pass, it’s always combined with other objects. It doesn’t seem that it’s possible but maybe I am wrong. Any idea @Aras ?

I think more details are needed to answer your question. For example, the shaders that you use, what exactly goes wrong etc.

Thank you @Aras , I’ll try to improve my question

The aim is to use a post process effect on some projectors with a specific shader.
For that I would like to exclude any other object from the camera and render only some specified projectors inside a rendertexture.
First, I am using a disabled camera with a script and a target rendertexture. In that rendertexture I only want to retrieve the MainTex of some projectors with a black background.

// Done OnPreCull
RenderWithShader(myShader, ",myReplacementTag");

The shader on my projectors has myReplacementTag.

Here is myShader used for the post process effect.

Shader "Custom/Projector"
{
    Properties
    {
        _MainTex ("Diffuse (RGBA)", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "myReplacementTag"="anything" }
        Pass
        {
            Blend SrcAlpha OneMinusSrcAlpha
            ZWrite Off
            Offset -1, -1
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
             sampler2D            _MainTex;
             uniform float4x4    _Projector;
              struct vertexInput
              {
                float4 vertex : POSITION;
                float3 normal : NORMAL;
             };
             struct vertexOutput
             {
                float4 pos : SV_POSITION;
                float4 posProj : TEXCOORD0;
             };

             vertexOutput vert(vertexInput input)
             {
                vertexOutput output;
                output.posProj = mul(_Projector, input.vertex);
                output.pos = mul(UNITY_MATRIX_MVP, input.vertex);
                return output;
             }
  
             float4 frag(vertexOutput input) : COLOR
             {
                 if (input.posProj.w > 0.0)
                { return tex2D(_MainTex, input.posProj.xy / input.posProj.w); }
                else
                { return float4(0.0, 0.0, 0.0, 0.0); }
             }
             ENDCG
         }
   }
    Fallback Off
}

After that I want to send my rendertexture to the specified projector and apply it but this should not be a problem except maybe for the projection.

For the moment, I have a simple setup scene with two projectors and a plane and my rendertexture is all black.
The first thing would be to fill the rendertexture with black and the specified projectors with their MainTex colors. But I don’t know what I am doing wrong…and I don’t know if what I want to do is possible.

Tell me if you need more informations.

@Aras I take the liberty to remember you my question, I would like to know if you have an idea if there is an issue or if it’s not possible.
Of course, any other idea is also welcome ! :slight_smile:

Thank you !

Any idea ?

I only know is in Unity5.6.4, Unity Don’t support projectors when doing shader replacement. I found it in the unity source code.