Fix line rendering when one endpoint is behind the camera.#33
Open
mrdoob wants to merge 1 commit intogoogle:masterfrom
Open
Fix line rendering when one endpoint is behind the camera.#33mrdoob wants to merge 1 commit intogoogle:masterfrom
mrdoob wants to merge 1 commit intogoogle:masterfrom
Conversation
Change-Id: I99a2909eaa8de03c664d51c9441b59ea96ed6cd5
|
Looks like the dEQP test suite could use an extra test for this case of line rendering... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Made with Claude Opus 4.5.
Problem
Lines with one endpoint behind the camera (
w <= 0) were being incorrectly rendered or disappearing entirely. The perspective division (P.x / P.w) produces invalid values whenw <= 0, causing the line's rectangle polygon to have garbage coordinates before clipping could occur.Solution
Clip line endpoints to
w > epsilonbefore computing the screen-space direction (dx,dy). This ensures valid perspective division and proper rectangle construction, allowing the subsequent polygon clipping to work correctly.Test
The fix can be verified with three.js examples that render grid lines extending toward the camera (e.g.,
webgl_materials_car,webxr_vr_teleport). Before the fix, grid lines close to the camera would break/disappear. After the fix, they render continuously to the screen edges.