From dc7d9382d6e206700e2d61bab44533c93bd64450 Mon Sep 17 00:00:00 2001 From: Ma Nan Date: Fri, 1 Nov 2024 11:57:29 +0800 Subject: [PATCH] fix: slice viewer change all 3d viewports fix: eevee env light effect cycles render feat: add gamma prop to correct color from non-linear image feat: add "copy transform" node --- .../assets/Nodes/BioxelNodes_latest.blend | 4 +- bioxelnodes/blender_manifest.toml | 2 +- bioxelnodes/constants.py | 10 ++- bioxelnodes/operators/container.py | 1 + bioxelnodes/operators/io.py | 3 + bioxelnodes/operators/misc.py | 71 +++++++++++-------- pyproject.toml | 2 +- 7 files changed, 59 insertions(+), 34 deletions(-) diff --git a/bioxelnodes/assets/Nodes/BioxelNodes_latest.blend b/bioxelnodes/assets/Nodes/BioxelNodes_latest.blend index 74d16d7..864b370 100644 --- a/bioxelnodes/assets/Nodes/BioxelNodes_latest.blend +++ b/bioxelnodes/assets/Nodes/BioxelNodes_latest.blend @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1dca450cc325919624cf53467378ed8a0ca74cc1704c8f98c415a4215761f2ae -size 9323007 +oid sha256:0cce8196479019bb1696092c9d489c8de61b61b7c2b7731d35fa4b7757ac314e +size 9307196 diff --git a/bioxelnodes/blender_manifest.toml b/bioxelnodes/blender_manifest.toml index 6fac40b..07dd56b 100644 --- a/bioxelnodes/blender_manifest.toml +++ b/bioxelnodes/blender_manifest.toml @@ -1,7 +1,7 @@ schema_version = "1.0.0" id = "bioxelnodes" -version = "1.0.6" +version = "1.0.7" name = "Bioxel Nodes" tagline = "For scientific volumetric data visualization in Blender" maintainer = "Ma Nan " diff --git a/bioxelnodes/constants.py b/bioxelnodes/constants.py index 82d1897..ed6a0dd 100644 --- a/bioxelnodes/constants.py +++ b/bioxelnodes/constants.py @@ -1,6 +1,6 @@ from pathlib import Path -VERSIONS = [{"label": "Latest", "node_version": (1, 0, 6)}, +VERSIONS = [{"label": "Latest", "node_version": (1, 0, 7)}, {"label": "v0.3.x", "node_version": (0, 3, 3)}, {"label": "v0.2.x", "node_version": (0, 2, 9)}] @@ -8,7 +8,7 @@ NODE_LIB_DIRPATH = Path(Path(__file__).parent, "assets/Nodes").resolve() LATEST_NODE_LIB_PATH = lib_path = Path(NODE_LIB_DIRPATH, - "BioxelNodes_latest.blend").resolve() + "BioxelNodes_latest.blend").resolve() COMPONENT_OUTPUT_NODES = [ "CutoutByThreshold", @@ -166,6 +166,12 @@ MENU_ITEMS = [ 'name': 'ReCenter', 'description': '' }, + { + 'label': 'Copy Transform', + 'icon': 'EMPTY_AXIS', + 'name': 'CopyTransform', + 'description': '' + }, { 'label': 'Extract Transform', 'icon': 'EMPTY_AXIS', diff --git a/bioxelnodes/operators/container.py b/bioxelnodes/operators/container.py index 9dbedd9..99a474a 100644 --- a/bioxelnodes/operators/container.py +++ b/bioxelnodes/operators/container.py @@ -541,6 +541,7 @@ class ContainerProps(bpy.types.Operator): bl_label = "Change Container Properties" bl_description = "Change current ontainer properties" bl_icon = "FILE_TICK" + bl_options = {'UNDO'} scene_scale: bpy.props.FloatProperty(name="Scene Scale", soft_min=0.0001, soft_max=10.0, diff --git a/bioxelnodes/operators/io.py b/bioxelnodes/operators/io.py index 76ff2ce..6588c2b 100644 --- a/bioxelnodes/operators/io.py +++ b/bioxelnodes/operators/io.py @@ -664,6 +664,9 @@ class ImportVolumetricDataDialog(bpy.types.Operator): else: data = data.astype(np.float32) + # Gamma Correct + # data = data ** 2.2 + name = self.layer_name or "Color" if data.shape[4] == 1: data = np.repeat(data, repeats=3, axis=4) diff --git a/bioxelnodes/operators/misc.py b/bioxelnodes/operators/misc.py index 621d488..f5f7f7b 100644 --- a/bioxelnodes/operators/misc.py +++ b/bioxelnodes/operators/misc.py @@ -207,15 +207,24 @@ class SliceViewer(bpy.types.Operator): bpy.context.scene.eevee.volumetric_shadow_samples = 128 bpy.context.scene.eevee.volumetric_samples = 128 bpy.context.scene.eevee.volumetric_ray_depth = 1 + + bpy.context.scene.eevee.use_shadows = False bpy.context.scene.eevee.use_volumetric_shadows = False - for area in bpy.context.screen.areas: - if area.type == 'VIEW_3D': - area.spaces[0].shading.type = 'MATERIAL' - area.spaces[0].shading.studio_light = 'studio.exr' - area.spaces[0].shading.studiolight_intensity = 2.5 - area.spaces[0].shading.use_scene_lights = False - area.spaces[0].shading.use_scene_world = False + view_3d = None + if context.area.type == 'VIEW_3D': + view_3d = context.area + else: + for area in context.screen.areas: + if area.type == 'VIEW_3D': + view_3d = area + break + if view_3d: + view_3d.spaces[0].shading.type = 'MATERIAL' + view_3d.spaces[0].shading.studio_light = 'studio.exr' + view_3d.spaces[0].shading.studiolight_intensity = 1.5 + view_3d.spaces[0].shading.use_scene_lights = False + view_3d.spaces[0].shading.use_scene_world = False return {'FINISHED'} @@ -282,29 +291,35 @@ class AddEeveeEnv(bpy.types.Operator): bl_description = "To make volume shadow less dark" def execute(self, context): - bpy.ops.object.light_add( - type='POINT', align='WORLD', location=(0, 0, 0), scale=(1, 1, 1)) - light_obj = bpy.context.active_object - light_obj.name = "EeveeEnv" - light_obj.data.shadow_soft_size = 100 - light_obj.data.energy = 1e+06 - light_obj.data.color = (0.1, 0.1, 0.1) - light_obj.data.use_shadow = False - light_obj.data.diffuse_factor = 0 - light_obj.data.specular_factor = 0 - light_obj.data.transmission_factor = 0 - light_obj.hide_select = True - light_obj.lock_location[0] = True - light_obj.lock_location[1] = True - light_obj.lock_location[2] = True - light_obj.lock_rotation[0] = True - light_obj.lock_rotation[1] = True - light_obj.lock_rotation[2] = True - light_obj.lock_scale[0] = True - light_obj.lock_scale[1] = True - light_obj.lock_scale[2] = True + bpy.ops.wm.append( + directory=f"{str(LATEST_NODE_LIB_PATH)}/Object", + filename="EeveeEnv" + ) + # bpy.ops.object.light_add( + # type='POINT', align='WORLD', location=(0, 0, 0), scale=(1, 1, 1)) + # light_obj = bpy.context.active_object + # light_obj.name = "EeveeEnv" + # light_obj.data.shadow_soft_size = 100 + # light_obj.data.energy = 1e+06 + # light_obj.data.color = (0.1, 0.1, 0.1) + # light_obj.data.use_shadow = False + # light_obj.data.diffuse_factor = 0 + # light_obj.data.specular_factor = 0 + # light_obj.data.transmission_factor = 0 + # light_obj.hide_select = True + # light_obj.lock_location[0] = True + # light_obj.lock_location[1] = True + # light_obj.lock_location[2] = True + # light_obj.lock_rotation[0] = True + # light_obj.lock_rotation[1] = True + # light_obj.lock_rotation[2] = True + # light_obj.lock_scale[0] = True + # light_obj.lock_scale[1] = True + # light_obj.lock_scale[2] = True + + bpy.context.scene.eevee.use_shadows = True bpy.context.scene.eevee.use_volumetric_shadows = True return {'FINISHED'} diff --git a/pyproject.toml b/pyproject.toml index fd165cd..0744eeb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "bioxelnodes" -version = "1.0.6" +version = "1.0.7" description = "" authors = ["Ma Nan "] license = "MIT"