Using the reflection probe node in Shader Graph causes a flicker. When paired with bloom, this blows the screen out white because the flicker is of very high intensity.
Reproduction steps:
Create a fresh project in a version that supports Forward+ (I confirmed this bug in 2022.2.11f1 & 2022.2.15f1)
Delete the Post Processing Volume
Go to your URP renderers and switch them to a Forward+ rendering path
Create a new URP Lit shader graph
Add the Reflection Probe node, and connect it to the Base Color
Save Asset
Add a reflection probe into the scene
Bake the probe
Create a new material using the shader created above
Add a Cube into the scene
Assign the material to the cube
Enter play mode
Observe flicker
While we work on the fix, I can provide some context for why this is happening. With Forward+, weâre no longer culling lights or reflection probes per object since we use a spatial data structure to get the same information instead. We disable the computation of the old data for performance reasons.
Unfortunately, it turned out that the Shader Graph node here doesnât actually go through the same path as reflection probe sampling in the URP Lit shader. That also means that it does not support Box Projection - although the fallback from that is a bit more gracious.
So basically, in Forward+ it ends up sampling a texture that hasnât been set to anything, and apparently that just gives you flickering rather than an error.
We need to fix this for sure, but we canât actually fix it with the current node interface, as the node doesnât take a position in, but only a direction. This is also why it cannot support Box Projection at the moment. So the fix (on our side) will be to add that input to the node, and then make it go through the proper code path.
Hi, thanks for the clarification! I think itâd be nice if thereâll be a function to sample the URP reflection probe atlas. And the node can use it too.
ViewDirWS and NormalWS must be in the same space (ex. object, world)
PositionWS is the world space position of current pixel
Smoothness controls which LOD to be sampled in a reflection probe
ScreenPosition is the screen UV (0-1) of current pixel
Code:
// Defined when using Forward+
#if USE_FORWARD_PLUS
// Located at "ShaderLibrary/GlobalIllumination.hlsl", maintained by URP.
Out = CalculateIrradianceFromReflectionProbes(reflect(-ViewDirWS, NormalWS), PositionWS, 1.0 - Smoothness, ScreenPosition);
#else
// Forward or Deferred
// You can sample reflection probes here.
Out = half3(0.0, 0.0, 0.0);
#endif
Reflection Probe node is very broken for me in Forward+ and 2022.3.23f1. Iâve played around with stuff and yes, my shader works in Forward and Deferred mode (which I canât use because it doesnât support camera stacking).
For some reason, after recreating URP settings and setting the Quality asset to the new Deferred one and then back to the original one, the node started partially working. It now at least reflects the skybox instead of flickering. Still doesnât actually reflect any probes.
hi sorry I dont know much about shaders, can give me a bit more detailed instructions? Iâve done what you said, but my shader node gives me an error saying " â_additionalLightsPositionâ: implicit array missing initial value at line 169. Do you know how can I Fix this? Iâm using unity 6.0.30