Testing object for HDRP PreRender

What am I trying to do?
I have an object that is rendered with one type of material when it is culled b y the camera. when the object comes in view of the camera, I would like to switch the material on it.
My issue is figuring out when the camera is going to render that object. I am using RenderPipelineManager.beginContextRendering but it is always being called.

How can I get notified when my camera is about to or has, rendered my object?

Maybe i don’t understand, but… Would this help?
https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnRenderObject.html

That looks like it would work thanks.

I will tell you what I’m trying to do in case you have any other ideas. I am trying to make an xray vision effect as in the following video
https://www.youtube.com/watch?v=eLIe95csKWE
but this is for URP. I am attempting to do this with HDRP. I can do it fine with material replacement but I would prefer to use Custom Pass Volumes (https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@10.5/manual/Custom-Pass-Volume-Workflow.html), just not sure how.

What about this example ? https://github.com/alelievr/HDRP-Custom-Passes?tab=readme-ov-file#outline-effect

On that note:

This is the camera frustum culling, so when an objects enters/exits the camera point of view, not when it is behind other objects like you showed in the last message. It would make any sense to have a different material when to object is out of the frustum.

Yeah, I played with the “Local” Custom Pass Volume (I only want this effect on enemies) but it needs to be attached to a collider. Unfortunately, my colliders do not reflect the Mesh of the “enemies”. I only have ragdoll colliders.

That’s not how the local custom pass works. The “local” notion of it is to change where the custom pass affects the camera : if the camera is inside the volume of the custom pass bounds, it will affect it, else it will not.

I think this other example is even exactly what you need : GitHub - alelievr/HDRP-Custom-Passes: A bunch of custom passes made for HDRP