Blenderproc: SurfaceLighting throws an error when setting the emission color

Created on 21 Jun 2021  路  2Comments  路  Source: DLR-RM/BlenderProc

When using the SurfaceLighting module to apply a random emission color it throws an error.

I'm using this configuration:

{
  "module": "lighting.SurfaceLighting",
  "config": {
    "selector": {
      "provider": "getter.Entity",
      "conditions": {
        "name": "Ceiling",
      },
    },
    "emission_strength": 10.,
    "emission_color": {
      "provider": "sampler.Color",
      "min": [0.3, 0.3, 0.3, 1.0],
      "max": [1.0, 1.0, 1.0, 1.0]
    },
  }
}

and this is the error:

Traceback (most recent call last):
  File "/home/federico/repos/BlenderProc/src/run.py", line 44, in <module>
    pipeline = Pipeline(config_path, argv[2:], working_dir, temp_dir)
  File "/home/federico/repos/BlenderProc/src/main/Pipeline.py", line 36, in __init__
    self.modules = Utility.initialize_modules(config["modules"])
  File "/home/federico/repos/BlenderProc/src/utility/Utility.py", line 99, in initialize_modules
    modules.append(module_class(Config(config)))
  File "/home/federico/repos/BlenderProc/src/lighting/SurfaceLighting.py", line 46, in __init__
    self.emission_color = self.config.get_vector3d("emission_color", None)
  File "/home/federico/repos/BlenderProc/src/utility/Config.py", line 242, in get_vector3d
    return self.get_vector(name, fallback, 3)
  File "/home/federico/repos/BlenderProc/src/utility/Config.py", line 213, in get_vector
    raise TypeError(str(value) + "' must have exactly " + str(dimensions) + " dimensions!")
TypeError: [0.3139297366142273, 0.8560619950294495, 0.8377216458320618, 1.0]' must have exactly 3 dimensions!

I tried changing the configuration to this:

{
  "module": "lighting.SurfaceLighting",
  "config": {
    "selector": {
      "provider": "getter.Entity",
      "conditions": {
        "name": "Ceiling",
      },
    },
    "emission_strength": 10.,
    "emission_color": {
      "provider": "sampler.Uniform3d",
      "min": [0.3, 0.3, 0.3],
      "max": [1.0, 1.0, 1.0]
    },
  }
}

but it throws another error:

Traceback (most recent call last):
  File "/home/federico/repos/BlenderProc/src/run.py", line 45, in <module>
    pipeline.run()
  File "/home/federico/repos/BlenderProc/src/main/Pipeline.py", line 43, in run
    module.run()
  File "/home/federico/repos/BlenderProc/src/lighting/SurfaceLighting.py", line 55, in run
    self.add_emission_to_materials(objects)
  File "/home/federico/repos/BlenderProc/src/lighting/SurfaceLighting.py", line 88, in add_emission_to_materials
    material.make_emissive(emission_strength=self.emission_strength, emission_color=self.emission_color, keep_using_base_color=self.keep_using_base_color)
  File "/home/federico/repos/BlenderProc/src/utility/MaterialUtility.py", line 172, in make_emissive
    emission_node.inputs["Color"].default_value = emission_color
ValueError: bpy_struct: item.attr = val: sequences of dimension 0 should contain 4 items, not 3

Eventually I fixed it by changing

https://github.com/DLR-RM/BlenderProc/blob/8bc933868c2284982ad2aa091358429c02d8842d/src/lighting/SurfaceLighting.py#L46

into

self.emission_color = self.config.get_vector4d("emission_color", None)

and using the first configuration i posted.

bug model_issue

All 2 comments

Hey,

awesome issue! Thanks you explained the problem and already found the solution!

We will integrate your fix into BlenderProc!

Thanks again.

Best,
Max

Hey,

this is now fixed with version 1.12.0. Thanks again!

Best regards,
Max

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hummat picture hummat  路  5Comments

soans1994 picture soans1994  路  5Comments

manuelli picture manuelli  路  3Comments

Lotfi-MERAD picture Lotfi-MERAD  路  3Comments

soans1994 picture soans1994  路  3Comments