Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Particles not rendering when enters in projector area

Discussion in 'General Graphics' started by idurvesh, Sep 15, 2016.

  1. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    Hi, I have particles system of Nitro...When it enters onto projector ,it gets invisible.

    Anyone knows why this may be the case?


    EDIT

    I am using projectors for shadows...When I use particles for bike speed up i.e., nitro speed the particles get cutout by those shadows....

    Here is screenshot of it,



    Here is my shader code of projectors ,
    Code (CSharp):
    1. Shader "Projector/Projector Multiply Black"
    2. {
    3.     Properties
    4.     {
    5.         _ShadowTex("Cookie", 2D) = "gray" { TexGen ObjectLinear }
    6.     _ShadowStrength("Strength",float) = 1
    7.     }
    8.  
    9.         Subshader
    10.     {
    11.         Tags{ "RenderType" = "Transparent"  "Queue" = "Transparent+100" }
    12.         Pass
    13.     {
    14.         ZWrite Off
    15.  
    16.         //Fog { Mode Off }
    17.  
    18.         Blend DstColor Zero
    19.  
    20.         CGPROGRAM
    21. #pragma vertex vert
    22. #pragma fragment frag
    23. #pragma fragmentoption ARB_fog_exp2
    24. #pragma fragmentoption ARB_precision_hint_fastest
    25. #include "UnityCG.cginc"
    26.  
    27.  
    28.         struct v2f
    29.     {
    30.         float4 pos : SV_POSITION;
    31.         float2 uv_Main     : TEXCOORD0;
    32.     };
    33.  
    34.     sampler2D _ShadowTex;
    35.     float4x4 unity_Projector;
    36.     float _ShadowStrength;
    37.  
    38.     v2f vert(appdata_tan v)
    39.     {
    40.         v2f o;
    41.  
    42.  
    43.         o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    44.  
    45.         o.uv_Main = mul(unity_Projector, v.vertex).xy;
    46.  
    47.  
    48.         return o;
    49.     }
    50.  
    51.     half4 frag(v2f i) : COLOR
    52.     {
    53.         half4 tex = tex2D(_ShadowTex, i.uv_Main);
    54.         half strength = (1 - tex.a*_ShadowStrength);
    55.         tex = (strength,strength,strength,strength);
    56.         return tex;
    57.     }
    58.         ENDCG
    59.  
    60.     }
    61.     }
    62. }

    Here is my particle code,
    Code (CSharp):
    1. // Simple additive particle shader.
    2.  
    3. Shader "Custom/Particle additive"
    4. {
    5. Properties
    6. {
    7.     _MainTexture ("Particle Texture (Alpha8)", 2D) = "white" {}
    8. }
    9.  
    10. Category
    11. {
    12.     Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
    13.     Blend SrcAlpha One
    14.     Cull Off Lighting Off ZWrite Off Fog {Color (0,0,0,0)}
    15.  
    16.     BindChannels
    17.     {
    18.         Bind "Color", color
    19.         Bind "Vertex", vertex
    20.         Bind "TexCoord", texcoord
    21.     }
    22.  
    23.     SubShader
    24.     {
    25.         Pass
    26.         {
    27.             SetTexture [_MainTexture]
    28.             {
    29.                 combine primary, texture * primary
    30.             }
    31.         }
    32.     }
    33. }
    34. }
     
  2. Torbach78

    Torbach78

    Joined:
    Aug 10, 2013
    Posts:
    296
    Transparent+100 makes it ontop?
     
    richardkettlewell likes this.
  3. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    I tried that on both shader..one of both shaders...but same happening
     
  4. Torbach78

    Torbach78

    Joined:
    Aug 10, 2013
    Posts:
    296
    hmm

    Change the fog from "Color (0,0,0,0)" to "Mode Off".??

    ... is the multiply Blend mode operation on the projector the cause? maybe an idea
    but perhaps Blend DstColor Zero causes destination = 0 ; source = source * destination

    could that shadow be black using frag computation instead of blend mode? RGB = 0, Alpha = 1
    ///Blend One OneMinusSrcAlpha///...could that work?
     
    idurvesh likes this.
  5. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    I able to solve that problem by adding two cameras, one for only rendering particle and other for rest of stuff....It did work pretty good.

    I will check it out your solution soon and update you with same.

    Thank you so much for your replies. :)
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,209
    As mentioned in your other thread this was a bug with projectors rendering twice (in this case once at the correct queue before the particles, and once at the end of the queue over the particles).

    It's listed as a fixed issue in the 5.4.2 release notes, so I suggest you upgrade to that.
    • Graphics: Fixed the issue of projectors rendering twice if transparent objects are in the scene. (814282)
     
    idurvesh and richardkettlewell like this.