Search Unity

Projector on transparent objects

Discussion in 'Editor & General Support' started by Bjerre, Mar 6, 2008.

  1. Bjerre

    Bjerre

    Joined:
    Nov 8, 2006
    Posts:
    108
    I´m trying to make all objects in a scene turn white. I´m using a projector and it seems to work just like a want it to, Except for transparent objects. Instead of turn white they become gray. see picture.



    Does anybody know the trick to make it work ?

    The shader I use for my projector


    Code (csharp):
    1.  
    2. Shader "Myshaders/Projector_noAlpha" {
    3.     Properties {
    4.         _Color ("Main Color", Color) = (1,1,1,1)  
    5.         _MainTex ("Cookie", 2D) = "gray" { TexGen ObjectLinear }
    6.     }
    7.  
    8.     Category {
    9.         Lighting Off
    10.         Blend DstColor Zero
    11.         Fog { Color (0, 0, 0) }
    12.  
    13.         Subshader {
    14.             Pass {
    15.                 ZWrite On
    16.                 ZTest Equal
    17.                 AlphaTest Greater 0
    18.                 Color [_Color]
    19.  
    20.                 SetTexture [_MainTex] {
    21.                     constantColor [_Color] Combine constant * texture, constant
    22.                     Matrix [_Projector]
    23.                 }
    24.             }
    25.             Pass {
    26.                 Cull Off
    27.                 Alphatest Greater 0
    28.                 Blend SrcAlpha OneMinusSrcAlpha
    29.                 Color [_Color]
    30.  
    31.                 SetTexture [_MainTex] {
    32.                     Combine previous * texture DOUBLE
    33.                     Matrix [_Projector]
    34.                 }
    35.             }
    36.         }
    37.     }
    38. }
    39.  
    / bjerre
     
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Making Projector affect transparent objects properly is probably impossible. Projector works by re-rendering all objects it touches with a material it uses. But in order to affect a transparent object properly, projector's material would have to somehow know how the original material applies the texture, and so on. Which is probably an impossible problem to solve.

    I think the best you can do is make the projector not affect transparent objects, by using layer masks.
     
  3. Xystress

    Xystress

    Joined:
    Sep 19, 2012
    Posts:
    11
    Hi

    I'm unburying (no sure if this word exists!) this post because I went into almost the same need, and I don't understand why that can't work.
    Actually I have a scene with a camera that render what it see into a render texture (also with depth map), and I want to project this on a plane, but I want the parts where the depth map is black to be transparent on the projected plane.
    My plane has a custom transparent shader, and when the plane has a part inside the frustum of the projector, it turns opaque.

    [EDIT]
    Specifically what we want to know is if the projector pass is rendered before or after the original material, and if it's possible to project transparency or at least a cutout

    @Aras, I trust you when you say that this is not possible, but what I want to understand is why :)

    Thanks for your help !
     
    Last edited: Jun 20, 2013
  4. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    Why do spotlight cookies display properly on sprites then?

    2018-07-12_00-02-30.gif
     
  5. smetzzz

    smetzzz

    Joined:
    Mar 24, 2014
    Posts:
    145
    Would like to be able to project onto plane and the transparency of the projected image is cutout on the plane. Has anyone made progress here? Is it impossible?