Skip to content

Commit

Permalink
fix some of the issues with camera motion blur (LuxCoreRender#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Theverat committed Jan 14, 2018
1 parent c8abacc commit 97469e4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion doc/luxcore_api_tips.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
When one property of a key is set, all other (previously defined) properties of the key will be deleted.
Example:
Let"s say we have set the following properties:
Let's say we have set the following properties:
```
props.Set(pyluxcore.Property("scene.materials.test.type", "matte"))
props.Set(pyluxcore.Property("scene.materials.test.kd", [0.7, 0.7, 0.7]))
Expand Down
2 changes: 2 additions & 0 deletions export/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ def create_session(self, engine, scene, context=None):

if enabled and blur_settings.shutter > 0:
motion_blur_props = motion_blur.convert(context, scene, objs, self.exported_objects)
if camera_blur:
motion_blur_props.Set(camera_props)
scene_props.Set(motion_blur_props)

# World
Expand Down
29 changes: 15 additions & 14 deletions export/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def convert(scene, context=None):
_clipping_plane(scene, definitions)
_motion_blur(scene, definitions, context)

return utils.create_props(prefix, definitions)
p = utils.create_props(prefix, definitions)
print(p)
return p
except Exception as error:
msg = 'Camera: %s' % error
scene.luxcore.errorlog.add_warning(msg)
Expand Down Expand Up @@ -207,21 +209,20 @@ def _motion_blur(scene, definitions, context):
return

# TODO why does this not work as expected?
# definitions["shutteropen"] = -moblur_settings.shutter * 0.5
# definitions["shutterclose"] = moblur_settings.shutter * 0.5
definitions["shutteropen"] = -moblur_settings.shutter * 0.5
definitions["shutterclose"] = moblur_settings.shutter * 0.5

# # Don't export camera blur in viewport render
# if moblur_settings.camera_blur and not context and motion_blur.is_camera_moving(context, scene):
# # Make sure lookup is defined - this function should be the last to modify it
# assert "lookat.orig" in definitions
# assert "lookat.target" in definitions
# assert "up" in definitions
# # Reset lookat - it's handled by motion.x.transformation
# # TODO: seems like this is not needed - why?
# definitions["lookat.orig"] = [0, 0, 0]
# definitions["lookat.target"] = [0, 0, -1]
# definitions["up"] = [0, 1, 0]
# # Note: camera motion system is defined in export/motion_blur.py
if moblur_settings.camera_blur and not context and motion_blur.is_camera_moving(context, scene):
# Make sure lookup is defined - this function should be the last to modify it
assert "lookat.orig" in definitions
assert "lookat.target" in definitions
assert "up" in definitions
# Reset lookat - it's handled by motion.x.transformation
definitions["lookat.orig"] = [0, 0, 0]
definitions["lookat.target"] = [0, 0, -1]
definitions["up"] = [0, 1, 0]
# Note: camera motion system is defined in export/motion_blur.py


def _calc_lookat(cam_matrix):
Expand Down
11 changes: 7 additions & 4 deletions export/motion_blur.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def convert(context, scene, objects, exported_objects):
"motion.%d.transformation" % step: transformation,
}
props.Set(utils.create_props(prefix, definitions))
print(props)

return props

Expand Down Expand Up @@ -77,11 +78,13 @@ def _get_matrices(context, scene, steps, times, objects=None, exported_objects=N
_append_object_matrices(objects, exported_objects, matrices, step)

if motion_blur.camera_blur and not context:
matrix = scene.camera.matrix_world.copy()
matrix = scene.camera.matrix_world.inverted()

# TODO: This is so stupid. I have no idea what I'm doing
rotate = Matrix.Rotation(math.radians(180), 4, "X")
scale = Matrix.Scale(-1, 4, (0, 1, 0))
matrix = matrix * rotate * scale
# rotate = Matrix.Rotation(math.radians(180), 4, "X")
# scale = Matrix.Scale(-1, 4, (0, 1, 0))
# matrix = matrix * rotate * scale

prefix = "scene.camera."
_append_matrix(matrices, prefix, matrix, step)
print("appended camera matrix")
Expand Down

0 comments on commit 97469e4

Please sign in to comment.