Sampling from light probes in custom unlit shader

Hi,

I’m trying to sample from the ambient lighting environment in my custom unlit particle shader and am running into a bit of a problem.

For each particle, I basically just want to sample the light probe at the particle’s position in the vertex shader, but looking into the ShadeSH9 function it doesn’t seem this is possible - it takes a normal and nothing else. This doesn’t really make intuitive sense to me, since I would think light probes would be used for positional changes in lighting more so than directional changes.

Is there a way to do what I’m trying to do that I’m missing? Am I on the wrong path entirely?

Thanks!

By default light probes are sampled at the center of the object’s bounds (or from the anchor override’s transform position) and passed as a single spherical harmonic to the shader. That one “SH” is used for the entire object, so position isn’t necessary.

If you want to be able to access data from multiple probes in a single object you have to use Light Probe Proxy Volumes. There’s a handy blog post showing how to use them, including an example shader.
https://blogs.unity3d.com/2016/02/03/light-probe-proxy-volume-5-4-feature-showcase/

While Unity is using a function called ShadeSHPerPixel, and using it in the fragment shader, there’s no reason it has to be called in the fragment shader if you only want per vertex accuracy.

1 Like