Skip to content

Conversation

@maidi29
Copy link
Contributor

@maidi29 maidi29 commented Jan 14, 2026

Description

This PR adds support for controlling depth buffer writes in material definitions. The new depthWrite property allows developers to specify whether a material should write to the depth buffer during rendering.

This is particularly useful for transparent objects that shouldn't occlude other geometry behind them. When depthWrite is set to false, transparent materials can render correctly without blocking objects that should be visible through them.

Changes:

  • Added depthWrite?: boolean property to MaterialDefinition type with default value of true
  • Implemented depthWrite handling in MaterialManager when creating materials (defaults to true if not specified)
  • Added depthWrite support in highlight definition merging logic
  • Updated documentation to clarify the relationship between depthTest and depthWrite

Additional context

This feature complements the existing depthTest property and provides finer control over depth buffer operations.

Files modified:

  • packages/fragments/src/FragmentsModels/src/model/material-manager.ts
  • packages/fragments/src/FragmentsModels/src/model/model-types.ts

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following:

  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Follow the Conventional Commits v1.0.0 standard for PR naming (e.g. feat(examples): add hello-world example).
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

maidi29 added a commit to maidi29/engine_fragment that referenced this pull request Jan 14, 2026
…ation

- Add depthWrite property to MaterialDefinition (from PR ThatOpen#145)
- Update MaterialUtils.isSame to include transparent, depthTest, depthWrite
- Remove blanket dedup-disable for preserveOriginalMaterial
- Merge base material properties in highlight-helper before deduplication
- Add depthTest and depthWrite to highlight props list

Items with the same base material properties (opacity, transparent, depthTest,
depthWrite, renderedFaces) and same highlight color now share a single material,
dramatically reducing material count while preserving per-item opacity.

Example: 1000 windows with opacity=0.5 colored red -> 1 material instead of 1000
Copy link
Member

@MiguelG97 MiguelG97 left a comment

Choose a reason for hiding this comment

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

LGTM

@agviegas agviegas merged commit 391f9dc into ThatOpen:main Jan 16, 2026
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.

3 participants