Skip to content

Commit

Permalink
Merge pull request #1170 from hummat/add_output_format_options
Browse files Browse the repository at this point in the history
feat(render): add additional rendering parameters to set_output_format
  • Loading branch information
cornerfarmer authored Dec 12, 2024
2 parents 3b0002a + f2123e4 commit 1f09fe4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
14 changes: 12 additions & 2 deletions blenderproc/python/renderer/RendererUtility.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,15 +731,19 @@ def render(output_dir: Optional[str] = None, file_prefix: str = "rgb_", output_k

def set_output_format(file_format: Optional[str] = None, color_depth: Optional[int] = None,
enable_transparency: Optional[bool] = None, jpg_quality: Optional[int] = None,
view_transform: Optional[str] = None):
view_transform: Optional[str] = None, look: Optional[str] = None,
exposure: Optional[float] = None, gamma: Optional[float] = None):
""" Sets the output format to use for rendering. Default values defined in DefaultConfig.py.
:param file_format: The file format to use, e.q. "PNG", "JPEG" or "OPEN_EXR".
:param color_depth: The color depth.
:param enable_transparency: If true, the output will contain a alpha channel and the background will be
set transparent.
:param jpg_quality: The quality to use, if file format is set to "JPEG".
:param view_transform: View transform of the rendered output.
:param view_transform: View transform used when converting image to display space.
:param look: Additional transform applied before view transform for artistic needs.
:param exposure: Exposure (stops) applied before display transform.
:param gamma: Amount of gamma modification applied after display transform.
"""
if enable_transparency is not None:
# In case a previous renderer changed these settings
Expand All @@ -756,6 +760,12 @@ def set_output_format(file_format: Optional[str] = None, color_depth: Optional[i
bpy.context.scene.render.image_settings.quality = jpg_quality
if view_transform is not None:
bpy.context.scene.view_settings.view_transform = view_transform
if look is not None:
bpy.context.scene.view_settings.look = look
if exposure is not None:
bpy.context.scene.view_settings.exposure = exposure
if gamma is not None:
bpy.context.scene.view_settings.gamma = gamma


def enable_motion_blur(motion_blur_length: float = 0.5, rolling_shutter_type: str = "NONE",
Expand Down
3 changes: 3 additions & 0 deletions blenderproc/python/utility/DefaultConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class DefaultConfig:
antialiasing_distance_max = 10000
world_background = [0.05, 0.05, 0.05]
view_transform = "Filmic"
look = None
exposure = 0.0
gamma = 1.0

# Setup
default_pip_packages = ["wheel", "pyyaml==6.0.1", "imageio==2.34.1", "gitpython==3.1.43",
Expand Down
5 changes: 4 additions & 1 deletion blenderproc/python/utility/Initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ def set_default_parameters():
DefaultConfig.color_depth,
DefaultConfig.enable_transparency,
DefaultConfig.jpg_quality,
DefaultConfig.view_transform)
DefaultConfig.view_transform,
DefaultConfig.look,
DefaultConfig.exposure,
DefaultConfig.gamma)

@staticmethod
def remove_all_data(remove_camera: bool = True):
Expand Down

0 comments on commit 1f09fe4

Please sign in to comment.