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?
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.
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.