Search Unity

Render order (No sprites or multi cam setup)

Discussion in 'General Graphics' started by kamalcrucialfx, Mar 3, 2020.

  1. kamalcrucialfx

    kamalcrucialfx

    Joined:
    Feb 25, 2020
    Posts:
    2
    Hello all,

    First of I am VERY new to unity, scripting, programming and coding - baring this in mind I'm sorry if I make rookie mistakes.

    I currently have a 3d scene(environment assets) and a 2d plane(The background image)

    I need the background image to be rendered behind the 3d scene even though the 3d scene intersects the background plane.

    Ive looked into layers and tags but had no luck.
    Ive looked into sprites and havent had any luck there.
    Ive tried scripting but I always run into errors which im sure is due to my lack of scripting knowledge.

    I come from a graphics background so im used to c4d/photoshop and stuff like that - so this is all a bit alien to me

    From what I can see online it seems to be a scripting thing but havent had luck

    TIA
     
  2. kamalcrucialfx

    kamalcrucialfx

    Joined:
    Feb 25, 2020
    Posts:
    2
    So this is the shader code that I've found online - Ive had a fiddle with the render type and light mode but all it has done is create a 3d geometry mask that allows for the background image to come through that - which is the opposite of what im trying to achieve



    Code (CSharp):
    1. Shader "KA/Trans"
    2. {
    3.     Properties
    4.     {
    5.         _MainTex ("Texture", 2D) = "white" {}
    6.     }
    7.     SubShader
    8.     {
    9.         Tags
    10.     {
    11.         "Queue" = "Geometry-1"
    12.                 "RenderType" = "Opaque"
    13.                 "LightMode" = "ForwardBase"
    14.  
    15.  
    16.     }            
    17.          ZWrite On
    18.              Ztest LEqual
    19.              LOD 200
    20.         Pass
    21.         {
    22.             CGPROGRAM
    23.             #pragma vertex vert
    24.             #pragma fragment frag
    25.             // make fog work
    26.             #pragma multi_compile_fog
    27.  
    28.             #include "UnityCG.cginc"
    29.  
    30.             struct appdata
    31.             {
    32.                 float4 vertex : POSITION;
    33.                 float2 uv : TEXCOORD0;
    34.             };
    35.  
    36.             struct v2f
    37.             {
    38.                 float2 uv : TEXCOORD0;
    39.                 UNITY_FOG_COORDS(1)
    40.                 float4 vertex : SV_POSITION;
    41.             };
    42.  
    43.             sampler2D _MainTex;
    44.             float4 _MainTex_ST;
    45.  
    46.             v2f vert (appdata v)
    47.             {
    48.                 v2f o;
    49.                 o.vertex = UnityObjectToClipPos(v.vertex);
    50.                 o.uv = TRANSFORM_TEX(v.uv, _MainTex);
    51.                 UNITY_TRANSFER_FOG(o,o.vertex);
    52.                 return o;
    53.             }
    54.  
    55.             fixed4 frag (v2f i) : SV_Target
    56.             {
    57.                 // sample the texture
    58.                 fixed4 col = tex2D(_MainTex, i.uv);
    59.                 // apply fog
    60.                 UNITY_APPLY_FOG(i.fogCoord, col);
    61.                 return col;
    62.             }
    63.             ENDCG
    64.         }
    65.     }
    66. }
    67.