[webXR] Wierd behavior with prepass renderer

  1. I can partly understand why there are four parts in the scene but how can I fix it? It seems that textureSampler should not return an image with two parts.
  2. As far as I thought, the left part and the right part should be the same, but the second part(of four) missed.

I pushed your request to chatGPT to learn with you.

Can you explain me this code:
(pasted here your playground example)

chatGPT:
This code creates a Babylon.js scene with a sphere and a light, and sets up a custom post-process render pipeline that will be used for rendering the scene. The custom post-process render pipeline contains a single post-process effect that simply copies the input texture to the output texture.

The code begins by defining a constant called SHADER_NAME that contains the name of the shader used by the post-process effect. This shader is defined as a string and added to the Babylon.js Effect.ShadersStore object with the key ${SHADER_NAME}FragmentShader.

Next, a PrepassConfiguration class is defined with several properties and methods that are used to configure the prepass renderer. The CopyPostProcess class is then defined as a subclass of the PostProcess class from Babylon.js. This class overrides the getClassName() method and defines a constructor that calls the super() method to create a new PostProcess object with the specified parameters. The constructor also creates a new PrepassConfiguration object and sets the samples property of the render target to 6.

After that, the createScene() function is defined, which creates a new Babylon.js scene object and sets up a camera, light, and sphere mesh. It also creates a default environment for the scene. Then a new CopyPostProcess object is created and added to a _postProcesses array, which is used to create a new PostProcessRenderEffect object. This effect is added to a new PostProcessRenderPipeline object that is added to the scene’s postProcessRenderPipelineManager. Finally, an xrHelper object is created to handle WebXR, and the attachCamerasToRenderPipeline() and detachCamerasFromRenderPipeline() methods are called on the postProcessRenderPipelineManager depending on the state of the XR session.

Overall, this code sets up a simple scene with a custom post-process render pipeline that can be used for rendering the scene with an XR headset. The pipeline contains a single post-process effect that simply copies the input texture to the output texture.

I can partly understand why there are four parts in the scene but how can I fix it? It seems that textureSampler should not return an image with two parts. As far as I thought, the left part and the right part should be the same, but the second part(of four) missed.

GPT: Without more context, it’s difficult to say exactly what’s causing the issue you’re describing. However, it sounds like there may be a problem with the texture or the way it’s being sampled in the fragment shader.

The code you posted appears to define a fragment shader called “Copy” that simply samples a texture at a given UV coordinate and sets the output color to the value of the sampled texel. This shader is used in a post-processing pass called “CopyPass”, which is part of a custom render pipeline.

If you’re seeing unexpected results in the output texture, it’s possible that the input texture is not being sampled correctly. One thing to check is whether the texture being sampled is actually the correct size and format. Another thing to check is whether the UV coordinates being used to sample the texture are correct.

If you’re still having trouble, it might be helpful to provide more context or information about the specific problem you’re experiencing.

Here are some errors in the console which can be used to find the spot of the bug or missing link or whatever to fix the problem:

Then I sent the error message to chatGPT:
thinEngine.ts:5330 WebGL: INVALID_OPERATION: texParameter: no texture bound to target

GPT: This error message indicates that a WebGL texture parameter was attempted to be set, but no texture was bound to the target specified by the function. This can happen when trying to set a parameter for a texture that has not been created or bound yet.

To fix this error, you should ensure that a valid texture is bound to the appropriate target before calling the function that sets the texture parameter. Here are some steps you can follow to debug this issue:

  1. Check if you are creating and binding textures correctly. Make sure that the texture you are trying to set parameters for has been created and bound before calling texParameter.
  2. Make sure that you are using the correct texture target when binding the texture. Some texture targets include TEXTURE_2D, TEXTURE_CUBE_MAP_POSITIVE_X, TEXTURE_CUBE_MAP_NEGATIVE_X, TEXTURE_CUBE_MAP_POSITIVE_Y, TEXTURE_CUBE_MAP_NEGATIVE_Y, TEXTURE_CUBE_MAP_POSITIVE_Z, and TEXTURE_CUBE_MAP_NEGATIVE_Z.
  3. Check if the texture is being unbound somewhere else in the code. If you unbind the texture before calling texParameter, the texture will no longer be bound to the target and the error message will be triggered.
  4. If the error message persists, try running the code in a WebGL debugging tool such as WebGL Inspector or Chrome DevTools to get more information about the state of the WebGL context and the texture. This can help identify where the error is occurring and what steps need to be taken to fix it.

Please consider that not everything what GPT explains is correct and I have not enough experience to verify your code.

PS: I will delete my post if it is useless.

cc @Evgeni_Popov

Seems like an issue with WebXR and custom pipelines. I am going to assign myself and will check it after we are done with the 6.0 release

May I ask is there any progress?

Sure. Was working on that today (with a huge thank you to @Evgeni_Popov :slight_smile: ).
At its current state prepass rendering is not supported in WebXR. I understand the issue and we know how to solve it, but it will take a little more time until I find the cleanest solution for that.
Will take some time. I will create an issue on github to be able to track this.

3 Likes