Search Unity

Rendering in Transparent Geometry

Discussion in 'Shaders' started by TJHeuvel-net, Nov 25, 2015.

  1. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    838
    I'm rendering in deferred mode and would like my custom shader to render in the TransparentGeometry pass.

    http://i.imgur.com/kJJuxKK.png

    As you can see there are three cubes, the left most (green) uses the standard shader, the red one uses my custom alpha shader and the right most uses the standard shader with its rendering mode set to Transparent.

    I've added the Queue of 'transparent' and RenderType of 'Geometry' to the Tags portion, though that didnt seem to have much impact.
     
    Last edited: Nov 25, 2015
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,755
    I'm confused. What do you want to happen exactly?
     
  3. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    838
    Right now in the Render OpaqueGeometry there is an additional RenderForwardOpaque where the red cube is drawn, this is my custom shader. I'd like my custom shader to be drawn in the `Render.TransparentGeometry` queue, like the standard shader in Transparent mode.
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,755
    Well, I can't really help you if I don't know what your shader does.
     
  5. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    838
    I expect only the `queue` in the tags is really relevant, that is why i explained what its like in my initial post.

    However here is the rest of the shader (as you can see pretty standard). The reason i want it to render in the other pass is that my image effect still affects this shader and not the other one, because it has the ImageEffectOpaque attribute.

    Code (csharp):
    1.  
    2. Shader "Unlit/Alpha"
    3. {
    4.     Properties
    5.     {
    6.         _MainColor ("Maincolor ", Color) = (1,0,0,1)
    7.     }
    8.     SubShader
    9.     {
    10.         Tags
    11.         {
    12.             "Queue" = "Transparent"      
    13.             "RenderType" = "Geometry"
    14.         }
    15.         ColorMask rgb
    16.         Blend SrcAlpha OneMinusSrcAlpha
    17.         ZWrite Off
    18.         Cull Off
    19.  
    20.         LOD 100
    21.  
    22.         Pass
    23.         {
    24.             CGPROGRAM
    25.             #pragma vertex vert
    26.             #pragma fragment frag
    27.             // make fog work
    28.             #pragma multi_compile_fog
    29.          
    30.             #include "UnityCG.cginc"
    31.  
    32.             struct appdata
    33.             {
    34.                 float4 vertex : POSITION;
    35.                 float2 uv : TEXCOORD0;
    36.             };
    37.  
    38.             struct v2f
    39.             {
    40.                 float2 uv : TEXCOORD0;
    41.                 UNITY_FOG_COORDS(1)
    42.                 float4 vertex : SV_POSITION;
    43.             };
    44.  
    45.             float4 _MainColor;
    46.          
    47.             v2f vert (appdata v)
    48.             {
    49.                 v2f o;
    50.                 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
    51.                 UNITY_TRANSFER_FOG(o,o.vertex);
    52.                 return o;
    53.             }
    54.          
    55.             fixed4 frag (v2f i) : SV_Target
    56.             {
    57.                 return _MainColor;
    58.             }
    59.             ENDCG
    60.         }
    61.     }
    62.  
    63.     Fallback Off
    64. }
    65.  
    66.  
    Thanks for taking your time!
     
  6. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,755
    Are you sure it's not rendering it in Render.TransparentGeometry? That's where it appears to be rendering it in my tests.
     
  7. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    838
    Sorry to bother you this much, solved it! Thank you for helping.

    I guess the material cached the renderqueue incorrectly, after dragging the shader on again it jumped to the right queue.
     
    nbalexis1 and AcidArrow like this.