Skip to content

Conversation

GoodBoyDigital
Copy link
Member

@GoodBoyDigital GoodBoyDigital commented Mar 27, 2025

Description of change

This PR fixes an issue where face culling appears inverted when rendering to a render texture compared to rendering directly to the screen. This issue affects both render textures and filters (which use render textures internally).
The problem occurs because WebGL uses a different coordinate system when rendering to a texture (Y is flipped), which causes the winding order of triangles to be reversed. Since face culling depends on winding order, this results in front faces being culled instead of back faces and vice versa.

Changes

Added _invertFrontFace flag to track when rendering is happening to a texture
Implemented tracking mechanism for front face orientation in the GL state system
Added automatic front face culling correction when switching between screen and texture rendering
Ensured proper state restoration when context changes or when rendering finishes
Optimized GL state changes to only apply when actually needed

fixes #11350

Pre-Merge Checklist
  • Tests and/or benchmarks are included
  • Documentation is changed or added
  • Lint process passed (npm run lint)
  • Tests passed (npm run test)

Copy link

codesandbox-ci bot commented Mar 27, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit f88b869:

Sandbox Source
pixi.js-sandbox Configuration

@Zyie Zyie added the ✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t label Mar 27, 2025
@Zyie Zyie added this pull request to the merge queue Mar 27, 2025
Merged via the queue into dev with commit 50f1d65 Mar 27, 2025
5 checks passed
@Zyie Zyie deleted the bug/state-front-face-fix branch March 27, 2025 12:04
@Mysak0CZ
Copy link
Contributor

Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Mesh face culling breaks when rendering to a render texture
4 participants