Updating Reflection Probe at runtime... Oh my!

For a number of reason - in part because our sky is dynamic - I have to update a set of reflection probes once in a while.

However, even with “ReflectionProbeTimeSlicingMode.IndividualFaces”, a reflection probe update cost is highly prohibitive (about 2.5 to 3 times longer than a normal render from our player camera!).

We found out that normal “RenderProbe()” always renders in Forward mode, which is really not good for us for a number of reason, but mainly because it cost a lot more and the lighting is all wrong.

So we tried using a “Camera.RenderToCubemap()”, but it also only renders in Forward mode, regardless of the camera setting.

We tried to find a way to “Graphics.Blit()” a RenderTexture into a Cubemap, but it also appears to be an impossibility as it only blits into the X+ side even after doing “Graphics.SetRenderTarget()” with a cubemap face. Is it even possible to Blit into a specific face of a cubemap?

What is supposed to be the proper way of updating ReflectionProbe without killing your performance and getting a good lighting?

After another full day on the topic, I finally managed to do it on my own.

In a specific scene, we passed from 30-40ms per frame while updating a probe, to less then 10ms… While the probe is running on deferred and is able to pick particles and command-buffered lights.

EDIT: More optimization and work; 4ms while a reflection probe is being updated. Take that!

4 Likes

That sounds like a great thing to share with the community in a tutorial or blog post!

At runtime it works flawlessly.

I’m currently building a tool to bake deferred reflection probe, since our level artists are using quite a lot of Command Buffered decals and lights, and half our probes don’t need to be update at runtime. Means I can even apply post-process on those cubemap.

I might release an asset on the Store. Maybe 1-2$, maybe free. I’ll see.

3 Likes

Doing tests… And getting full post-process on a reflection probe is actually very cool. Example, you’re underwater and have a nice color correction to make everything bit blueish. But your probe doesn’t have that, so they aren’t tinted properly. Or you have some bright light sources that don’t “glow” properly in the reflection.


Probe with Amplify Color and Amplify Glow on it.

Comparaison:


I was surprised how much Unity normal reflection baking is having a hard time picking small emissive objects. The room is clearly blueish from all the blue emissive, but Unity’s probe turns out whiteish. Unity’s probes also render out decal and some transparent object totally wrong.

Our sky is totally dynamic, which means it change colors overtime. So updating smoothing (and accurately) the reflection probe is very important!

2 Likes

The Reflection Probe is rendered using the rendering path set in the graphics tier settings (Project Settings → Graphics).
You can specify which tier is active using Graphics.activeTier
By default the rendering path there is Forward.
For a specific camera you can customize the rendering path - Forward or Deferred or use the one set in the current tier settings(Use Graphics Settings).

1 Like

You’re right, it get updated properly now. (Downloaded 2017 to test)

However, we still have no control over the render process. I admit our camera setup is a bit unusual, since we have a “live” sky that is rendered by a different camera, which the normal reflection probe can’t pick.

We’d be very very interested in this (both baking and optimized runtime updating) – are you still thinking about releasing it on the Asset Store? Would surely be a bargain at a lot more than $1-2…

I might just end up dumping it on GitHub. I fount the Asset Store is usually not worth the work of packaging, documenting, supporting and updating an asset. I just haven’t found the few bucks here and there be worth the dozen of hours invested.

Definitely understand that! And that would be very generous…think you might do that soon? :slight_smile:

Here you go: https://github.com/LightStriker/ReflectorProbe
There’s a small demo scene where the reflector uses a camera with a different clear so the sky in the reflection is blue.

7 Likes

Awesome! Thank you so much!!

This is great, thanks!

This is exactly what I needed!

Edit: I don’t know why but this seems to cause errors with the new post processing layer, also flare layer on the camera causes a crash…

need hdr! Thanks

Thanks for all that great stuff. It’s indeed very useful. With regards to manually updating the Reflection Probes:

If you are using HDRP (and maybe other Scriptable Rendering Pipelines), Reflection Probes are overridden by newer classes (search for UnityEngine.Experimental.Rendering.HDPipeline.HDProbe.cs).

They behave differently, and RenderProbe method won’t work with those. Instead, you have to use the following helper method:

HDAdditionalReflectionDataExtensions.RequestRenderNextUpdate(reflectionProbe);

Please note: The HDAdditionalReflectionDataExtensions class is in the UnityEngine.Experimental.Rendering.HDPipeline namespace. You will also need to configure your probe as RealTime, and realtime mode should be set to OnDemand.

Cheers

@LightStriker_1 I just downloaded your package and everything seems fine, i just can’t seem to find where i can switch the mode of the reflection probe? There’s a refreshmode.cs in the folder, but no button in the inspector?

I don’t think I’ve exposed the refresh mode in the inspector, since for our use we had it driven by a manager.

1 Like

Ok, so could you help me on how to call the refresh function? I’m not that familiar with namespaces, but i can’t find the void RefreshReflection function when using Reflector.ReflectorProbe- Am I missing something to call the function?