diff --git a/kubric/__init__.py b/kubric/__init__.py index 6c5db4ae..31c29a55 100644 --- a/kubric/__init__.py +++ b/kubric/__init__.py @@ -38,6 +38,7 @@ from kubric.core.lights import DirectionalLight from kubric.core.lights import PointLight from kubric.core.lights import RectAreaLight +from kubric.core.lights import SpotLight from kubric.core.materials import Material from kubric.core.materials import UndefinedMaterial diff --git a/kubric/core/lights.py b/kubric/core/lights.py index d4bd7899..c98cc0d4 100644 --- a/kubric/core/lights.py +++ b/kubric/core/lights.py @@ -13,6 +13,7 @@ # limitations under the License. """Kubric lights module.""" +import numpy as np import traitlets as tl from kubric.core import traits as ktl @@ -31,6 +32,11 @@ def get_background_default(self): return True +class SpotLight(Light): + spot_blend = tl.Float(1.) + spot_size = tl.Float(np.pi / 4) + + class UndefinedLight(Light, UndefinedAsset): pass diff --git a/kubric/renderer/blender.py b/kubric/renderer/blender.py index 6e83c118..fc09d2e6 100644 --- a/kubric/renderer/blender.py +++ b/kubric/renderer/blender.py @@ -474,6 +474,24 @@ def _add_asset(self, obj: core.DirectionalLight): # pylint: disable=function-re obj.observe(KeyframeSetter(sun, "energy"), "intensity", type="keyframe") return sun_obj + #@add_asset.register(core.SpotLight) # I think these are needed... ~MrX + #@blender_utils.prepare_blender_object + def _add_asset(self, obj: core.SpotLight): # pylint: disable=function-redefined + spotlight = bpy.data.lights.new(obj.uid, "SPOT") + spotlight_obj = bpy.data.objects.new(obj.uid, core.SpotLight) + + register_object3d_setters(obj, spotlight_obj) + obj.observe(AttributeSetter(spotlight, "color"), "color") + obj.observe(KeyframeSetter(spotlight, "color"), "color", type="keyframe") + obj.observe(AttributeSetter(spotlight, "energy"), "intensity") + obj.observe(KeyframeSetter(spotlight, "energy"), "intensity", type="keyframe") + obj.observe(AttributeSetter(spotlight, "spot_blend"), "spot_blend") + obj.observe(KeyframeSetter(spotlight, "spot_blend"), "spot_blend", type="keyframe") + obj.observe(AttributeSetter(spotlight, "spot_size"), "spot_size") + obj.observe(KeyframeSetter(spotlight, "spot_size"), "spot_size", type="keyframe") + return spotlight_obj + + @add_asset.register(core.RectAreaLight) @blender_utils.prepare_blender_object def _add_asset(self, obj: core.RectAreaLight): diff --git a/shapenet2kubric/convert.py b/shapenet2kubric/convert.py index 8c6ad112..1444eb0a 100644 --- a/shapenet2kubric/convert.py +++ b/shapenet2kubric/convert.py @@ -296,7 +296,7 @@ def stage5(object_folder: Path, logger=_DEFAULT_LOGGER): tar.add(object_folder / 'kubric' / 'collision_geometry.obj', arcname='collision_geometry.obj') tar.add(object_folder / 'kubric' / 'model_watertight.obj', - arcname='collision_geometry.obj') + arcname='model_watertight.obj') tar.add(object_folder / 'kubric' / 'object.urdf', arcname='object.urdf') tar.add(object_folder / 'kubric' / 'data.json',