Skip to content

Commit 134d8e3

Browse files
committed
feat: support eevee
1 parent 322b84c commit 134d8e3

File tree

8 files changed

+68
-31
lines changed

8 files changed

+68
-31
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,15 @@ It is not support editing the same blender file across add-on versions. In order
5656
But even then, there is still no guarantee that the new version of the add-on will work on the old blender file. Therefore, it is highly recommended to open a new blender file to start the creating, not based on the old one.
5757

5858
Alternatively, objects from the old file that have nothing to do with Bioxel Nodes could be append to the new blender file.
59+
60+
## About EEVEE Render
61+
62+
Bioxel Nodes is designed for Cycles Render. However, it does support eevee render partially. "Solid Shader" node and "Volume Shader" node have a toggle called "EEVEE Render". If you want to render Bioxel Component in real-time, turn it on.
63+
64+
Also, there are some limitations:
65+
66+
1. Only one cutter supported.
67+
2. You cannot use "Color Ramp" over 2 colors.
68+
3. EEVEE Render result is not that great as Cycles does.
69+
70+
> "Volume Shader" node is not work properly in EEVEE Next since 4.2. It is because EEVEE Next is not support attributes from instances of volume shader by now. But the Blender 4.2 docs still say attributes reading is ok, so I suppose this feature will eventually be implemented.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:673262476653e04ca793e97f2d998cba31f338e1219199585a3844fd3c8d6b33
3-
size 4887206
2+
oid sha256:6721aaf62fda8d104312d290032ab045b9f7d06f7f71ef9dd17b851c0e7293b5
3+
size 5410056
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:cecabd497316a2c0a0e64cb30274ea4c62000288fb13481102b4f2f2eaca2e7d
3-
size 4196897
2+
oid sha256:9dc863260e46ad32b0101f9e082a4c7162ccf1e1df7a8ea678d02961d9866d99
3+
size 4702346

bioxelnodes/io.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
from pathlib import Path
77
from uuid import uuid4
88
import mathutils
9+
import random
910

1011
from .nodes import custom_nodes
1112
from .props import BIOXELNODES_Series
12-
from .utils import (calc_bbox_verts, get_container, get_layer, get_text_index_str,
13+
from .utils import (calc_bbox_verts, get_all_layers, get_container, get_layer, get_text_index_str,
1314
get_node_by_type, hide_in_ray, lock_transform, show_message)
1415

1516
try:
@@ -218,6 +219,7 @@ class ImportVolumeDataDialog(bpy.types.Operator):
218219
) # type: ignore
219220

220221
def execute(self, context):
222+
is_first_import = len(get_all_layers()) == 0
221223
image, name = read_image(self.filepath, self.series_id)
222224
container_name = self.container_name or name
223225
bioxel_size = self.bioxel_size
@@ -258,7 +260,7 @@ def execute(self, context):
258260
interpolator = sitk.sitkNearestNeighbor
259261
elif self.resample_method == "gaussian":
260262
interpolator = sitk.sitkGaussian
261-
263+
262264
if self.read_as == "labels":
263265
interpolator = sitk.sitkNearestNeighbor
264266

@@ -451,11 +453,14 @@ def create_layer(array, layer_name, layer_type="scalar"):
451453
input_node = get_node_by_type(nodes, 'NodeGroupInput')[0]
452454
output_node = get_node_by_type(nodes, 'NodeGroupOutput')[0]
453455

454-
to_layer_node = custom_nodes.add_node(nodes, "BioxelNodes__ConvertToLayer")
456+
to_layer_node = custom_nodes.add_node(nodes,
457+
"BioxelNodes__ConvertToLayer")
455458

456459
links.new(input_node.outputs[0], to_layer_node.inputs[0])
457460
links.new(to_layer_node.outputs[0], output_node.inputs[0])
458461

462+
to_layer_node.inputs['Layer ID'].default_value = random.randint(-200000000,
463+
200000000)
459464
to_layer_node.inputs['Bioxel Size'].default_value = bioxel_size
460465
to_layer_node.inputs['Shape'].default_value = layer_shape
461466
to_layer_node.inputs['Origin'].default_value = layer_origin
@@ -531,7 +536,7 @@ def create_layer(array, layer_name, layer_type="scalar"):
531536
bpy.context.view_layer.objects.active = container
532537

533538
# Change render setting for better result
534-
if preferences.do_change_render_setting:
539+
if preferences.do_change_render_setting and is_first_import:
535540
bpy.context.scene.render.engine = 'CYCLES'
536541
bpy.context.scene.cycles.volume_bounces = 12
537542
bpy.context.scene.cycles.transparent_max_bounces = 16

bioxelnodes/operators.py

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pathlib import Path
2+
import random
23
import bpy
34
import pyopenvdb as vdb
45
from uuid import uuid4
@@ -107,7 +108,29 @@ def execute(self, context):
107108
filepath=str(vdb_path), align='WORLD', location=(0, 0, 0), scale=(1, 1, 1))
108109

