Skip to content

WIP/Fix: correct parallel projection frustum plane normals for left/right#2640

Open
zzuegg wants to merge 1 commit intojMonkeyEngine:masterfrom
zzuegg:fix/parallel-projection-frustum-planes
Open

WIP/Fix: correct parallel projection frustum plane normals for left/right#2640
zzuegg wants to merge 1 commit intojMonkeyEngine:masterfrom
zzuegg:fix/parallel-projection-frustum-planes

Conversation

@zzuegg
Copy link
Member

@zzuegg zzuegg commented Mar 11, 2026

getLeft() returns up×direction but fromFrame() uses direction×up as the view matrix X axis. These are negatives of each other. The hardcoded parallel projection coefficients (1 for left, -1 for right) built plane normals from getLeft(), causing them to point opposite to the view matrix.

This made frustum culling reject visible geometry for any camera with a non-standard orientation (e.g. looking along +Z) or asymmetric frustum values in parallel projection mode.

Fix: negate the left/right coefficients so plane normals align with the view matrix's X axis.

Note: this bug was found and fixed by claude. all jme tests pass, my local project passes too, but i am not sure of the consequences. I create this PR now to run all the remote testing.

getLeft() returns up×direction but fromFrame() uses direction×up as the
view matrix X axis. These are negatives of each other. The hardcoded
parallel projection coefficients (1 for left, -1 for right) built plane
normals from getLeft(), causing them to point opposite to the view matrix.

This made frustum culling reject visible geometry for any camera with a
non-standard orientation (e.g. looking along +Z) or asymmetric frustum
values in parallel projection mode.

Fix: negate the left/right coefficients so plane normals align with the
view matrix's X axis.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

🖼️ Screenshot tests have failed.

The purpose of these tests is to ensure that changes introduced in this PR don't break visual features. They are visual unit tests.

📄 Where to find the report:

  • Go to the (failed run) > Summary > Artifacts > screenshot-test-report
  • Download the zip and open jme3-screenshot-tests/build/reports/ScreenshotDiffReport.html

⚠️ If you didn't expect to change anything visual:
Fix your changes so the screenshot tests pass.

If you did mean to change things:
Review the replacement images in jme3-screenshot-tests/build/changed-images to make sure they really are improvements and then replace and commit the replacement images at jme3-screenshot-tests/src/test/resources.

If you are creating entirely new tests:
Find the new images in jme3-screenshot-tests/build/changed-images and commit the new images at jme3-screenshot-tests/src/test/resources.

Note; it is very important that the committed reference images are created on the build pipeline, locally created images are not reliable. Similarly tests will fail locally but you can look at the report to check they are "visually similar".

See https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-screenshot-tests/README.md for more information

Contact @richardTingle (aka richtea) for guidance if required

@zzuegg
Copy link
Member Author

zzuegg commented Mar 11, 2026

i actually do not know why the screenshot tests are failing. at least i did not expect these to fail

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the camera's parallel projection frustum calculation. By negating specific coefficients for the left and right frustum planes, it ensures that the plane normals correctly align with the view matrix's X-axis, thereby preventing visible geometry from being erroneously culled, especially for cameras with unusual orientations.

Highlights

  • Parallel Projection Frustum Normals: Corrected the coefficients for left and right frustum planes in parallel projection mode to align with the view matrix's X-axis, resolving incorrect frustum culling for non-standard camera orientations.
Activity
  • Bug identified and fixed by Claude.
  • Local JME tests and project tests passed.
  • PR created to initiate remote testing.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a bug in the frustum culling for parallel projections. The change corrects the coefficients for the left and right frustum planes to align their normals with the view matrix's coordinate system. My analysis confirms that Camera.getLeft() and the view matrix's X-axis were indeed opposed, and this change correctly inverts the coefficients to fix the issue. The added comment clearly explains the rationale behind the fix. The change appears correct and should resolve the described culling problems.

@jMonkeyEngine jMonkeyEngine deleted a comment from coderabbitai bot Mar 11, 2026
@riccardobl
Copy link
Member

i actually do not know why the screenshot tests are failing. at least i did not expect these to fail

looks like they are passing now.. there is a bug or something that causes them to fail sometimes, maybe it depends on the action worker?

@zzuegg
Copy link
Member Author

zzuegg commented Mar 12, 2026

from the screenshots it looks like a very small timing issue? i have not checked how the system works exactly. it should run on constant tpf's

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