Skip to content

Gui: Add hidden anchor object to root for transparency#26590

Merged
kadet1090 merged 2 commits intoFreeCAD:mainfrom
tetektoza:fix/24003_transparent_image_plane_broken
Jan 3, 2026
Merged

Gui: Add hidden anchor object to root for transparency#26590
kadet1090 merged 2 commits intoFreeCAD:mainfrom
tetektoza:fix/24003_transparent_image_plane_broken

Conversation

@tetektoza
Copy link
Member

@tetektoza tetektoza commented Jan 1, 2026

Image planes with transparency failed to render correctly in empty scenes because OpenInventor's two-pass transparency rendering requires at least one opaque object to properly initialize the depth buffer.

The fix adds a zero-scaled cube with no material node (making it use OpenGL's default opaque material) to each image plane's scene graph. This hidden object:

  • Acts as a depth buffer anchor for transparent rendering
  • Is invisible (scaled to 0,0,0)
  • Has negligible performance impact

This matches the workaround already used in the rotation center indicator and resolves the issue where image transparency only worked when the rotation center, grid, or other opaque objects were visible.

Demo:

Before:

before_24003.mp4

After:

after_24003.mp4

Resolves: #24003
Resolves: #15192
Resolves: #24309

@github-actions github-actions bot added the Mod: Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD label Jan 1, 2026
Copy link
Collaborator

@maxwxyz maxwxyz left a comment

Choose a reason for hiding this comment

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

Works

@maxwxyz maxwxyz added Approved: Tested The PR was manually tested and approved Type: Bug This issue or PR is related to a bug backport releases/FreeCAD-1-1 Applied to a PR that is on main to trigger the automatic creation of another PR onto 1.1 labels Jan 2, 2026
@maxwxyz maxwxyz added this to the 1.1 milestone Jan 2, 2026
@maxwxyz maxwxyz moved this from Queue to Approved in Merge Queue Jan 2, 2026
@kadet1090
Copy link
Member

We have the same issue with other planar geometry - like for example planes. Would it be possible to add element like that to the root of 3D scene instead?

Image planes with transparency failed to render correctly in empty scenes
because OpenInventor's two-pass transparency rendering requires at least
one opaque object to properly initialize the depth buffer.

The fix adds a zero-scaled cube with no material node (making it use
OpenGL's default opaque material) to each image plane's scene graph.
This hidden object:
- Acts as a depth buffer anchor for transparent rendering
- Is invisible (scaled to 0,0,0)
- Has negligible performance impact

This matches the workaround already used in the rotation center indicator
and resolves the issue where image transparency only worked when the
rotation center, grid, or other opaque objects were visible.
@tetektoza tetektoza force-pushed the fix/24003_transparent_image_plane_broken branch from d8ba6f8 to df7bb7c Compare January 2, 2026 20:37
@tetektoza tetektoza changed the title Gui: Add hidden anchor object to ViewProviderImagePlane for transparency Gui: Add hidden anchor object to root for transparency Jan 2, 2026
@tetektoza
Copy link
Member Author

tetektoza commented Jan 2, 2026

@kadet1090 sure, done. Along this change I also tested issue that Max linked me, thx @maxwxyz (#15192) and it looks like this patch resolves this as well.

@kadet1090
Copy link
Member

Does it impact bounding box calculation? It is some geometry placed in the scene so it might affect stuff like "fit all" etc.

Prevents the hidden anchor from affecting "fit all" and other bounding box
operations by wrapping it in `SoSkipBoundingGroup`.
@tetektoza
Copy link
Member Author

@kadet1090 good catch, didn't even think about that. Yes, turns out it was prone to Fit All, I also tested clipping plane positioning and standard views - all worked correctly after wrapping the hidden anchor in SoSkipBoundingGroup and setting the mode to EXCLUDE_BBOX - if you have any more ideas what to check, then I can give it a try

@kadet1090 kadet1090 enabled auto-merge (squash) January 3, 2026 01:08
@kadet1090 kadet1090 merged commit 3f49f3f into FreeCAD:main Jan 3, 2026
13 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in Merge Queue Jan 3, 2026
freecad-ci-runner pushed a commit that referenced this pull request Jan 3, 2026
* Gui: Add hidden anchor object to the root for transparency

Image planes with transparency failed to render correctly in empty scenes
because OpenInventor's two-pass transparency rendering requires at least
one opaque object to properly initialize the depth buffer.

The fix adds a zero-scaled cube with no material node (making it use
OpenGL's default opaque material) to each image plane's scene graph.
This hidden object:
- Acts as a depth buffer anchor for transparent rendering
- Is invisible (scaled to 0,0,0)
- Has negligible performance impact

This matches the workaround already used in the rotation center indicator
and resolves the issue where image transparency only worked when the
rotation center, grid, or other opaque objects were visible.

* Gui: Exclude hidden anchor from bounding box calculations

Prevents the hidden anchor from affecting "fit all" and other bounding box
operations by wrapping it in `SoSkipBoundingGroup`.

(cherry picked from commit 3f49f3f)
@freecad-ci-runner
Copy link
Collaborator

Successfully created backport PR for releases/FreeCAD-1-1:

maxwxyz pushed a commit that referenced this pull request Jan 3, 2026
* Gui: Add hidden anchor object to the root for transparency

Image planes with transparency failed to render correctly in empty scenes
because OpenInventor's two-pass transparency rendering requires at least
one opaque object to properly initialize the depth buffer.

The fix adds a zero-scaled cube with no material node (making it use
OpenGL's default opaque material) to each image plane's scene graph.
This hidden object:
- Acts as a depth buffer anchor for transparent rendering
- Is invisible (scaled to 0,0,0)
- Has negligible performance impact

This matches the workaround already used in the rotation center indicator
and resolves the issue where image transparency only worked when the
rotation center, grid, or other opaque objects were visible.

* Gui: Exclude hidden anchor from bounding box calculations

Prevents the hidden anchor from affecting "fit all" and other bounding box
operations by wrapping it in `SoSkipBoundingGroup`.

(cherry picked from commit 3f49f3f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved: Tested The PR was manually tested and approved backport releases/FreeCAD-1-1 Applied to a PR that is on main to trigger the automatic creation of another PR onto 1.1 Mod: Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD Type: Bug This issue or PR is related to a bug

Projects

Archived in project

4 participants