Title: Bonsai: linked IFC models render white in Material Preview / Rendered (link cache only sets diffuse_color) and purposed fix · Issue #10140 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Bonsai: linked IFC models render white in Material Preview / Rendered (link cache only sets diffuse_color) and purposed fix · Issue #10140 · IfcOpenShell/IfcOpenShell
X Title: Bonsai: linked IFC models render white in Material Preview / Rendered (link cache only sets diffuse_color) and purposed fix · Issue #10140 · IfcOpenShell/IfcOpenShell
Description: Bug Description Bonsai / Blender: 0.9.0-post1 / 5.2 LTS (Windows). Same code on the v0.8.0 branch today. What happens Linking an IFC (Project > Links > Link IFC) shows the correct colours in Solid view, but every material is white in Mat...
Open Graph Description: Bug Description Bonsai / Blender: 0.9.0-post1 / 5.2 LTS (Windows). Same code on the v0.8.0 branch today. What happens Linking an IFC (Project > Links > Link IFC) shows the correct colours in Solid ...
X Description: Bug Description Bonsai / Blender: 0.9.0-post1 / 5.2 LTS (Windows). Same code on the v0.8.0 branch today. What happens Linking an IFC (Project > Links > Link IFC) shows the correct colours in ...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/10140
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bonsai: linked IFC models render white in Material Preview / Rendered (link cache only sets diffuse_color) and purposed fix","articleBody":"### Bug Description\n\n**Bonsai / Blender:** 0.9.0-post1 / 5.2 LTS (Windows). Same code on the v0.8.0 branch today.\n\n### What happens\nLinking an IFC (Project > Links > Link IFC) shows the correct colours in Solid view, but every material is\nwhite in Material Preview and Rendered (EEVEE and Cycles). Opening the same IFC normally renders in colour.\nThis makes linked models unusable for rendering, which is where linking helps most for big files.\n\n### Steps\n1. Link any IFC with coloured surface styles (Project > Links > Link IFC).\n2. Switch the viewport to Material Preview or render.\n3. Everything is white. In the `.ifc.cache.blend`, each material's `diffuse_color` is right but its\n Principled BSDF Base Color is the default 0.8 grey/white.\n\n### Cause\n`LoadLinkedProject` creates the cache materials with only the viewport colour:\n\n- `execute()` > `process_chunk()`: `bpy.data.materials.new(\"Chunk\")` + `blender_mat.diffuse_color = mat`\n- `process_occurrence()`: `bpy.data.materials.new(material_name)` + `blender_mat.diffuse_color = diffuse`\n\nIn Blender 5.x `materials.new()` comes with a Principled BSDF (checked on 5.2), and nothing sets its Base Color.\nTransparency is also only in the viewport alpha, so glass renders opaque.\n\n### Suggested fix\nSmall helper used at both places, so the shader matches the viewport colour (diff attached, ~20 lines,\nformatted with black -l 120):\n\n```python\ndef create_flat_material(self, name: str, rgba: tuple[float, ...]) -> bpy.types.Material:\n \"\"\"Material whose shader matches its viewport colour, so linked models render in colour.\"\"\"\n material = bpy.data.materials.new(name)\n material.diffuse_color = rgba\n if material.node_tree:\n bsdf = next((n for n in material.node_tree.nodes if n.type == \"BSDF_PRINCIPLED\"), None)\n if bsdf:\n bsdf.inputs[\"Base Color\"].default_value = (*rgba[:3], 1.0)\n bsdf.inputs[\"Alpha\"].default_value = rgba[3]\n if rgba[3] \u003c 1.0:\n material.surface_render_method = \"BLENDED\"\n return material\n```\n\nI've tested the same logic on real link caches: a fresh link of a 1,290-object model gave 61 cache\nmaterials, all rendering with their Solid-view colour afterwards (before/after Cycles render attached).\nIn the meantime I'm using a small add-on that applies it in a `save_pre` handler when the cache is saved.\n\n### Possibly worth a follow-up\n- Cache materials are deduplicated by colour, so different IFC styles with the same colour (e.g. \"Glass\" and\n \"reglit\") become one material, and the names become `Chunk` / `r-g-b-a`. Keeping the style name (or\n deduplicating by style id) would let users swap linked materials for render materials by name.\n- The colours arrive gamma-adjusted from the iterator (an IFC value of 0.44 becomes 0.194, i.e. squared).\n Just noting it in case it isn't intended.\n\nHappy to open a PR with this if it's the right direction.\n\n*Disclosure (per AGENTS.md): the investigation, the suggested code and the workaround add-on were written\nwith the assistance of an AI coding tool; I've reviewed and tested them.*\n\n### Attachments\n\n_No response_\n\n### Debug and Error Output\n\n```true\n\n```","author":{"url":"https://github.com/sir306","@type":"Person","name":"sir306"},"datePublished":"2026-11-05T23:50:51Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/10140"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:18cc3fe2-d213-bc58-a813-b291db5b3aff |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B728:17C468:30877:4313C:6B04617B |
| html-safe-nonce | 176f7cba97fe9ced8170c6ef52b3fe135e2e539017f2f20a1624ba69bfa77b31 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzI4OjE3QzQ2ODozMDg3Nzo0MzEzQzo2QjA0NjE3QiIsInZpc2l0b3JfaWQiOiI1MjQ1MzYxNTQyNjgzOTM4NTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f1b95078fed91eb53ffd8cf4d61caa5457f7ce5909667448676e0cf2bf6aa49d |
| hovercard-subject-tag | issue:6233790727 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/IfcOpenShell/IfcOpenShell/10140/issue_layout |
| twitter:image | https://opengraph.githubassets.com/84212e99a5b3e58af43a2309d8c067d25c03eca8d0932225fd2ebf5ee4afa7a4/IfcOpenShell/IfcOpenShell/issues/10140 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/84212e99a5b3e58af43a2309d8c067d25c03eca8d0932225fd2ebf5ee4afa7a4/IfcOpenShell/IfcOpenShell/issues/10140 |
| og:image:alt | Bug Description Bonsai / Blender: 0.9.0-post1 / 5.2 LTS (Windows). Same code on the v0.8.0 branch today. What happens Linking an IFC (Project > Links > Link IFC) shows the correct colours in Solid ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sir306 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2d58451b4bcb73c33c67bfb6b28fb75fe6d5e279daf9b560fa4fd832f3d8c9a6 |
| turbo-cache-control | no-preview |
| go-import | github.com/IfcOpenShell/IfcOpenShell git https://github.com/IfcOpenShell/IfcOpenShell.git |
| octolytics-dimension-user_id | 13692563 |
| octolytics-dimension-user_login | IfcOpenShell |
| octolytics-dimension-repository_id | 40473201 |
| octolytics-dimension-repository_nwo | IfcOpenShell/IfcOpenShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 40473201 |
| octolytics-dimension-repository_network_root_nwo | IfcOpenShell/IfcOpenShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 03e114520787ad27289207f153520ef97461127c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width