Skip to content

Commit

Permalink
Merge pull request #788 from DLR-RM/iss_blender_3.4.1
Browse files Browse the repository at this point in the history
feat(blender): Updates to blender 3.5.1
  • Loading branch information
cornerfarmer authored Oct 18, 2023
2 parents c0d689b + f63006b commit b519573
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 4 deletions.
2 changes: 1 addition & 1 deletion blenderproc/api/renderer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set_cpu_threads, toggle_stereo, set_simplify_subdivision_render, set_noise_threshold, \
set_max_amount_of_samples, enable_distance_output, enable_depth_output, enable_normals_output, \
enable_diffuse_color_output, map_file_format_to_file_ending, render, set_output_format, enable_motion_blur, \
enable_segmentation_output, set_world_background, set_render_devices, enable_experimental_features
enable_segmentation_output, set_world_background, set_render_devices, enable_experimental_features, toggle_light_tree
from blenderproc.python.renderer.SegMapRendererUtility import render_segmap
from blenderproc.python.renderer.FlowRendererUtility import render_optical_flow
from blenderproc.python.renderer.NOCSRendererUtility import render_nocs
4 changes: 4 additions & 0 deletions blenderproc/python/loader/Front3DLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ def load_furniture_objs(data: dict, future_model_path: str, lamp_light_strength:
# => Reset the emission color
principled_node.inputs["Emission"].default_value[:3] = [0, 0, 0]

# Front3d .mtl files use Tf incorrectly, they make all materials fully transmissive
# Revert that:
principled_node.inputs["Transmission"].default_value = 0

# For each a texture node
image_node = mat.new_node('ShaderNodeTexImage')
# and load the texture.png
Expand Down
10 changes: 10 additions & 0 deletions blenderproc/python/renderer/RendererUtility.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ def toggle_stereo(enable: bool):
if enable:
bpy.context.scene.render.views_format = "STEREO_3D"

def toggle_light_tree(enable: bool):
""" Enables/Disables blender's light tree for rendering.
Enabling the light tree reduces the noise in scenes with many point lights,
however it increases the render time per sample.
See https://wiki.blender.org/wiki/Reference/Release_Notes/3.5/Cycles
:param enable: True, if light tree should be enabled.
"""
bpy.context.scene.cycles.use_light_tree = enable

def set_simplify_subdivision_render(simplify_subdivision_render: int):
""" Sets global maximum subdivision level during rendering to speedup rendering.
Expand Down
21 changes: 21 additions & 0 deletions blenderproc/python/types/LightUtility.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self, light_type: str = "POINT", name: str = "light", blender_obj:
light_obj = bpy.data.objects.new(name=name, object_data=light_data)
bpy.context.collection.objects.link(light_obj)
super().__init__(light_obj)
self.set_radius(0.25)
else:
super().__init__(blender_obj)

Expand All @@ -46,6 +47,16 @@ def set_energy(self, energy: float, frame: Optional[int] = None):
self.blender_obj.data.energy = energy
Utility.insert_keyframe(self.blender_obj.data, "energy", frame)

def set_radius(self, radius: float, frame: Optional[int] = None):
""" Sets the radius / shadow_soft_size of the light.
:param radius: Light size for ray shadow sampling (Raytraced shadows).
:param frame: The frame number which the value should be set to. If None is given, the current
frame number is used.
"""
self.blender_obj.data.shadow_soft_size = radius
Utility.insert_keyframe(self.blender_obj.data, "shadow_soft_size", frame)

def set_color(self, color: Union[list, Color], frame: Optional[int] = None):
""" Sets the color of the light.
Expand Down Expand Up @@ -191,6 +202,16 @@ def get_energy(self, frame: Optional[int] = None) -> float:
with KeyFrame(frame):
return self.blender_obj.data.energy

def get_radius(self, frame: Optional[int] = None) -> float:
""" Returns the radius / shadow_soft_size of the light.
:param frame: The frame number which the value should be set to. If None is given, the current
frame number is used.
:return: The radius at the specified frame.
"""
with KeyFrame(frame):
return self.blender_obj.data.shadow_soft_size

def get_color(self, frame: Optional[int] = None) -> Color:
""" Returns the RGB color of the light.
Expand Down
2 changes: 1 addition & 1 deletion blenderproc/python/utility/DefaultConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class DefaultConfig:

# Setup
default_pip_packages = ["wheel", "pyyaml==5.1.2", "imageio==2.9.0", "gitpython==3.1.18",
"scikit-image==0.19.2", "pypng==0.0.20", "scipy==1.7.3", "matplotlib==3.5.1",
"scikit-image==0.19.2", "pypng==0.0.20", "scipy==1.11.3", "matplotlib==3.5.1",
"pytz==2021.1", "h5py==3.6.0", "Pillow==8.3.2", "opencv-contrib-python==4.5.5.64",
"scikit-learn==1.0.2", "python-dateutil==2.8.2", "rich==12.6.0", "trimesh==3.21.5",
"pyrender==0.1.45"]
2 changes: 2 additions & 0 deletions blenderproc/python/utility/Initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ def set_default_parameters():
# cpu thread means GPU-only rendering)
RendererUtility.set_cpu_threads(0)
RendererUtility.set_denoiser(DefaultConfig.denoiser)
# For now disable the light tree per default, as it seems to increase render time for most of our tests
RendererUtility.toggle_light_tree(False)

RendererUtility.set_simplify_subdivision_render(DefaultConfig.simplify_subdivision_render)

Expand Down
4 changes: 2 additions & 2 deletions blenderproc/python/utility/InstallUtility.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def make_sure_blender_is_installed(custom_blender_path: str, blender_install_pat
blender_install_path = "blender"

# Determine configured version
# right new only support blender-3.3.1
major_version = "3.3"
# right new only support blender-3.5.1
major_version = "3.5"
minor_version = "1"
blender_version = f"blender-{major_version}.{minor_version}"
if platform in ["linux", "linux2"]:
Expand Down

0 comments on commit b519573

Please sign in to comment.