From a5aa970977b03bd1e4b88f6de948a8121619ddd6 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 19 Oct 2022 09:37:22 +1100 Subject: [PATCH] Add support for normalised ratio diffuse colours. See #2509. --- src/blenderbim/blenderbim/bim/import_ifc.py | 22 ++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/import_ifc.py b/src/blenderbim/blenderbim/bim/import_ifc.py index daf9465454..3018e3e2e3 100644 --- a/src/blenderbim/blenderbim/bim/import_ifc.py +++ b/src/blenderbim/blenderbim/bim/import_ifc.py @@ -1473,13 +1473,21 @@ class IfcImporter: if surface_style.ReflectanceMethod in ["PHYSICAL", "NOTDEFINED"]: blender_material.use_nodes = True bsdf = blender_material.node_tree.nodes["Principled BSDF"] - if surface_style.DiffuseColour and surface_style.DiffuseColour.is_a("IfcColourRgb"): - bsdf.inputs["Base Color"].default_value = ( - surface_style.DiffuseColour.Red, - surface_style.DiffuseColour.Green, - surface_style.DiffuseColour.Blue, - 1, - ) + if surface_style.DiffuseColour: + if surface_style.DiffuseColour.is_a("IfcColourRgb"): + bsdf.inputs["Base Color"].default_value = ( + surface_style.DiffuseColour.Red, + surface_style.DiffuseColour.Green, + surface_style.DiffuseColour.Blue, + 1, + ) + elif surface_style.DiffuseColour.is_a("IfcNormalisedRatioMeasure"): + bsdf.inputs["Base Color"].default_value = ( + surface_style.SurfaceColour.Red * surface_style.DiffuseColour.wrappedValue, + surface_style.SurfaceColour.Green * surface_style.DiffuseColour.wrappedValue, + surface_style.SurfaceColour.Blue * surface_style.DiffuseColour.wrappedValue, + 1, + ) if surface_style.SpecularColour and surface_style.SpecularColour.is_a("IfcNormalisedRatioMeasure"): bsdf.inputs["Metallic"].default_value = surface_style.SpecularColour.wrappedValue if surface_style.SpecularHighlight and surface_style.SpecularHighlight.is_a("IfcSpecularRoughness"):