#if VFX_PASSDEPTH == VFX_PASSDEPTH_MOTION_VECTOR
${VFXPassVelocityDefine}
#elif VFX_PASSDEPTH == VFX_PASSDEPTH_SHADOW
${VFXPassShadowDefine}
#else
${VFXPassDepthDefine}
#endif
${VFXIncludeRP("VFXLit.template")}

#if defined(WRITE_NORMAL_BUFFER)
${SHADERGRAPH_PIXEL_CODE_DEPTHNORMALS}
#else
${SHADERGRAPH_PIXEL_CODE_DEPTHONLY}
#endif

#if VFX_PASSDEPTH == VFX_PASSDEPTH_SELECTION
int _ObjectId;
int _PassValue;
#elif VFX_PASSDEPTH == VFX_PASSDEPTH_PICKING
float4 _SelectionID;
#endif

#pragma fragment frag
void frag(ps_input i
#if USE_DOUBLE_SIDED
    , bool frontFace : SV_IsFrontFace
#endif
#if VFX_PASSDEPTH == VFX_PASSDEPTH_MOTION_VECTOR
    , out float4 outMotionVector : SV_Target0
#elif VFX_PASSDEPTH == VFX_PASSDEPTH_ACTUAL
    #if defined(WRITE_NORMAL_BUFFER)
    , out float4 outNormalBuffer : SV_Target0
    #endif
    #if defined(_WRITE_RENDERING_LAYERS)
    , out uint outRenderingLayers : SV_Target1
    #endif
#elif VFX_PASSDEPTH == VFX_PASSDEPTH_SELECTION || VFX_PASSDEPTH == VFX_PASSDEPTH_PICKING
    , out float4 outColor : SV_Target0
#endif
)
{
    UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
    VFXTransformPSInputs(i);
    ${VFXComputeNormalWS}

    #ifdef VFX_SHADERGRAPH
        ${VFXAdditionalInterpolantsPreparation}

        #if defined(WRITE_NORMAL_BUFFER)
        ${SHADERGRAPH_PIXEL_CALL_DEPTHNORMALS}
        #else
        ${SHADERGRAPH_PIXEL_CALL_DEPTHONLY}
        #endif

        float alpha = OUTSG.${SHADERGRAPH_PARAM_ALPHA};
    #else

        float alpha = VFXGetFragmentColor(i).a;
        #if URP_USE_BASE_COLOR_MAP_ALPHA
            alpha *= VFXGetTextureColor(VFX_SAMPLER(baseColorMap),i).a;
        #endif

         #if VFX_MATERIAL_TYPE_SIX_WAY_SMOKE
            #ifndef VFX_VARYING_NORMAL
			    const VFXUVData uvData = GetUVData(i);
		    #endif
            alpha *= SampleTexture(VFX_SAMPLER(positiveAxesLightmap),uvData).a;
            #if defined(VFX_VARYING_ALPHA_REMAP)
                alpha = SampleCurve(i.VFX_VARYING_ALPHA_REMAP, alpha);
            #endif
        #endif
    #endif

    VFXClipFragmentColor(alpha,i);

    #if defined(WRITE_NORMAL_BUFFER)
        #ifdef VFX_SHADERGRAPH
            #if HAS_SHADERGRAPH_PARAM_NORMALTS
                float3 n =  OUTSG.${SHADERGRAPH_PARAM_NORMALTS};
                normalWS = mul(n,tbn);
            #endif
        #endif
		VFXComputePixelOutputToNormalBuffer(i, normalWS, GetUVData(i), outNormalBuffer);
    #endif

    #if VFX_PASSDEPTH == VFX_PASSDEPTH_MOTION_VECTOR
        ${VFXComputeOutputMotionVector}
        outMotionVector = encodedMotionVector;
    #elif VFX_PASSDEPTH == VFX_PASSDEPTH_SELECTION
        // We use depth prepass for scene selection in the editor, this code allow to output the outline correctly
        outColor = float4(_ObjectId, _PassValue, 1.0, 1.0);
    #elif VFX_PASSDEPTH == VFX_PASSDEPTH_PICKING
        outColor = _SelectionID;
    #elif VFX_PASSDEPTH == VFX_PASSDEPTH_ACTUAL
        #if defined(_WRITE_RENDERING_LAYERS)
            outRenderingLayers = EncodeMeshRenderingLayer();
        #endif
    #elif VFX_PASSDEPTH == VFX_PASSDEPTH_SHADOW
        //void
    #else
        #error VFX_PASSDEPTH undefined
    #endif
}