Shader not outputing result.

Just got started with URP shaders and the shader I wrote doesnt output anything. Cant figure out where it went wrong.

Shader "Unlit/Test1"
{
    Properties
    {
        _BaseColor("Base Color",Color)=(1,1,1,1)
    }
    SubShader
    {
        Tags
        {
             "RenderType"="Opaque"
             "Queue"="Geometry"
             "RenderPipeline"="UniversalPipeline"
            
        }
      
        Pass
        {
            Tags
            {
                "LightMode"="UniversalForward"
            }

            HLSLPROGRAM
            
                #pragma vertex vert
                #pragma fragment frag

                #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

                struct appdata
                {
                    float4 positionOS:POSITION;
                };

                struct v2f
                {
                    float4 positionCS:SV_POSITION;
                };

                float4 _BaseColor;

                v2f vert(appdata v)
                {
                    v2f o;
                    o.positionCS=TransformObjectToHClip(v.positionOS);
                    return o;
                }

                float4 frag(v2f i):SV_TARGET
                {
                    return _BaseColor;
                }
               
            ENDHLSL
        }
    }
    FallBack "Hidden/Universal Render Pipeline/FallbackError"
}

8997091--1239262--upload_2023-5-7_18-11-6.png

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.

1 Like