I have a reflection probe and its creating a cube map for the metallic sphere and green wall. The material I’m using for the metallic effect is “Universal Render Pipeline/Lit”
It looks fine in the Unity editor but when I export the reflection texture does not get exported across. Does anyone know how to make that work? Maybe @MackeyK24 knows something about this.
The only reflection texture I export is the main environment texture that comes from the skybox or specifically set as custom.
I don’t iterate all reflection probes in the scene… how do you intend to use these non global skybox reflection textures anyway…
If you can explain the usage , maybe I can do something with them
In the image above I have a mirror sphere and a reflective green wall. You can see how they’ve reflected the environment in the Unity editor. On the right-side is the resulting Babylon output.
I was using reflection probes to bake a cubemap (since the scene is static) which the sphere and wall would use as their reflection.
Should I set the global skybox to that reflection probe cubemap? I think that could create a weird side-effect. Also, what’s the best material in Unity to use to convert to PBR metallic material in Babylon.js?
Well thats basically what the global skybox cubemap (Now called Environment in Unity 2020) does.
Unity uses one global reflection probe that get baked for the environment (Unless you specify a cubemap that has already been generated) each time you build the export scene
So basically Unity does what you are doing. By putting an extra reflection probe in the middle of the scene and PRE-BAKING the cubemap, i think your just duplicating the global reflection probe.
By the way… All reflection probes (including the global unity environment cubemap) gets stored in the the scene folder that should be right next to the scene file itself.
They will be call ReflectionProbe-X… The last (or possibly the only) reflection probe texture is the global environment texture.
So if you only had the global environment reflection probe… It will be called RelfectionProbe-0.exr
if you create additional reflection probes… They will start at zero and the last reflecttion probe texture will be the global environment.
The exporter uses that global cubemap (Which is actually generated in the scene folder) via the RenderSettings.ambientProbe and set it the the scene.environmentTexture. This basically set that global environment texture for each PBR material in the scene (That does not have its own reflectionTexture).
But to answer your original question, if you want to manually create cubemaps of have more than the one global cubemap environment texture:
1… Create the additional reflection probes in Unity and pre bake the cubemap textures.
2… Manually add those reflection textures you just created to the scene export folder
3… In Babylon.js manually load the pre-filtered cubemap textures and manually assign them to what ever materials you want
Thank you for the detailed info. Really appreciate it!
I think I have the wrong material for my sphere though. I can’t seem to get it to reflect anything when exported to Babylon.js, even when I have the custom skybox in place.
Using the legacy version… Yeah those Universal Render Pipeline materials are not supported… Where not even around when i created the old unity exporter.
You best bet (especially for the upcoming toolkit) is to use Standard materials (including Standard Specular).
The new version will convert all materials to GLTF PBR Materials… Even if using funny unity shaders… The toolkit basically looks to use a Base Color, Base Texture, Normal Texture, Occlusion Texture and Emissive Texture (basically the GLTF supported textures)… It will look for these unity textures names (_MainTex, _BumpText etc) and create PBR Materials with these unity textures… So if your unity scene is already using a Unity Standard Material… All the PBR ness will easily convert and copy over… Any NON-PBR material will simply use a Metallic Roughness PBR (metal = 0 and rough = 1) as the FALLBACK material.
This also allows me to create and use custom materials from unity… Including Raw GLSL shaders, to fully custom shaders to the PBR Custom Material type shaders… Which i call Partial Shader Materials in the new toolkit.
Also… Please Remember… We are really just exporting unity content (geometry and its materials, as well as any supported components attach to the node).
So as far as we are concerned, there is absolutely no advantage of using a unity project with the High Definition Render Pipeline, Low Definition Render Pipeline or Universal Render Pipeline. Those are Unity Runtime Concepts. We are only use the Unity Editor Ecosystem to ultimately export content that we load into our native BabylonJS environment and use our babylon script code to do anything we need to.
This is basically what the SceneManager extension does for you. That gives that appearance we are actually using Unity Constructs at runtime… But we are not… The scene manager extension just makes it look we are.
The new version is sooooo intergated (using the native Unity Component Meta Data stoed in the native GTLF To Re-Create the scene in Babylon)… It look like it even more… You should see how i create things Vehicle Control System and Chracter Controller Systems … Using Unity Style Workflows and Gameplay Mechanics. It looks like BabylonJS is really an output type for Unity Itself… But again… Its not… The SceneManager is re-creating that whole Unity Experience using the underlying GLTF Extra Metadata.
Really Kool
2 Likes
I got it working! Thanks so for much your help. You’re a champion @MackeyK24 !
What’s the status of the new exporter? Is there a beta version somewhere? Nothing urgent, just interested to see how its turning out
Did you have to enter the size of the reflection box (X, Y, Z, W)
I have tried it and it didnt work. It just defaulted to the skybox 0, 0, 0 position and image.
The new toolkit now supports exporting ore baked unity reflection probes… you setup exactly like you would for a unity project … refer to the unity docs for baked reflections
1 Like