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
into
self.emission_color = self.config.get_vector4d("emission_color", None)
and using the first configuration i posted.
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