#How to use IRenderPipelineResources correctly in URP?

1 messages · Page 1 of 1 (latest)

lone vale
#

Hello, i am creating a renderer feature and using the SSAO feature as a reference for my implementation. I have seen they use IRenderPipelineResources for the shader and blue noise textures.

My implementation of this is below, i have used the absolute path for now so the Code folder is located under assets.

    [Serializable]
    [SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
    internal class BloomPersistentResources : IRenderPipelineResources
    {
        [SerializeField, ResourcePath("Code/Shaders/PostProcessing/Bloom.shader")]
        private Shader m_Shader = default;
        public Shader Shader
        {
            get => m_Shader;
            set => this.SetValueAndNotify(ref m_Shader, value);
        }

        [SerializeField, HideInInspector]
        private int m_Version = 0;
        public int version => m_Version;
    }
#

In the AddRenderPasses function in the renderer feature i call a custom function TryGetResources() which tries to retrieve the shader from the resources above. The code below is specifically the part for the shader in the TryGetResources() function.

            if (m_Shader == null)
            {
                if (!GraphicsSettings.TryGetRenderPipelineSettings<BloomPersistentResources>(out var resources))
                {
                    Debug.LogErrorFormat($"Couldn't find the required resources for the {nameof(Bloom)} render feature. If this exception appears in the Player, make sure at least one {nameof(Bloom)} render feature is enabled or adjust your stripping settings.");
                    return false;
                }

                m_Shader = resources.Shader;
            }

I am not sure but something is not correct so far because it is outputting the error.

#

I have taken most of this from the SSAO renderer feature, i understand most of the reason this is done but not sure what i am missing to ensure it works correctly in a build.