No description
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| Everyone-together-my-little-pony-friendship-is-magic-29790647-813-6061.ppm | ||
| Makefile | ||
| README.md | ||
| scop.en.subject.pdf | ||
SCOP - Modern 3D Object Viewer (WGPU & Rust)
📋 Overview
SCOP is a high-performance, cross-platform 3D object renderer built with Rust and WGPU. Originally based on OpenGL/Glium, this project has been modernized to use the WebGPU standard, allowing it to run natively on Vulkan, DirectX 12, Metal, and in the browser via WebAssembly.
It features a robust rendering engine capable of loading various 3D model formats (OBJ, FBX, GLTF) and image textures (PNG, JPG), with smooth interactive controls and efficient resource management.
🎯 Project Objectives
- Modern Graphics Stack: Utilize WGPU for next-gen graphics API support.
- Universal Asset Loading: Support industry-standard formats via Assimp.
- Cross-Platform: Compile for Desktop (Windows/Linux/macOS) and Web (WASM).
- Performance: Efficient rendering loop with 60 FPS cap and low CPU usage.
- Interactivity: Smooth transitions, auto-rotation, and dynamic coloring.
✨ Features
Core Features
| Feature | Description |
|---|---|
| WGPU Rendering | Runs on Vulkan, DX12, Metal, and WebGL2/WebGPU. |
| Universal Loader | Loads OBJ, FBX, GLTF, PLY, STL via russimp (Assimp). |
| Texture Support | Loads PNG, JPG, BMP, TIFF via image crate. |
| Efficient Loop | Smart event loop with ControlFlow::WaitUntil for 60 FPS cap. |
| Shader System | Modern WGSL shaders for vertex and fragment processing. |
| Interactive Camera | Look-At camera with smooth axis switching. |
| Dynamic Visuals | "Lizard mode" color animation and texture blending. |
🛠️ Technical Stack
| Component | Technology |
|---|---|
| Language | Rust (Edition 2024) |
| Graphics API | WGPU (WebGPU implementation) |
| Windowing | Winit 0.29 |
| Model Loading | Russimp (Assimp bindings) |
| Texture Loading | Image crate |
| Shaders | WGSL (WebGPU Shading Language) |
📦 Project Structure
scop/
├── Cargo.toml # Dependencies (wgpu, winit, russimp, image)
├── README.md # This file
└── src/
├── main.rs # WGPU setup, event loop, rendering logic
├── obj_parcer.rs # Model and texture loading abstraction
└── shader.wgsl # Vertex and Fragment shaders
🔧 Building
Prerequisites
- Rust Toolchain: Install via rustup.rs.
- LLVM/Clang: Required for
russimpbindings.- Windows:
winget install LLVM.LLVM - Linux:
sudo apt install llvm-dev libclang-dev clang - macOS:
brew install llvm
- Windows:
Environment Setup (Windows)
Ensure libclang.dll is in your path or set the environment variable:
$env:LIBCLANG_PATH = "C:\Program Files\LLVM\bin"
Compile & Run
# Run with arguments
cargo run <model_path> <texture_path>
# Example
cargo run models/car.obj textures/car_skin.png
🚀 Usage
./target/debug/scop <model_path> <texture_path>
Arguments
| Argument | Description |
|---|---|
model_path |
Path to the 3D file (OBJ, FBX, GLTF, etc.) |
texture_path |
Path to the texture image (PNG, JPG, etc.) |
⌨️ Controls
| Key | Action |
|---|---|
Q |
Toggle texture/color mode (smooth transition) |
T |
Toggle dynamic color animation ("lizard mode") |
W |
Switch to X-axis rotation |
E |
Switch to Y-axis rotation |
R |
Switch to Z-axis rotation |
Y |
Reverse rotation direction |
A / Z |
Move along X-axis (+/-) |
S / X |
Move along Y-axis (+/-) |
D / C |
Move along Z-axis (+/-) |
🧮 Technical Implementation
WGPU Pipeline
- Initialization: Async adapter request -> Device/Queue creation.
- Resources: Vertex/Index buffers created via
bytemuckcasting. - Uniforms: Rotation/Translation matrices updated CPU-side and copied to GPU uniform buffer.
- Shaders: WGSL shaders handle projection and texture sampling.
- Render Pass: Clears screen, binds groups, draws indexed geometry.
Asset Loading
- Models: Uses
russimpto post-process (triangulate, flip UVs, generate normals) and load mesh data. - Textures: Uses
imagecrate to decode bytes into RGBA8 format for WGPU textures.
📄 License
This project is part of the 42 Network curriculum / 1337.
Modernized for the Moroccan Market & Web Deployment