How by-luckk/physgen3d works
Main Components and Their Roles
• Input & Data:
– "data" folder holds raw image data (under data/img) and HDR environment maps (data/hdr) used for lighting in rendering.
– "configs" contains configuration files (e.g., GroundingDINO, lama-prediction, mpm configurations) that control various stages.
• Perception Module:
– Executed via perception.py, this module processes a given input image (e.g., teddy.jpg), extracts depth information, object masks, and creates initial meshes. It outputs intermediate files (depth, inpainted images, masks, reconstructed meshes, etc.) into an organized “outputs” folder.
• Simulation Module:
– Managed by simulation.py (and supported by additional scripts such as ball_sim.py and mpm_sim.py), the simulation module reads configuration parameters (from the data/sim folder) to simulate physical behavior. This module applies the physics engine provided in the "engine" folder (which includes core solvers, mesh IO, voxelizers, etc.) and writes simulation results into its dedicated output folder.
• Rendering Module:
– Triggered by rendering.py. It takes the simulation results and perception outputs to produce final visuals. HDR backgrounds, camera settings, and rendering parameters are configured (from command-line arguments and external config files) to generate images and video outputs.
• Engine and Supporting Tools:
– The "engine" folder encapsulates the core physics and simulation functionalities (e.g., mpm_solver, particle_io, renderer) whereas additional modules like “my_instant_mesh.py” and “my_dust3r.py” support specialized tasks.
– The "inverse", "locate", and "mesh_utils.py" files assist in different stages of geometry and object registration.
– Submodules (e.g., instant_mesh, GroundingDINO, dust3r, lama) integrate external repositories and state-of-the-art models for mesh generation, superpoint matching, and transformer-based decoding.
Relationships and Data Flow
– Raw images and HDR data from the “data” directory.
– Configuration inputs from “configs.”
• Next, illustrate the Perception component:
– Show that perception.py receives the input image and text prompt.
– Indicate outputs (object masks, point clouds, inpainted images, meshes) being stored in a structured “outputs” directory.
– Simulation.py uses configuration data (from data/sim) and the outputs of the Perception module (e.g., initial meshes, detected geometries).
– Under this, include the core functionality from the “engine” folder that provides solvers and simulation routines.
• On the right-hand side, add the Rendering component:
– Connect the simulation results and perception outputs as inputs to rendering.py.
– Highlight that rendering employs HDR environments and produces final visuals (images and videos).
• Auxiliary components (e.g., "locate", "inverse") as supporting modules that feed into perception or simulation as needed.
Important Architectural Patterns and Technologies
• Modular Pipeline: Emphasize separation of concerns where perception, simulation, and rendering are distinct yet interconnected.
• Integration via Submodules: Note the architecture leverages external models and code (e.g., instant_mesh, GroundingDINO) which are integrated as submodules.
• Dependency Flow: Detail how configuration management and external dependencies (install scripts in env_install) facilitate the entire workflow.
• Use of TAICHI-Elements: The “engine” directory’s role in providing physics simulation routines based on taichi-elements is crucial.