I still don't understand how reflection probes could help reflecting all the scene

Hi @carolhmj,

thanks for checking on me :slight_smile: I unfortunately got sidetracked by other parts of my projects and didn’t get a chance to look at this thoroughly but to be honest I don’t really know where to start from so I would absolutely love some help!

Is this something you’ve done before? any pointers would be very welcome.

Thanks again.

Chris

Haven’t done it before (well, only reflections in ray tracing which is easier) but there’s always a first time! :rofl: I’m trying to tinker with @Vinc3r 's idea of cloning the texture, but instead of using .clone(), trying to copy the texture pixels so we don’t get the framebuffer loop:

Testing reflection probes | Babylon.js Playground (babylonjs-playground.com)

It’s not working yet, I think instead of just calling scene.render() just once like I’m doing, this process will need to be repeated on each frame, or we need some other way to guarantee the reflection probe will only run when the rest of the scene is ready.

Ooop ooop that wasn’t it! I just set generateMipmaps to false on the probe and it worked! :open_mouth:

Testing reflection probes | Babylon.js Playground (babylonjs-playground.com)

EDIT: oh shoot, still the feedback loop message :frowning:

EDIT2: Third try! I feel this one is cheaty but… It doesn’t result in a loop and might be better performance wise if there are fewer reflective objects? I created a copy of the object we want to apply the probe on and also render, but with the reflection texture not applied to it. So the probe renders the non reflective version, and I apply the probe to the reflective one:
Testing reflection probes | Babylon.js Playground (babylonjs-playground.com)

First I was ā€œhidingā€ the non reflective version from the final scene by making it a bit smaller than the reflective, so that it was hidden inside, but layer masks also seem to work!

If you pay attention you can see it isn’t the same reflection, but it’s an ok approximation if you don’t need anything very detailed.

Thanks so much for spending time on this @carolhmj! This could work really well for me!

Correct me if I’m wrong but it does mean that I have to double up any object and materials that will use that reflection probe, right?

Chris

That’s correct! I was tinkering with a way to optimize it (I’m finding this really fun :rofl: ), and one option could be to use a simplified version of the mesh for the reflection. I built this veeery ugly one from spheres and cubes:


Placed it along our proper Suzanne:
image
Aaaand ran the reflection probe again:
image

At that distance, it’s pretty hard to distinguish the reflections with the original and simplified meshes, and even more if the reflective material has a bit of bump/roughness, which would distort/blur the reflection:
image

Updated version with these experiments: Testing reflection probes | Babylon.js Playground (babylonjs-playground.com) :smiley:

I’m playing to Mafia 3 these days, and I’ve noticed it seems they’re disabling a lot of render properties for the rear-view mirror. Maybe they’re doing a kind of trick like you do: using a ghost scene for this mirror plane. (I, until now, don’t payed attention about details in the cubemaps used for the car body, 'will check next time I’ll launch the game)

a

Maybe they’re using a lower LOD for the meshes rendered in the Rear view mirror there? Would obviate need for a ghost scene I’d think…