Merge pull request #19 from OmooLab/feature/dev

feat: support eevee
This commit is contained in:
Ma Nan
2024-06-12 15:24:06 +08:00
committed by GitHub
8 changed files with 88 additions and 51 deletions

View File

@@ -56,3 +56,15 @@ It is not support editing the same blender file across add-on versions. In order
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.
Alternatively, objects from the old file that have nothing to do with Bioxel Nodes could be append to the new blender file.
## About EEVEE Render
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.
Also, there are some limitations:
1. Only one cutter supported.
2. You cannot use "Color Ramp" over 2 colors.
3. EEVEE Render result is not that great as Cycles does.
> "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.

View File

@@ -6,10 +6,11 @@ import numpy as np
from pathlib import Path
from uuid import uuid4
import mathutils
import random
from .nodes import custom_nodes
from .props import BIOXELNODES_Series
from .utils import (calc_bbox_verts, get_container, get_layer, get_text_index_str,
from .utils import (calc_bbox_verts, get_all_layers, get_container, get_layer, get_text_index_str,
get_node_by_type, hide_in_ray, lock_transform, show_message)
try:
@@ -218,6 +219,7 @@ class ImportVolumeDataDialog(bpy.types.Operator):
) # type: ignore
def execute(self, context):
is_first_import = len(get_all_layers()) == 0
image, name = read_image(self.filepath, self.series_id)
container_name = self.container_name or name
bioxel_size = self.bioxel_size
@@ -451,11 +453,14 @@ class ImportVolumeDataDialog(bpy.types.Operator):
input_node = get_node_by_type(nodes, 'NodeGroupInput')[0]
output_node = get_node_by_type(nodes, 'NodeGroupOutput')[0]
to_layer_node = custom_nodes.add_node(nodes, "BioxelNodes__ConvertToLayer")
to_layer_node = custom_nodes.add_node(nodes,
"BioxelNodes__ConvertToLayer")
links.new(input_node.outputs[0], to_layer_node.inputs[0])
links.new(to_layer_node.outputs[0], output_node.inputs[0])
to_layer_node.inputs['Layer ID'].default_value = random.randint(-200000000,
200000000)
to_layer_node.inputs['Bioxel Size'].default_value = bioxel_size
to_layer_node.inputs['Shape'].default_value = layer_shape
to_layer_node.inputs['Origin'].default_value = layer_origin
@@ -531,7 +536,7 @@ class ImportVolumeDataDialog(bpy.types.Operator):
bpy.context.view_layer.objects.active = container
# Change render setting for better result
if preferences.do_change_render_setting:
if preferences.do_change_render_setting and is_first_import:
bpy.context.scene.render.engine = 'CYCLES'
bpy.context.scene.cycles.volume_bounces = 12
bpy.context.scene.cycles.transparent_max_bounces = 16

View File

@@ -1,4 +1,5 @@
from pathlib import Path
import random
import bpy
import pyopenvdb as vdb
from uuid import uuid4
@@ -108,6 +109,28 @@ class JoinLayers(bpy.types.Operator):
joined_layer = bpy.context.active_object
# Set props to VDB object
joined_layer.name = f"{base_layer.name}_Joined"
joined_layer.data.name = f"{base_layer.name}_Joined"
lock_transform(joined_layer)
hide_in_ray(joined_layer)
joined_layer.hide_select = True
joined_layer.hide_render = True
joined_layer.hide_viewport = True
joined_layer.data.display.use_slice = True
joined_layer.data.display.density = 1e-05
joined_layer['bioxel_layer'] = True
joined_layer.parent = base_layer.parent
for collection in layer.users_collection:
collection.objects.unlink(layer)
for collection in base_layer.users_collection:
collection.objects.link(layer)
# add convert to layer node
base_layer_node = base_layer.modifiers[0].node_group.nodes['BioxelNodes__ConvertToLayer']
bioxel_size = base_layer_node.inputs['Bioxel Size'].default_value
layer_shape = base_layer_node.inputs['Shape'].default_value
@@ -131,14 +154,14 @@ class JoinLayers(bpy.types.Operator):
input_node = get_node_by_type(nodes, 'NodeGroupInput')[0]
output_node = get_node_by_type(nodes, 'NodeGroupOutput')[0]
joined_layer_node = custom_nodes.add_node(
nodes, "BioxelNodes__ConvertToLayer")
links.new(input_node.outputs[0], joined_layer_node.inputs[0])
links.new(joined_layer_node.outputs[0], output_node.inputs[0])
joined_layer_node.inputs['Layer ID'].default_value = random.randint(-200000000,
200000000)
joined_layer_node.inputs['Bioxel Size'].default_value = bioxel_size
joined_layer_node.inputs['Shape'].default_value = layer_shape
joined_layer_node.inputs['Origin'].default_value = layer_origin
@@ -147,21 +170,6 @@ class JoinLayers(bpy.types.Operator):
joined_layer_node.inputs['Scalar Min'].default_value = scalar_min
joined_layer_node.inputs['Scalar Max'].default_value = scalar_max
# Set props to VDB object
joined_layer.name = f"{base_layer.name}_Joined"
joined_layer.data.name = f"{base_layer.name}_Joined"
lock_transform(joined_layer)
hide_in_ray(joined_layer)
joined_layer.hide_select = True
joined_layer.hide_render = True
joined_layer.hide_viewport = True
joined_layer.data.display.use_slice = True
joined_layer.data.display.density = 1e-05
joined_layer['bioxel_layer'] = True
joined_layer.parent = base_layer.parent
return {'FINISHED'}
def invoke(self, context, event):
@@ -206,8 +214,8 @@ class ConvertToMesh(bpy.types.Operator):
output_node = get_node_by_type(nodes, 'NodeGroupOutput')[0]
object_node = nodes.new("GeometryNodeObjectInfo")
realize_nodes = nodes.new("GeometryNodeRealizeInstances")
separate_node = custom_nodes.add_node(
nodes, "BioxelNodes__SeparateComponent")
separate_node = custom_nodes.add_node(nodes,
"BioxelNodes__SeparateComponent")
object_node.inputs[0].default_value = container
separate_node.inputs[1].default_value = 1

View File

@@ -54,3 +54,15 @@ It is not support editing the same blender file across add-on versions. In order
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.
Alternatively, objects from the old file that have nothing to do with Bioxel Nodes could be append to the new blender file.
## About EEVEE Render
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.
Also, there are some limitations:
1. Only one cutter supported.
2. You cannot use "Color Ramp" over 2 colors.
3. EEVEE Render result is not that great as Cycles does.
> "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.

View File

@@ -3,7 +3,7 @@ schema_version = "1.0.0"
# Example of manifest file for a Blender extension
# Change the values according to your extension
id = "bioxelnodes"
version = "0.2.0"
version = "0.2.2"
name = "Bioxel Nodes"
tagline = "For scientific volumetric data visualization in Blender"
maintainer = "Ma Nan <icrdr2010@outlook.com>"

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "bioxelnodes"
version = "0.2.0"
version = "0.2.2"
description = ""
authors = ["Ma Nan <icrdr2010@outlook.com>"]
license = "MIT"