68 lines
2.6 KiB
Markdown
68 lines
2.6 KiB
Markdown
|
|
# SSBO Editor Component Usage Guide
|
|
|
|
This directory contains a modular SSBO Scene Editor component for Panda3D RenderPipeline.
|
|
|
|
## 📁 File Structure
|
|
|
|
- `ssbo_editor.py`: Main component class `SSBOEditor`. Handles ImGui, RP integration, and input.
|
|
- `ssbo_controller.py`: Core logic for object ID baking and SSBO matrix packing.
|
|
- `effects/ssbo_instancing.yaml`: The custom shader effect for RenderPipeline (includes Normal Matrix fix).
|
|
- `demo_component.py`: Example usage script.
|
|
|
|
## 🚀 How to Integrate
|
|
|
|
### 1. Prerequisites
|
|
|
|
Ensure your project has:
|
|
- `RenderPipeline` setup
|
|
- `imgui_bundle` and `p3dimgui` installed
|
|
- `panda3d` (version 1.10.15+)
|
|
|
|
### 2. Basic Setup (See demo_component.py)
|
|
|
|
```python
|
|
from direct.showbase.ShowBase import ShowBase
|
|
from rpcore import RenderPipeline
|
|
from ssbo_component.ssbo_editor import SSBOEditor
|
|
|
|
class MyApp(ShowBase):
|
|
def __init__(self):
|
|
# 1. Initialize RP
|
|
self.rp = RenderPipeline()
|
|
self.rp.pre_showbase_init()
|
|
super().__init__()
|
|
self.rp.create(self)
|
|
|
|
# 2. Add SSBO Component
|
|
# Pass your ShowBase instance (self), the RP instance (self.rp), and your model path
|
|
self.editor = SSBOEditor(
|
|
base_app=self,
|
|
render_pipeline=self.rp,
|
|
model_path="path/to/your/model.glb",
|
|
font_path="path/to/chinese/font.ttc" # Optional
|
|
)
|
|
|
|
app = MyApp()
|
|
app.run()
|
|
```
|
|
|
|
### 3. Key Features
|
|
|
|
- **SSBO Instancing**: Efficiently renders thousands of objects using hardware instancing.
|
|
- **Normal Correction**: Default shaders are patched to correctly handle non-uniform scaling (Inverse Transpose Normal Matrix).
|
|
- **ImGui Editor**: Built-in scene tree browsing, search, and selection.
|
|
- **Object Manipulation**: Select and move objects (Arrows + Z/X keys).
|
|
- **Shadow Integration**: Correctly injects SSBO data into RP shadow passes.
|
|
- **Motion Blur Support**: Computes per-object velocity for correct motion blur.
|
|
|
|
### 4. Notes
|
|
|
|
- **Model Preparation**: The input model should have a clear hierarchy. The component will flatten it but preserve logical objects for selection.
|
|
- **Effects Path**: The `ssbo_instancing.yaml` is loaded relative to the `ssbo_editor.py` file, so the directory structure inside `ssbo_component` should be preserved.
|
|
- **GPU Picking**: Basic GPU picking is implemented using shaders in `ssbo_component/shaders/`. These are loaded automatically relative to the component path.
|
|
|
|
## ⚠️ Important for RenderPipeline
|
|
|
|
If you encounter `ImportError: No module named 'rplibs.six.moves'`, ensure you apply the compatibility fix at the start of your main script (as seen in `demo_component.py`).
|