updated mesh loader node

This commit is contained in:
paulh4x
2025-07-08 02:38:30 +02:00
parent 9b23fbd625
commit 2bd2c481fe
2 changed files with 38 additions and 21 deletions
+11
View File
@@ -21,6 +21,17 @@ What started as a simple experiment quickly grew into a passion project. It has
---
### Version 0.2 - Refinements and Fixes
This version focuses on improving the usability and stability of the nodes, with several key refinements and bug fixes.
**Key Features & Accomplishments:**
* **Material Output:** The `LoadMesh` node now has a `RENDERFORMER_MATERIAL` output, allowing you to pipe the material from one mesh to another.
* **Default Transformations:** When loading specific background meshes from the `cbox-bunny.json` example (`plane.obj`, `wall0.obj`, `wall1.obj`, `wall2.obj`), the node now automatically applies the correct transformation values.
* **Increased Precision:** The precision for rotation and scale inputs has been increased for finer control over transformations.
* **Bug Fixes:** Resolved an out-of-memory error that could occur with high-resolution rendering or complex scenes.
### Version 0.1 - Initial Development
This initial version of the PHRenderFormerWrapper lays the foundation for rendering 3D scenes within ComfyUI. The focus was on establishing the core architecture, implementing a comprehensive set of nodes for scene construction, and creating a flexible, user-friendly workflow.
+27 -21
View File
@@ -115,20 +115,19 @@ class LoadMesh:
"trans_x": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.001}),
"trans_y": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.001}),
"trans_z": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.001}),
"rot_x": ("FLOAT", {"default": -90.0, "min": -360.0, "max": 360.0, "step": 1.0}),
"rot_y": ("FLOAT", {"default": 0.0, "min": -360.0, "max": 360.0, "step": 1.0}),
"rot_z": ("FLOAT", {"default": 0.0, "min": -360.0, "max": 360.0, "step": 1.0}),
"scale": ("FLOAT", {"default": 1.0, "min": 0.1, "max": 10.0, "step": 0.1}),
"rot_x": ("FLOAT", {"default": 0.0, "min": -360.0, "max": 360.0, "step": 0.1}),
"rot_y": ("FLOAT", {"default": 0.0, "min": -360.0, "max": 360.0, "step": 0.1}),
"rot_z": ("FLOAT", {"default": 0.0, "min": -360.0, "max": 360.0, "step": 0.1}),
"scale": ("FLOAT", {"default": 1.0, "min": 0.1, "max": 10.0, "step": 0.01}),
# Material properties
"diffuse_rgb": ("STRING", {"default": "204, 204, 204", "multiline": False, "tooltip": "Diffuse color (R, G, B) from 0-255"}),
"specular_rgb": ("STRING", {"default": "25, 25, 25", "multiline": False, "tooltip": "Specular color (R, G, B) from 0-255"}),
"roughness": ("FLOAT", {"default": 0.7, "min": 0.0, "max": 1.0, "step": 0.01}),
"emissive_rgb": ("STRING", {"default": "0, 0, 0", "multiline": False, "tooltip": "Emissive strength (R, G, B). Values can exceed 255."}),
}
}
RETURN_TYPES = ("PH_MESH",)
RETURN_TYPES = ("PH_MESH", "RENDERFORMER_MATERIAL",)
FUNCTION = "load_mesh"
CATEGORY = "PHRenderFormer"
@@ -145,9 +144,17 @@ class LoadMesh:
def load_mesh(self, mesh, material=None, mesh_path=None,
normalize_mesh=True, trans_x=0.0, trans_y=0.0, trans_z=0.0,
rot_x=-90.0, rot_y=0.0, rot_z=0.0, scale=1.0,
rot_x=0.0, rot_y=0.0, rot_z=0.0, scale=1.0,
diffuse_rgb="204, 204, 204",
specular_rgb="25, 25, 25", roughness=0.7, emissive_rgb="0, 0, 0"):
specular_rgb="25, 25, 25", roughness=0.7):
# Default transformations for specific background files from cbox-bunny.json
background_files = ["plane.obj", "wall0.obj", "wall1.obj", "wall2.obj"]
if mesh in background_files:
normalize_mesh = False
trans_x, trans_y, trans_z = 0.0, 0.0, 0.0
rot_x, rot_y, rot_z = 0.0, 0.0, 0.0
scale = 0.5
final_material = None
@@ -158,13 +165,12 @@ class LoadMesh:
# Otherwise, build the material from the node's own inputs.
diffuse_color = self._parse_color_string(diffuse_rgb, 255.0) or [0.8, 0.8, 0.8]
specular_color = self._parse_color_string(specular_rgb, 255.0) or [0.1, 0.1, 0.1]
emissive_color = self._parse_color_string(emissive_rgb, 1.0) or [0.0, 0.0, 0.0]
final_material = {
"diffuse": diffuse_color,
"specular": specular_color,
"roughness": roughness,
"emissive": emissive_color
"emissive": [0.0, 0.0, 0.0]
}
# Load mesh from path
@@ -194,7 +200,7 @@ class LoadMesh:
"transforms": [transform]
}
return (ph_mesh,)
return (ph_mesh, final_material)
class RemeshMesh:
@classmethod
@@ -304,12 +310,12 @@ class RenderFormerCamera:
def INPUT_TYPES(cls):
return {
"required": {
"camera_pos_x": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.1}),
"camera_pos_y": ("FLOAT", {"default": -2.0, "min": -10.0, "max": 10.0, "step": 0.1}),
"camera_pos_z": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.1}),
"camera_look_at_x": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.1}),
"camera_look_at_y": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.1}),
"camera_look_at_z": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.1}),
"camera_pos_x": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.01}),
"camera_pos_y": ("FLOAT", {"default": -2.0, "min": -10.0, "max": 10.0, "step": 0.01}),
"camera_pos_z": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.01}),
"camera_look_at_x": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.01}),
"camera_look_at_y": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.01}),
"camera_look_at_z": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.01}),
"fov": ("FLOAT", {"default": 37.5, "min": 1.0, "max": 179.0, "step": 1.0, "tooltip": "Field of View in degrees"}),
}
}
@@ -337,10 +343,10 @@ class RenderFormerLighting:
"trans_x": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.001}),
"trans_y": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.001}),
"trans_z": ("FLOAT", {"default": 2.1, "min": -10.0, "max": 10.0, "step": 0.001}),
"rot_x": ("FLOAT", {"default": 0.0, "min": -360.0, "max": 360.0, "step": 1.0}),
"rot_y": ("FLOAT", {"default": 0.0, "min": -360.0, "max": 360.0, "step": 1.0}),
"rot_z": ("FLOAT", {"default": 0.0, "min": -360.0, "max": 360.0, "step": 1.0}),
"scale": ("FLOAT", {"default": 2.5, "min": 0.1, "max": 10.0, "step": 0.1}),
"rot_x": ("FLOAT", {"default": 0.0, "min": -360.0, "max": 360.0, "step": 0.1}),
"rot_y": ("FLOAT", {"default": 0.0, "min": -360.0, "max": 360.0, "step": 0.1}),
"rot_z": ("FLOAT", {"default": 0.0, "min": -360.0, "max": 360.0, "step": 0.1}),
"scale": ("FLOAT", {"default": 2.5, "min": 0.1, "max": 10.0, "step": 0.01}),
}
}