✨ ComfyUI-PHRenderFormerWrapper ✨

Author: paulh4x

WIP Screenshot 1 WIP Screenshot 2 WIP Screenshot 3 Resolution Comparison

This repository contains a set of custom nodes for ComfyUI that provide a wrapper for Microsoft's RenderFormer model. It allows you to render complex 3D scenes (see Limits) with physically-based materials and global illumination directly within the ComfyUI interface.

Warning

WORK IN PROGRESS & HELLO WORLD: This project is my first "hello world" in contributing code of any kind and is currently under active development. It should be considered experimental. The model is in a very early stage and may be further developed later. I do not take responsibility if this breaks anything and do not plan to provide official support for it.


🚀 Features

  • 🎨 End-to-End Rendering: Load 3D models, define materials, set up cameras, and render—all within ComfyUI.
  • ⚙️ Modular Node-Based Workflow: Each step of the rendering pipeline is a separate node, allowing for flexible and complex setups.
  • 🎥 Animation & Video: Create camera animations by interpolating between keyframes. The nodes output image batches compatible with ComfyUI's native video-saving nodes.
  • 🔧 Advanced Mesh Processing: Includes nodes for loading, combining, remeshing, and applying simple color randomization to your 3D assets.
  • 💡 Lighting and Material Control: Easily add and combine multiple light sources and control PBR material properties like diffuse, specular, roughness, and emission.
  • ↔️ Full Transformation Control: Apply translation, rotation, and scaling to objects within the scene.

🧱 Model Limits

  • Meshes: RenderFormer can handle scenes of up to 8192 polygons.
  • Lights: Up to 8 lightsources can be combined for lighting, emission color is for now limited to rgb 255, 255, 255 (white).
  • Resolution: Best tested resolutions for now are between 512 x 512 to 1024 x 1024 pixels. The model can produce resolutions up to 2048 x 2048 pixel, quality of outputs decrease with higher resolutions (see comparison img).
  • Animations: Due to slightly varying precision in each frame rendered, camera animations for now contain some flickering, especially with high reflective materials.

📝 Progress & To-Do

This project is under active development. Here is a summary of the progress so far and the features planned for the future.

✅ Done

  • Core Rendering Pipeline: All essential nodes for building and rendering a static 3D scene are implemented.
  • In-Memory Processing: Partitial scene preparation pipeline is handled in-memory to maximize speed.
  • Video Rendering: A complete, dedicated workflow for video rendering is in place.
  • Advanced Utilities: Nodes for mesh combination, remeshing, and JSON-based scene loading are functional.
  • Custom UI Elements: The nodes feature custom colors for better visual organization, and progress bars are implemented for long-running operations.
  • Bug Fixes: Addressed various bugs related to file handling, data types, and temporary file management.
  • Proper RGB Values for diffuse Color: Colorpicker support for white-values for more variety of colors including.

📋 To Do

  • Randomize Color Fix: Fix RandomizeColors node, will produce the expected visual output.
  • ⚡ In-Memory Processing: Fix entire scene preparation pipeline, from loading meshes to generating the final HDF5 data for the model, should be handled in-memory to maximize speed and avoid disk I/O.
  • Camera Animation: Fix flickering in animations especially for objects with high glossy materials.
  • Mesh Format Support: Add support for loading .glb and .fbx files, including their materials and textures.
  • Target Animation Nodes: Implement animation capabilities for MESH and LIGHT properties, not just the camera.
  • Camera Adoption: Integrate with the Load 3D core node to adopt its camera transformations.
  • Material Presets: Create a system for saving and loading material presets.
  • Public Release: Prepare for a more stable, public release with better documentation and examples.

️ Installation

Prerequisites

  • Git: Required for cloning the repository and installing certain dependencies.
  • Python: A Python version compatible with ComfyUI and PyTorch 2.0+.
  • PyTorch: A compatible version of PyTorch must be installed for your hardware (NVIDIA CUDA or Apple Metal). This wrapper is tested with PyTorch 2.7.1 and CUDA 12.6.
  • ComfyUI: A working installation of ComfyUI.

Installation Steps

  1. Navigate to your ComfyUI custom_nodes directory:
    cd ComfyUI/custom_nodes/
    
  2. Clone this repository:
    git clone https://github.com/your-github-username/ComfyUI_PHRenderFormerWrapper.git
    
  3. Navigate into the newly cloned directory:
    cd ComfyUI_PHRenderFormerWrapper
    
  4. Clone the official Microsoft RenderFormer repository into this directory. It must be named renderformer:
    git clone https://github.com/microsoft/renderformer.git renderformer
    
  5. Install the required Python packages for this wrapper:
    pip install -r requirements.txt
    

Important

For owners of a NVIDIA 50xx series GPU, a dedicated requirements file is available. Please use the following command instead:

pip install -r requirements_50xx.txt
  1. RenderFormer requires an additional plugin for handling HDR image formats. Run the following command to download it:
    python -c "import imageio; imageio.plugins.freeimage.download()"
    
  2. Restart ComfyUI.

Note

For NVIDIA GPU users, the underlying RenderFormer library can optionally use Flash Attention for better performance. If you have it installed in your PyTorch environment, it should be used automatically.


📦 Nodes

This wrapper provides a comprehensive set of nodes to build 3D scenes.

Core Pipeline

  • PHRenderFormer Model Loader: Loads a specified RenderFormer model from Hugging Face or a local path.
  • PHRenderFormer Scene Builder: Assembles a final scene for single-image rendering from meshes, a camera, materials, and lighting.
  • PHRenderFormer Sampler: Executes the RenderFormer pipeline on an assembled scene to produce the final rendered image.

