Sampling Probe Volumes from a script

My game needs to know how brightly-lit a point is. I currently use LightProbes.GetInterpolatedProbe to do this. This works great – it captures both baked and realtime global illumination.

I’d like to switch to probe volumes, but I see no way to do this. I’ve dug around the API docs a fair bit. Is there something I’ve missed?

Hello, there is no way do do that with APV. As the data is streamed from disk to gpu, it is not available for reading on cpu.
What you can do however is run a compute shader that evaluates APV at a given point, output that in a graphicsbuffer and perform an async readback on CPU to get the value a few frames later.
You can find an example of how to sample APV from HLSL here

Same file and line as Adrien linked, just in the public repo

Thanks, I’m trying to access it in ShaderGraph, do you think it’s possible?
It seems that the BakedGI node allows access in HDRP like LightProbes, I’m working on URP.

I’m not entirely sure, since I don’t personally touch ShaderGraph very much. I imagine it should be possible, but you might have to write a custom function node to do it.

At cursory glance, it looks like the Baked GI node should sample APV in both URP and HDRP. Is that not what you are observing?

Okay, I’ll try to have a look if I have the time, but I haven’t yet fully mastered the way it all works.

No, that’s not what I’m seeing, which surprises me because LightProbes passes through this node just fine.
It’s a problem (or a request) that was already raised last June on this thread .

By the way, the node seems to be buggy since I switched my project to 6000.0.1f1.

I know this is an old thread, but i thought i would answer here because someone else might find it helpful. You can use the BakedGI node in URP to access Sample Probe Volumes too. You just need to enable a boolean keyword in your graph with the following set:

Name: ProbeVolumesL1
Reference: PROBE_VOLUMES_L1
Definition: Shader Feature or Multi Compile
Is Overridable: false
Generate Material Property: true
Stages: Fragment
Default Value: true

This works in unity 6000.0.26f1 with shader graph 17.0.3, URP 17.0.3

You can find the breakdown for how BakedGI works in URP here: Graphics/Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl at 2ecb711df890ca21a0817cf610ec21c500cb4bfe · Unity-Technologies/Graphics · GitHub on line 56. the BakedGI node uses that function in a custom function node, i believe.