PreBake/Cache Realtime Reflection Probe

Hi there,
I need something between a ‘baked’ reflection probe and a realtime reflection probe- a ‘cached’ realtime reflection probe…

In my scene I have a reflective object arising out of an interior subterranean cave model into the exterior where only the skymap is providing the reflections- so while it is ‘rising’ I want to be able to see the reflections change from reflecting the ‘interior’ of the cave to reflecting the ‘exterior’ skymap. While this sort of works with ‘realtime reflections’ the processing involved is just too great (target device is mobile) and while I could set up multiple baked reflection probes again because target device is mobile, the effect is pretty ‘poppy’ because the probes dont ‘blend’.

What would be ideal is if I could bake the realtime reflections associated with the animation of the object (which doesnt change) and then play that back as the object animates, playing the cached file that is closest to the current ‘frame’.

I know Unity doesn’t have a ‘framerate’ as such but if I could bake the realtime reflections at 25fps and then play the cache back during the animation so that the closest cubemap to the current frame was selected that’d be perfect.

Any ideas on how to achieve that?

It’s built in, simply read the docs for reflection probes. You can use a drop down property on the reflection probe to control when it renders from script. If this is regular, then an InvokeRepeating can cause it to update at the frequency you desire.

For “closest to camera” you might want to use the new features in 5.2 - it provides robust distance band results that are calculated very quickly. We’re using that functionality to know what set of reflection probes to update, then we just round robin those, with others far off updated in even lazier fashion ie when nothing else is happening.

@hippocoder , thanks so much for your reply!

Ok… Have read and re-read the docs actually, but the ‘penny isn’t dropping’ quite yet…I cant quite understand what is going on and why its not working for my scenario…

My animation is for Vuforia actually so after about 4secs it happens- from the rendering times on my PC it seems unlikely that will be long enough.

I have some stuff inside the cave too (shiny pistons that lift the main reflective object up) that I am trying to get to use a static baked reflection map. but I am having problems with this map overriding the one on the main reflective object. I have tried using the importance setting but cannot get it to affect just the main reflective object. Even so the main reflective object is not getting realtime reflections- they are still too juttery

So I guess my query now is when you say ‘its built in’ do you mean that after the first time the animation happens at run time the cube maps are cached? If so thats no good for me, since the animation only plays once and that first time is the crucial one, so somehow I need the cubemaps cached before the runtime starts…

Apologies if my lack of understanding is frustrating!

  • this means a reflection probe you can tell to update on your terms.

Unity - Manual: Reflection Probe Inspector window reference - see the section “Refresh Mode”. You set it to “Scripting” on the actual reflection probe.

2192691--145495--2015-07-07_12h30_17.png

Via Scripting

Once you’ve done that you will need a script either on the reflection probe or on another manager object. Obviously, you will be required to get a reference to the reflection probe component. These can be found in various ways and managed in various ways, which is beyond the scope of what you asked since how you’ll do it is your own preference.

If you wanted the most basic way of controlling when a reflection probe will update then simply put a script on the reflection probe and Unity - Scripting API: ReflectionProbe.RenderProbe

For more extensive scripting documentation on probes please refer to Unity - Scripting API: ReflectionProbe

If you only need it to update once when the scene begins, use Awake option on Refresh Mode.

Thanks again hippocoder.

Ok cool, so is there anyway that I can script the probe to render when the app builds, so that the cubemap cache is already there when the app first runs?