109110
joined_layer = bpy.context.active_object
110-
111+
112+
# Set props to VDB object
113+
joined_layer.name = f"{base_layer.name}_Joined"
114+
joined_layer.data.name = f"{base_layer.name}_Joined"
115+
116+
lock_transform(joined_layer)
117+
hide_in_ray(joined_layer)
118+
joined_layer.hide_select = True
119+
joined_layer.hide_render = True
120+
joined_layer.hide_viewport = True
121+
joined_layer.data.display.use_slice = True
122+
joined_layer.data.display.density = 1e-05
123+
124+
joined_layer['bioxel_layer'] = True
125+
joined_layer.parent = base_layer.parent
126+
127+
for collection in layer.users_collection:
128+
collection.objects.unlink(layer)
129+
130+
for collection in base_layer.users_collection:
131+
collection.objects.link(layer)
132+
133+
# add convert to layer node
111134
base_layer_node = base_layer.modifiers[0].node_group.nodes['BioxelNodes__ConvertToLayer']
112135
bioxel_size = base_layer_node.inputs['Bioxel Size'].default_value
113136
layer_shape = base_layer_node.inputs['Shape'].default_value
@@ -116,7 +139,7 @@ def execute(self, context):
116139
scalar_offset = base_layer_node.inputs['Scalar Offset'].default_value
117140
scalar_min = base_layer_node.inputs['Scalar Min'].default_value
118141
scalar_max = base_layer_node.inputs['Scalar Max'].default_value
119-
142+
120143
if self.scalar_layer != "None":
121144
scalar_layer_node = scalar_layer.modifiers[0].node_group.nodes['BioxelNodes__ConvertToLayer']
122145
scalar_offset = scalar_layer_node.inputs['Scalar Offset'].default_value
@@ -130,15 +153,15 @@ def execute(self, context):
130153

131154
input_node = get_node_by_type(nodes, 'NodeGroupInput')[0]
132155
output_node = get_node_by_type(nodes, 'NodeGroupOutput')[0]
133-
134156

135157
joined_layer_node = custom_nodes.add_node(
136158
nodes, "BioxelNodes__ConvertToLayer")
137159

138-
139160
links.new(input_node.outputs[0], joined_layer_node.inputs[0])
140161
links.new(joined_layer_node.outputs[0], output_node.inputs[0])
141162

163+
joined_layer_node.inputs['Layer ID'].default_value = random.randint(-200000000,
164+
200000000)
142165
joined_layer_node.inputs['Bioxel Size'].default_value = bioxel_size
143166
joined_layer_node.inputs['Shape'].default_value = layer_shape
144167
joined_layer_node.inputs['Origin'].default_value = layer_origin
@@ -147,21 +170,6 @@ def execute(self, context):
147170
joined_layer_node.inputs['Scalar Min'].default_value = scalar_min
148171
joined_layer_node.inputs['Scalar Max'].default_value = scalar_max
149172

150-
# Set props to VDB object
151-
joined_layer.name = f"{base_layer.name}_Joined"
152-
joined_layer.data.name = f"{base_layer.name}_Joined"
153-
154-
lock_transform(joined_layer)
155-
hide_in_ray(joined_layer)
156-
joined_layer.hide_select = True
157-
joined_layer.hide_render = True
158-
joined_layer.hide_viewport = True
159-
joined_layer.data.display.use_slice = True
160-
joined_layer.data.display.density = 1e-05
161-
162-
joined_layer['bioxel_layer'] = True
163-
joined_layer.parent = base_layer.parent
164-
165173
return {'FINISHED'}
166174

167175
def invoke(self, context, event):
@@ -206,8 +214,8 @@ def execute(self, context):
206214
output_node = get_node_by_type(nodes, 'NodeGroupOutput')[0]
207215
object_node = nodes.new("GeometryNodeObjectInfo")
208216
realize_nodes = nodes.new("GeometryNodeRealizeInstances")
209-
separate_node = custom_nodes.add_node(
210-
nodes, "BioxelNodes__SeparateComponent")
217+
separate_node = custom_nodes.add_node(nodes,
218+
"BioxelNodes__SeparateComponent")
211219

212220
object_node.inputs[0].default_value = container
213221
separate_node.inputs[1].default_value = 1

docs/index.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,15 @@ It is not support editing the same blender file across add-on versions. In order
5454
But even then, there is still no guarantee that the new version of the add-on will work on the old blender file. Therefore, it is highly recommended to open a new blender file to start the creating, not based on the old one.
5555

5656
Alternatively, objects from the old file that have nothing to do with Bioxel Nodes could be append to the new blender file.
57+
58+
## About EEVEE Render
59+
60+
Bioxel Nodes is designed for Cycles Render. However, it does support eevee render partially. "Solid Shader" node and "Volume Shader" node have a toggle called "EEVEE Render". If you want to render Bioxel Component in real-time, turn it on.
61+
62+
Also, there are some limitations:
63+
64+
1. Only one cutter supported.
65+
2. You cannot use "Color Ramp" over 2 colors.
66+
3. EEVEE Render result is not that great as Cycles does.
67+
68+
> "Volume Shader" node is not work properly in EEVEE Next since 4.2. It is because EEVEE Next is not support attributes from instances of volume shader by now. But the Blender 4.2 docs still say attributes reading is ok, so I suppose this feature will eventually be implemented.

extension/blender_manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ schema_version = "1.0.0"
33
# Example of manifest file for a Blender extension
44
# Change the values according to your extension
55
id = "bioxelnodes"
6-
version = "0.2.0"
6+
version = "0.2.2"
77
name = "Bioxel Nodes"
88
tagline = "For scientific volumetric data visualization in Blender"
99
maintainer = "Ma Nan <[email protected]>"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "bioxelnodes"
3-
version = "0.2.0"
3+
version = "0.2.2"
44
description = ""
55
authors = ["Ma Nan <[email protected]>"]
66
license = "MIT"

0 commit comments

Comments
 (0)