Skip to content

glTF/IFC export loses Revit transparency when the element→material binding fails, and never reads view/graphics (V/G) overrides #1812

Closed

Description

@zenglanmu

Summary

First, thanks — the material pipeline is in better shape than the docs suggest. On a Revit 2024
project, material_object_tag / scan_material_appearances recovered 192 materials, 60 of them
with transparency > 0
, and model_to_glb emitted 37 alphaMode: "BLEND" materials whose
baseColorFactor[3] is exactly 1 − transparency
(Glass 0.9, Fassade - Glas 0.75,
Glass - Clear, Grey 0.64, Glass - Frosted 0.55, …). Those bindings reach 438 glazing panels and
66 light-fixture glass panes. So graphics-tab transparency is read and exported correctly — this is
not an alpha-emission bug report.

Two gaps remain for consumers that treat the glTF as geometry+appearance data:

  1. View/graphics overrides (V/G) are not read at all. A view that sets a category or an element
    to 50% transparency exports fully opaque. There is no research module, no support-matrix.json
    row, and no mention in the changelog for VisibilityGraphics / OverrideGraphicSettings /
    per-view transparency. (All "override" hits in the changelog are IFC Export As overrides.)
  2. When the element→material binding fails, the fallback throws away transparency. The
    fallback is category_material() → category_colour() (src/ifc/gltf.rs:640-664), which
    hardcodes alpha per IFC type and otherwise 1.0. On the same project:

A related small inconsistency: category_colour() invents alpha for IFCWINDOW/IFCPLATE
(0.45) and IFCSPACE (0.12). Those values are not in the file. For a viewer palette that may be
intentional, but the same function feeds the glTF/IFC data export, so a consumer cannot tell
"Revit says 45% opaque" from "rvt chose 45% for windows". See the downstream-consumer note below for
why that distinction matters to a CAD database.

Environment

How YACR uses this crate

