Search Unity

Question Shader not outputing result.

Discussion in 'Universal Render Pipeline' started by ashan1995, May 7, 2023.

  1. ashan1995

    ashan1995

    Joined:
    Mar 19, 2019
    Posts:
    2
    Just got started with URP shaders and the shader I wrote doesnt output anything. Cant figure out where it went wrong.

    Code (CSharp):
    1.  
    2. Shader "Unlit/Test1"
    3. {
    4.     Properties
    5.     {
    6.         _BaseColor("Base Color",Color)=(1,1,1,1)
    7.     }
    8.     SubShader
    9.     {
    10.         Tags
    11.         {
    12.              "RenderType"="Opaque"
    13.              "Queue"="Geometry"
    14.              "RenderPipeline"="UniversalPipeline"
    15.            
    16.         }
    17.      
    18.         Pass
    19.         {
    20.             Tags
    21.             {
    22.                 "LightMode"="UniversalForward"
    23.             }
    24.  
    25.             HLSLPROGRAM
    26.            
    27.                 #pragma vertex vert
    28.                 #pragma fragment frag
    29.  
    30.                 #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
    31.  
    32.                 struct appdata
    33.                 {
    34.                     float4 positionOS:POSITION;
    35.                 };
    36.  
    37.                 struct v2f
    38.                 {
    39.                     float4 positionCS:SV_POSITION;
    40.                 };
    41.  
    42.                 float4 _BaseColor;
    43.  
    44.                 v2f vert(appdata v)
    45.                 {
    46.                     v2f o;
    47.                     o.positionCS=TransformObjectToHClip(v.positionOS);
    48.                     return o;
    49.                 }
    50.  
    51.                 float4 frag(v2f i):SV_TARGET
    52.                 {
    53.                     return _BaseColor;
    54.                 }
    55.                
    56.             ENDHLSL
    57.         }
    58.     }
    59.     FallBack "Hidden/Universal Render Pipeline/FallbackError"
    60. }
    61.  
    upload_2023-5-7_18-11-6.png

    upload_2023-5-7_18-11-48.png
     
  2. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    766
    Hi, looks like there's no DepthOnly pass (and DepthNormals if using SSAO) in your custom shader. This will break opaque object rendering when Depth Priming is enabled.

    You can either try adding a DepthOnly pass or disabling Depth Priming in URP Asset.
     
    minsumandoo likes this.