Skip to content

Conversation

kwafok
Copy link

@kwafok kwafok commented Aug 25, 2025

Related issue: #31739

Description

This PR fixes an inconsistency where mirroring a camera's projection or view matrix caused incorrect face culling, while mirroring an object's scale worked as expected.

The solution extends the culling logic in both WebGLRenderer and WebGPURenderer to account for the entire transformation chain (Model, View, and Projection). It now correctly determines the final winding order by checking for an odd number of reflections across all relevant matrices, ensuring rendering is predictable and correct in all mirroring scenarios.

To demonstrate the fix, two new examples (mirrored_camera_culling.html and mirrored_camera_culling_webgpu.html) has been added for both WebGL and WebGPU, which allows for interactive testing of the corrected behavior.

image image

kwafok added 4 commits August 25, 2025 23:05
…or improved clarity and consistency. Introduced a computeFrontFaceCW function to encapsulate determinant checks for object, view, and projection matrices.
- Introduced `mirrored_camera_culling.html` for WebGL rendering.
- Added `mirrored_camera_culling_webgpu.html` for WebGPU rendering.
- Created `MirroredCullingApp.js` to handle mirrored camera logic and GUI controls for both rendering contexts.
- Remove unused helpers: syncCameras, resetMirrored, flipProjectionAxis, flipViewAxis
- Use local `group` in setupScene instead of temporary `testGroup`
- Simplify updateDebug by removing unused string accumulator
- No functional changes; lints pass
…tils

- Introduced computeFrontFaceCW function to determine front-face orientation based on object, view, and projection matrix determinants.
- Updated setPipelineAndBindings and draw functions to accept frontFaceCW parameter for pipeline selection.
- Modified _getPrimitiveState and _buildRenderPipelineDescriptor to support front-face orientation configuration.
- Added getRenderPipelineVariant method to retrieve or create a pipeline based on front-face orientation.
Copy link

github-actions bot commented Aug 25, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 338.91
79.11
338.99
79.14
+79 B
+37 B
WebGPU 579.35
159.66
580.28
159.97
+926 B
+316 B
WebGPU Nodes 577.96
159.41
578.88
159.73
+926 B
+315 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 470.78
113.9
470.86
113.94
+79 B
+31 B
WebGPU 649.5
175.53
650.43
175.84
+926 B
+309 B
WebGPU Nodes 603.6
164.67
604.52
164.98
+926 B
+313 B

@kwafok kwafok force-pushed the bugfix-mirrored-camera-inside-out-webgpu branch from e9109c3 to b77201a Compare August 25, 2025 15:14
kwafok added 4 commits August 25, 2025 23:22
- Introduced camera parameters for type, FOV, and orthographic size in the UI.
- Added functions to create and resize cameras based on user selection.
- Updated camera controls to reflect changes in camera type and properties.
- Improved responsiveness to window resizing by consolidating camera update logic.
- No functional changes; maintains existing behavior while enhancing configurability.
…dling

- Added TSL imports (color, select, frontFacing, float) to enable advanced material configurations.
- Refactored setupScene to inline primitive creation and incorporate open geometry functionality.
- Implemented openUpGeometry function to modify geometry
- Enhanced material application logic to differentiate between WebGPU and WebGL rendering contexts.
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.

1 participant