YACR (https://github.com/zenglanmu/yacr) is a Rust CAD viewer that imports .rvt by depending on
this crate, pinned exactly at =0.17.0 (no fork, no patch). It calls run_export(...) +
model_to_glb(&run.model) and then reads the GLB as data: node world transforms become meshes,
baseColorFactor becomes the entity colour, and alphaMode: "BLEND" + alpha becomes an explicit
opacity attribute stored on the entity. That opacity is both rendered (transparent pass: 580 of
6,804 batches in the sample below) and plotted (PDF /ca), so it is database state rather than a
viewer tint: a lost material binding makes an element silently opaque, and a V/G override has no
representation — and no diagnostic saying it was dropped.

Reproduction

  1. Open the sample project with the default export path, write the GLB.
  2. Count materials and node primitives by baseColorFactor[3]:
    • 212 glTF materials, 37 with alpha < 1.0;
    • 6,804 primitives, 580 with alpha < 1.0;
    • every primitive on a Category IFC* material is a = 1.0 except IFCSPACE (0.12).
  3. In Revit, create/observe a view with a V/G override that makes a category translucent
    (e.g. Walls → 50%); re-export. The override has no effect on any material or primitive.
  4. For the binding gap, compare a type that draws with one material against an instance whose
    material is only in its own parameters: the former gets the material (and its alpha), the latter
    falls back to Category IFC*.

Expected

  • A documented, machine-readable statement of whether view/graphics overrides are part of the
    export contract (a support-matrix.json row plus a line in the glTF/IFC docs would be enough for
    consumers to state the boundary honestly).
  • If feasible: read OverrideGraphicSettings transparency for the exported view and let it override
    the element/category alpha, with the same "no invented values" rule used for materials.
  • Category fallback should not fabricate alpha for data exports, or should mark it (e.g. the
    material name already says Category …; an extras flag or a documented alphaSource would make
    it unambiguous).

Companion PR I can send (small, zero decoder risk)

tests/element_materials.rs checks material names through the IFC export, but no test asserts
the glTF alpha path — the transparency claim currently rests on the external IFC-scored probes
(RE-53). I can add tests/gltf_material_alpha.rs, corpus-free and deterministic:

  • build IfcModel { materials: vec![..], ..Default::default() } with
    MaterialInfo { transparency: Some(0.75) } and an opaque sibling;
  • model_to_glb(&model), parse the JSON chunk with serde_json (already a regular dependency);
  • assert the translucent material emits alphaMode == "BLEND" and
    pbrMetallicRoughness.baseColorFactor[3] ≈ 0.25, and the opaque one emits no alphaMode with
    1.0;
  • optionally pin the category fallback deliberately: an IfcEntity::BuildingElement with
    ifc_type = "IFCWINDOW" and no material emits Category IFCWINDOW with alpha 0.45, so the
    fabricated value is a documented decision rather than an accident.

No Cargo.toml change is needed: the upstream [dev-dependencies] already enables
rvt = { path = ".", features = ["unstable-research"] } for dev targets, and serde_json is
already a regular dependency.

I can also add a corpus-gated companion check in the style of tests/element_materials.rs
(RVT_PROJECT_CORPUS_DIR, skip when absent) that walks the sample project and asserts the
transparent-material count, so a future regression in pbr.rs/gltf.rs fails loudly.

Notes

  • I am not asking for a fork; we pin an exact version and would bump to whichever release carries
    this.
  • Happy to split the work: the test PR now, the V/G override reading as a separate issue once you
    decide it is in scope.

Activity

  1. DrunkOnJava commented on Nov 12, 2026

    @DrunkOnJava
    Owner

    Thank you for the careful report, and for measuring it on a real project before writing. Your reading of the material path is right, and so is the main point: a consumer reading the GLB as data cannot tell a colour read from the file from one rvt-rs chose. Here is where each part stands.

    1. View/graphics overrides. rvt-rs does not read them. Revit's own IFC export does not apply them either. In Autodesk's open-source exporter (revit-ifc):

    • BodyExporter.GetBestColourAndOpacity takes an element's colour and opacity from its material (found from its geometry or a parameter), or else from its category's material;
    • CategoryUtil writes IfcSurfaceStyleRendering.Transparency from that material's own transparency.

    Neither reads a view's overrides. rvt-rs follows Revit's export, so view overrides are outside the export contract. I will state that boundary in docs/support-matrix.json and the glTF section of docs/viewer-api.md, so it is written down in one place rather than left to be inferred.

    2. The category fallback. One correction on scope: the IFC export does not use category_colour. step_writer writes a surface style only for a material whose colour was read from the file, with that material's own transparency, and an element with no material gets no style. The category colours and their alphas (0.45 for windows and plates, 0.12 for spaces) exist only in the GLB, where they are the viewer's palette. The viewer draws that same GLB, which is why they are there.

    You are right that the Category … name does not settle it, since a Revit material can be named anything. I will mark the palette materials in the GLB itself, with a material extras entry saying the colour and alpha are rvt-rs's rather than the file's, and document it next to the viewer's palette.

    Giving an element with no material of its own its category's material, which is what Revit's export does, is the larger fix. rvt-rs reads a category's material today only for the layers of walls, floors, roofs and ceilings that take it (RE-91, RE-115, RE-206). Extending that to ducts, pipes, light fixtures and the rest is a measured change against Revit's exports, and it belongs with #1603.

    3. Tests. Thank you for offering, but this repository does not take unit tests: CONTRIBUTING.md ("Unit tests are banned, with one exception"). That rules out a test that builds an IfcModel by hand and reads back its alpha, and one that pins the 0.45 we chose. A count of transparent materials on one project would only pin our own number.

    The check that fits here is end to end against Revit's export. tools/re/glb_material_colours_vs_ifc.py already compares each family instance's GLB colour with the surface style colour in Revit's own IFC4 export of the same file. It does not yet compare transparency. A pull request that adds 1 − alpha against Revit's IfcSurfaceStyleRendering.Transparency to that scorer would be welcome, and it would test exactly the claim you measured.

    I will link the pull request for (1) and (2) here when it is up.

  2. DrunkOnJava commented on Nov 12, 2026

    @DrunkOnJava
    Owner

    The pull request for (1) and (2) is #1818. Every GLB material now carries extras.colourSource: "file" where its colour and alpha are the Revit material's own, "rvt-rs" where rvt-rs chose them. The category palette is "rvt-rs", its translucent windows and faint rooms included. A support-matrix row states that view overrides are not read, with the revit-ifc reason. Its Measure run includes a probe on your file, rmeadvancedsampleproject 2024, counting the materials and primitives by source and translucency; I will post those counts on the pull request.

  3. DrunkOnJava commented on Nov 12, 2026

    @DrunkOnJava
    Owner

    The counts from #1818's run are in (comment), along with one change since my last note.

    The mark is now two fields. A decoded material can have its colour read and its transparency not. So extras says each separately: { "colourSource": ..., "alphaSource": ... }, each "file" or "rvt-rs".

    On your file, rmeadvancedsampleproject 2024:

    • 201 materials are file/file, 36 of them translucent.
    • 12 are rvt-rs/rvt-rs, and one of those is translucent: the palette's IFCSPACE (alpha 0.12).
    • Every translucent alpha comes either from a transparency read from the file or from the palette.

    On all 100 models the run probed, no material had its colour read and its transparency not, or the reverse. Every export is byte-identical to main's.

    The IFC side. The IFC used to write a transparency of 0 for a material whose transparency was not read, so it claimed opaque where nothing said so. #1826 leaves that attribute unset ($) instead. No measured model has such a material, and its Measure run, held-out models included, will confirm that count.

  4. DrunkOnJava commented on Nov 12, 2026

    @DrunkOnJava
    Owner

    #1826 has landed. When rvt-rs has not read a material's transparency, the IFC now leaves IfcSurfaceStyleRendering.Transparency unset ($) rather than writing 0.

    Its Measure run (43298971854) confirms the count from my last note. It covered the samples of every year, the BIM4LCA models, the R2025 set, rac_advanced and the held-out models:

    • 125 of 125 exports equal main's byte for byte;
    • no measured model has a material whose colour was read and whose transparency was not.

    So no real file measured so far shows the change. Only CI's synthetic project has such a material, and CI validates its surface style there.

    With #1818 and #1826 in, rvt-rs marks every colour and alpha it chose itself, in the GLB as data and in the IFC by leaving the value unset. The category-material fallback that Revit's export uses stays with #1603.

  5. DrunkOnJava commented on Nov 14, 2026

    @DrunkOnJava
    Owner

    Closing, since every part of this is now in a release or tracked elsewhere:

    Your offer of a transparency comparison in tools/re/glb_material_colours_vs_ifc.py (1 − alpha against Revit's IfcSurfaceStyleRendering.Transparency) still stands, if you want to send it. Thanks again for measuring it on a real project.

  6. zenglanmu commented on Nov 14, 2026

    @zenglanmu
    ContributorAuthor

    thanks for your fix, i will try it later. Btw, viewports in revit can set its own transparency alpha for certain elements (or filtered out elements) if i remember correctly. Do your have plan for this or it's already implemented

  7. DrunkOnJava commented on Nov 14, 2026

    @DrunkOnJava
    Owner

    @zenglanmu thanks for trying the fix. Per-view overrides are not implemented and not scheduled: transparency, colour, halftone and visibility set in a view, by category, element or filter, are not read, and the support matrix row view-graphics-overrides says unsupported.

    The file does declare them. Its schema has OverrideGraphicSettings, with a surfaces-transparency override among its fields, and the filter classes ParameterFilterElement and SelectionFilterElement. What is not known is where an instance sits and what it binds to. Revit's own IFC export ignores view overrides, so there is no export to measure against either.

    I opened #1973 to track it, with the first step (count the records) and what would make it measurable. If you can say what you need it for, and share a small model that is not confidential, with a view that sets a transparency override and a screenshot of that view, that gives the issue the oracle it lacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions