How to get boxMin and boxMax from reflection probe?

I need boxMin and boxMax for my shader, but as i know URP 2019.4.24f1 doesnt have those parameters in build in hlsl files. First of all, what is boxMin and boxMax? And how i can get it?

I assume you’re trying to do box projection for a reflection probe. The boxMin and boxMax values are the min and max extents of an axis aligned box “bounds” of the reflection probe.

You could calculate these yourself if you wanted using the reflection probe’s transform position, box size, and box extent properties. In pseudo code:

boxMin = probe.transform.position + probe.center - (probe.size * 0.5)
boxMax = probe.transform.position + probe.center + (probe.size * 0.5)

I suspect probe.bounds.min and probe.bounds.max would give you the same values, though I don’t know for sure.

Unity’s built in code for this also assumes these values are Vector4 / float4, but the w component isn’t ever used.

Unity may have decided not to support box projection for the URP, but the AFAIK values are still being passed to the shader via unity_SpecCube0_BoxMin and unity_SpecCube0_BoxMax so you don’t actually need to calculate and pass them in on your own unless you want custom values. You’ll likely also need unity_SpecCube0_ProbePosition.

Thanks you very much. Unity 2019.4.24f1 doesn’t have
unity_SpecCube0_BoxMax and unity_SpecCube0_BoxMin in UnityInput.hlsl, so i can’t to use them.

Do you know how to get unity_SpecCube1?

AFAIK you can just add them to your own shader if Unity isn’t defining the values in the included hlsl code. Since the URP uses the default reflection probes, these are still being set by Unity’s built in rendering code.

Again, if it’s not defined, you can just add it to your shader. Look at how they’re defined in the built in shaders and copy/paste that into your own shaders.

In edit mode, I cound get unity_SpecCube0_BoxMax and unity_SpecCube0_BoxMin, but once I enter play mode , these values would turns to be 0, any ideas?

Well … darn. My only thought there would be to copy the data off into your own component.

URP12( for Unity2021.2) started to support box projection, They added BoxMin and BoxMax to the UnityInput.hlsl.