From a48d014541e2d497499265855abf077b53d67ba5 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Tue, 2 Jan 2024 13:30:49 -0300 Subject: [PATCH] [Blender Export][Adde] Option to disable the denoiser - Enables the use of old hardware and Debian packages - You must be extremelly patient Closes #539 --- CHANGELOG.md | 1 + docs/samples/generic_plot.kibot.yaml | 3 +++ docs/source/configuration/outputs/blender_export.rst | 2 ++ kibot/blender_scripts/blender_export.py | 4 ++++ kibot/out_blender_export.py | 5 +++++ 5 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42cc6f99..361dd2ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Camera option to set the clip start (#484) - Traceback dump when Blender output contains it - Subdirectory for each output generated (#541) + - Option to disable the denoiser (#539) - KiKit - Expand text variables and KiBot %X markers in text objects (see #497) - PCB Print: diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index 04e4d76a..8487fbee 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -265,6 +265,9 @@ outputs: # [string='#CCCCE5'] Second color for the background gradient background2: '#CCCCE5' # `height` is an alias for `resolution_y` + # [boolean=false] Used to disable the render denoiser on old hardware, or when the functionality isn't compiled. + # Note that the impact in quality is huge, you should increase the amount of samples 10 times + no_denoiser: false # [number=1280] Width of the image resolution_x: 1280 # [number=720] Height of the image diff --git a/docs/source/configuration/outputs/blender_export.rst b/docs/source/configuration/outputs/blender_export.rst index d894b46f..56940ed2 100644 --- a/docs/source/configuration/outputs/blender_export.rst +++ b/docs/source/configuration/outputs/blender_export.rst @@ -97,6 +97,8 @@ Parameters: - ``background1`` :index:`: ` [string='#66667F'] First color for the background gradient. - ``background2`` :index:`: ` [string='#CCCCE5'] Second color for the background gradient. - *height* :index:`: ` Alias for resolution_y. + - ``no_denoiser`` :index:`: ` [boolean=false] Used to disable the render denoiser on old hardware, or when the functionality isn't compiled. + Note that the impact in quality is huge, you should increase the amount of samples 10 times. - ``resolution_x`` :index:`: ` [number=1280] Width of the image. - ``resolution_y`` :index:`: ` [number=720] Height of the image. - *width* :index:`: ` Alias for resolution_x. diff --git a/kibot/blender_scripts/blender_export.py b/kibot/blender_scripts/blender_export.py index a55fec15..86e7f257 100644 --- a/kibot/blender_scripts/blender_export.py +++ b/kibot/blender_scripts/blender_export.py @@ -370,6 +370,8 @@ def main(): parser.add_argument("-m", "--pcb_material", type=str, choices=["RASTERIZED", "3D"], default="RASTERIZED", help="Rasterized (Cycles) or 3D (deprecated) [RASTERIZED]") parser.add_argument("-M", "--dont_merge_materials", action="store_false", help="do not merge materials") + parser.add_argument("-n", "--no_denoiser", action="store_true", + help="Disable the denoiser (poor quality, increase passes)") parser.add_argument("-o", "--output", type=str, required=True, nargs='+', help="output file name, can be repeated") parser.add_argument("-r", "--scene", type=str, help="JSON file containing camera, light and render options") parser.add_argument("-s", "--solder_joints", type=str, choices=["NONE", "SMART", "ALL"], default="SMART", @@ -408,6 +410,8 @@ def main(): del ops["center_pcb"] ops["center_boards"] = args.dont_center bpy.ops.pcb2blender.import_pcb3d(**ops) + if args.no_denoiser: + bpy.context.scene.cycles.use_denoising = False # Apply the scene first scene c_views = apply_start_scene(args.scene) c_formats = len(args.format) diff --git a/kibot/out_blender_export.py b/kibot/out_blender_export.py index 9314a657..617539d4 100644 --- a/kibot/out_blender_export.py +++ b/kibot/out_blender_export.py @@ -197,6 +197,9 @@ class BlenderRenderOptions(Optionable): self.auto_crop = False """ When enabled the image will be post-processed to remove the empty space around the image. In this mode the `background2` is changed to be the same as `background1` """ + self.no_denoiser = False + """ Used to disable the render denoiser on old hardware, or when the functionality isn't compiled. + Note that the impact in quality is huge, you should increase the amount of samples 10 times """ self._unknown_is_error = True @@ -634,6 +637,8 @@ class Blender_ExportOptions(BaseOptions): cmd.extend(['--solder_joints', pi.solder_joints]) if not pi.stack_boards: cmd.append('--dont_stack_boards') + if self.render_options.no_denoiser: + cmd.append('--no_denoiser') cmd.append('--format') for pov in self.point_of_view: for _ in range(pov.steps):