Skip to content

Conversation

@querielo
Copy link
Contributor

@querielo querielo commented Jan 9, 2026

Description

Force autoClear. The engine can use fromEquirectangularTexture under the hood, and if the user sets renderer.autoClear = false, they may unexpectedly get a blank cubemap from fromEquirectangularTexture.

Copilot AI review requested due to automatic review settings January 9, 2026 10:10
@github-actions
Copy link

github-actions bot commented Jan 9, 2026

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 355.15
84.44
355.15
84.44
+0 B
+0 B
WebGPU 621.09
172.46
621.11
172.47
+15 B
+3 B
WebGPU Nodes 619.7
172.22
619.71
172.23
+15 B
+3 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 487.11
119.23
487.12
119.23
+13 B
+6 B
WebGPU 691.75
187.75
691.77
187.76
+28 B
+17 B
WebGPU Nodes 641.55
174.91
641.58
174.92
+28 B
+11 B

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an issue where fromEquirectangularTexture could produce blank cubemaps when renderer.autoClear is set to false. The fix ensures that autoClear is temporarily forced to true during the cubemap rendering operation, then restored to its original value.

Key Changes:

  • Added save/restore logic for renderer.autoClear in the fromEquirectangularTexture method to guarantee proper clearing behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Mugen87 Mugen87 changed the title CubeRenderTarget: Force autoClear CubeCamera: Force autoClear. Jan 12, 2026
@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 12, 2026

they may unexpectedly get a blank cubemap from fromEquirectangularTexture.

Do you mind explaining in more detail how a "blank cubemap" can happen when a clear is missing?

I'm also thinking about use cases were are potentially missing that break with this change. I wonder if there are scenarios where a clear during the update process of a cube map isn't wanted. With this change, there is no way to force "no clear". The previous code was more flexible since you can enable auto clear on app level before updating a cube camera.

@querielo
Copy link
Contributor Author

querielo commented Jan 12, 2026

In my case, I did two things:

  1. I set renderer.autoClear = false because we use a little customized render pipeline and need to prevent certain buffers from being cleared.
  2. I assigned an equirectangular texture as the background.

As a result, I unexpectedly got a black background. This happens because the engine internally calls fromEquirectangularTexture, which creates a render target and a mesh. That mesh is not rendered due to depth testing in WebGPU. Now, when I think about it probably, the issue could be resolved by disabling depth testing for that mesh. I'll check it tomorrow.

@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 12, 2026

Now, when I think about it probably, the issue could be resolved by disabling depth testing for that mesh.

If that works our for you, I would frankly prefer to not change the autoClear flags to avoid any unexpected side effects. I'm not feeling 100% confident with this PR, tbh. I mean the change is not "wrong" but I fear there are projects that rely on the current behavior.

@querielo
Copy link
Contributor Author

@Mugen87 I have just updated fromEquirectangularTexture for CubeRenderTarget and WebGLCubeRenderTarget.

@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 13, 2026

I set renderer.autoClear = false because we use a little customized render pipeline and need to prevent certain buffers from being cleared.
I assigned an equirectangular texture as the background.

Is it possible for your to demonstrate the issue with a live example first?

side: BackSide,
blending: NoBlending
blending: NoBlending,
depthTest: false,
Copy link
Collaborator

@Mugen87 Mugen87 Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, I don't understand how this fixes any issues since CubeCamera only renders the mesh defined by the cube render target the equirectangular texture is projected on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants