Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding SpotLight to Lighting kit #219

Merged
merged 6 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kubric/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions kubric/core/lights.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ def get_background_default(self):
return True


class SpotLight(Light):
spot_blend = tl.Float(1.)
spot_size = tl.Float(*(0.00, 180.00))
MrXandbadas marked this conversation as resolved.
Show resolved Hide resolved


class UndefinedLight(Light, UndefinedAsset):
pass

Expand Down
16 changes: 16 additions & 0 deletions kubric/renderer/blender.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,22 @@ def _add_asset(self, obj: core.DirectionalLight): # pylint: disable=function-re
obj.observe(KeyframeSetter(sun, "energy"), "intensity", type="keyframe")
return sun_obj

def _add_asset(self, obj: core.SpotLight): # pylint: disable=function-redefined
SpotLight = bpy.data.lights.new(obj.uid, "SPOT")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: lowercase variable names please (snake case)

SpotLight_obj = bpy.data.objects.new(obj.uid, 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):
Expand Down