Video & Animation

  • PHRenderFormer Camera Target: Creates a camera animation sequence by interpolating between a start and end camera state (position, look-at, FOV).
  • PHRenderFormer Video Scene Builder: Assembles a sequence of scenes, one for each frame of a camera animation.

Scene Components

  • PHRenderFormer Mesh Loader: Loads a 3D mesh file (e.g., .obj, .glb). Includes a file upload button and serves as the primary node for defining an object's material and transformation.
  • PHRenderFormer Camera: Defines the camera's position, look-at target, and field of view (FOV).
  • PHRenderFormer Material: Defines the PBR material properties for a mesh. The diffuse color can be set using an interactive, canvas-based color picker.
  • PHRenderFormer Lighting: Creates a configurable emissive light source.

Utilities & Advanced

  • PHRenderFormer Mesh Combine: Combines multiple PH_MESH outputs into a single object list.
  • PHRenderFormer Lighting Combine: Combines multiple light sources into a single list for the scene builder.
  • PHRenderFormer Remesh: Simplifies the geometry of a mesh to a target face count using pymeshlab.
  • PHRenderFormer Random Colors: Applies random vertex colors to a mesh for creative effects or debugging.
  • PHRenderFormer From JSON: Loads a scene from a JSON definition, allowing for more complex and customized setups based on the original RenderFormer format.
  • PHRenderFormer Example Scene: A test node to quickly load one of the official RenderFormer example scenes.

Version History

Version 0.2.5 - Node Consolidation and Workflow Simplification

  • Workflow: Merged the RenderFormerVideoSamplerBatched into the main RenderFormerGenerator (now RenderFormer Sampler). The sampler now intelligently handles both single images and video sequences, with an optional IMAGES output.
  • Workflow: Merged the RenderFormerVideoSceneBuilder into the main RenderFormerSceneBuilder. The node now accepts both a single CAMERA and a CAMERA_SEQUENCE, with optional SCENE and SCENE_SEQUENCE outputs.
  • Fix: Resolved a critical AttributeError in the RenderFormerSceneBuilder caused by a missing helper method after the node merge.
  • Fix: Removed hardcoded material properties for background meshes in the RenderFormerLoadMesh node, ensuring that materials are always controlled by the node's inputs.
  • UI/UX: Added a colored startup message with an ASCII logo to provide clear feedback on whether the nodes loaded successfully.
  • UI/UX: Fixed a SyntaxWarning related to escape sequences in the startup message.

Version 0.2.21 Beta Test - UI/UX and Workflow Enhancements

  • Examples: added example workflows for ComfyUI.
  • UI/UX: All nodes now have custom colors for better visual organization in the graph. The header is yellow (#FDC501) and the body is anthracite (#111417).
  • UI/UX: Added progress bars to all long-running nodes (SceneBuilder, VideoSceneBuilder, Sampler, VideoSampler, Remesh) to provide real-time feedback.
  • Workflow: The Remesh node now processes all meshes in a list, not just the first one.
  • Workflow: The SceneBuilder nodes will no longer add the default background if a background mesh has already been loaded manually, preventing duplicates.
  • Input Precision: The emissive_strength input on the Lighting node now has a smaller step value for finer control.

Version 0.1.9 - Video Rendering and Stability

  • Feature: Added a complete, dedicated workflow for video rendering (Camera Target, Video Scene Builder, Video Sampler).
  • Fix: Resolved a dacite.exceptions.MissingValueError in the video scene builder.
  • Fix: Addressed TypeError and FileNotFoundError bugs related to temporary file handling in the video pipeline.
  • Change: Separated single-image and video workflows for improved stability and clarity.

Version 0.1.5 - Refinements and Fixes

  • Feature: The LoadMesh node now has a RENDERFORMER_MATERIAL output, allowing material properties to be shared.
  • Feature: Added default transformations for specific background meshes from the official examples.
  • Change: Increased input precision for rotation and scale transformations.

Version 0.1.0 - Initial Development

  • Feature: Established the core rendering pipeline and all essential nodes for building and rendering a static 3D scene.
  • Feature: Implemented in-memory scene processing to patch trimesh and h5py, avoiding slow disk I/O.
  • Feature: Added advanced utility nodes like RemeshMesh, RandomizeColors, and FromJSON.
  • UI/UX: Integrated a file uploader and a custom canvas-based color picker for a better user experience.

🌱 My Journey

This project represents my first steps into coding and open-source contribution. It was born out of a desire to learn and create. What started as a simple experiment has been a journey of discovery, and I'm excited to see where it goes. I would love to develop this project further with the help of the community and welcome any contributions or feedback.

🙏 Acknowledgements

This project would not be possible without the foundational work of others.

  • RenderFormer This project is a wrapper for the incredible RenderFormer model. All credit for the underlying rendering technology goes to the original authors: Chong Zeng, Yue Dong, Pieter Peers, Hongzhi Wu, and Xin Tong.

  • comfyui-hunyuan3dwrapper Special thanks to kijai for their work on the comfyui-hunyan3dwrapper, which served as an invaluable reference and starting point for this project during its development in vibecoding.

  • ComfyUI_Fill-Example-Nodes A huge thank you to filliptm for creating the ComfyUI_Fill-Example-Nodes repository. The advanced color picker in this project was implemented by adapting the excellent example code provided in that repo. It was an essential learning resource for understanding how to build custom UI elements in ComfyUI.

S
Description
No description provided
Readme
6.1 MiB
Languages
Python 85.3%
JavaScript 14.7%