Get the cubetexture by ReflectionProbe, the ground is on top, the sky is on the bottom, how can I flip it up and down

I want to generate panoramas and ENV files from my 3D scene.
At present, my idea is: obtain cubetexture through ReflectionProbe,and then generate panorama and ENV files based on cubetexture. Now I have implemented these two features.
But there is a problem.The ground is on top and the sky is on the bottom in the generated ENV file, I wonder how I can flip it up and down? The sky is above and the ground below.

Here is PG:https://playground.babylonjs.com/#E7IT0S#78

Look forward to your reply.

cc @sebavan

Why not just generating the env file ? as we do here Babylon.js/packages/dev/inspector/src/components/actionTabs/tabs/toolsTabComponent.tsx at 1e5acecbf80a9fcb69c78f5fe50d6f06aa4b4ca0 · BabylonJS/Babylon.js · GitHub

Do you mean creating ENV using EnvironmentTextureTools.CreateEnvTextureAsync?
That’s what I’m using right now.
image

1 Like

Using EnvironmentTextureTools.CreateEnvTextureAsync, I was able to export ENV, but since the cubetexture generated by the reflection probe is sky down and ground up, this is not as expected.
So I’m asking for help, is there any way I can flip the generated ENV up and down?Or flip the cubetexture generated by the reflection probe up and down?

It is reversed cause you reversed top and bottom on the camera https://playground.babylonjs.com/#E7IT0S#80

1 Like

The PG I made can generate both panorama and ENV files at the same time.The PG you gave me is a solution for panorama flipping.
I have simplified PG and only generated ENV. The generated ENV file will be downloaded to a folder , I need to put this ENV file into the sandbox to see the sky box effect-the ground is on top and the sky is on the bottom in the generated ENV file.Now the problem is still there, but it can’t be seen directly in PG. Instead, you need to put the ENV file in the sandbox to see it.
My biggest problem right now is using EnvironmentTextureTools.CreateEnvTextureAsync, I was able to export ENV, but there is a problem with the generated ENV–the ground is on top and the sky is on the bottom.
New PG:https://playground.babylonjs.com/#E7IT0S#81

The PG I made can generate both panorama and ENV files at the same time.The PG you gave me is a solution for panorama flipping.
I have simplified PG and only generated ENV. The generated ENV file will be downloaded to a folder , I need to put this ENV file into the sandbox to see the sky box effect-the ground is on top and the sky is on the bottom in the generated ENV file.Now the problem is still there, but it can’t be seen directly in PG. Instead, you need to put the ENV file in the sandbox to see it.
My biggest problem right now is using EnvironmentTextureTools.CreateEnvTextureAsync, I was able to export ENV, but there is a problem with the generated ENV–the ground is on top and the sky is on the bottom.
New PG:https://playground.babylonjs.com/#E7IT0S#81

Hello,I wonder if there is a solution to the above problem.
Looking forward to your reply.

The cube texture generated by ReflectionProbe is upside down–the ground is on top and the sky is on the bottom.
Therefore, the ENV file generated based on this cubetexture is also upside down.
Can someone help me with this problem? :rofl: :rofl: :rofl: :rofl:

The cube texture generated by ReflectionProbe is upside down–the ground is on top and the sky is on the bottom.
Therefore, the ENV file generated based on this cubetexture is also upside down.
Can someone help me with this problem? @Cedric @sebavan @evidanary Ask God for help :rofl:

It seems that ReflectionProbe inverts the Y of each face when it captures the scene, and modifies the render target’s coordinates mode to INVCUBIC_MODE.

I don’t know why the capture is Y-inverted, but for now the simple solution is to change the coordinates mode to INVCUBIC_MODE when you use this texture.

  env.coordinatesMode = Constants.TEXTURE_INVCUBIC_MODE

Also, the following pg simplifies everything, just viewing the captured texture

1 Like

The way you say the method knowledge reflection is calculated has changed, in fact env itself has not changed.The ENV file generated based on this cubetexture is still upside down.

I think I found a parameter that can change this problem, but I don’t know where to call and modify it.
Can someone help me with this problem?

If this problem really can’t be solved, someone can let me know, and I will think of other ways to generate the ENV file. I think reversing Y should be a relatively simple problem for the authorities, so I still have the expectation that this method is feasible.

Sorry I was oof for a week. I will have a look soon but basically what happens is that env and reflection probe are using different coordinates mode by default. There is no direct way to change it.

@heyefeng229 do you want to make a PR to try and add a mode in the reflection probe to be inverted on y during generation ?

Yes, what you said is what I want, either the ability to flip after the generation, or the ability to flip during the generation of env. The ultimate goal is to get the ENV right.
Thank you very much for your help.

Hello,is there any way to achieve this? I’ve tried several ways. Nothing works.

This is the place Babylon.js/packages/dev/core/src/Probes/reflectionProbe.ts at ea9a8ab09e5f7be651daa06b7f0e780ba6f8e8ee · BabylonJS/Babylon.js · GitHub you would need to change how the faces have been generated. You would need to change the matrices used in the generation to achieve it.

Do you mean that I need to re-write the code to generate cubetexture according to the generation method of ReflectionProbe? Is this necessary?
Can the babylon engine provide some simple control variable based on ReflectionProbe to achieve the generated cubetexture inversion?