Pure Go 3D rendering library
Scene graph, PBR materials, GLTF loading. Zero CGO.
Built on gogpu/wgpu (Vulkan/Metal/DX12/GLES/Software).
g3d is a 3D rendering library — not a game engine. It provides the building blocks (scene graph, cameras, lights, materials, mesh loading) that game engines, CAD viewers, data visualizers, and AR/VR applications build upon.
Think of it like Three.js for Go: simple API, powerful rendering, zero opinion about your application architecture.
package main
import (
"github.com/gogpu/gogpu"
"github.com/gogpu/g3d"
)
func main() {
app := gogpu.NewApp(gogpu.Config{Title: "g3d Hello", Width: 800, Height: 600})
renderer := g3d.NewRenderer(app)
scene := g3d.NewScene()
scene.Add(g3d.NewAmbientLight(g3d.White, 0.3))
scene.Add(g3d.NewDirectionalLight(g3d.White, 1.0))
cube := g3d.NewMesh(g3d.NewBoxGeometry(1, 1, 1), g3d.NewStandardMaterial())
scene.Add(cube)
camera := g3d.NewPerspectiveCamera(75, 800.0/600.0, 0.1, 1000)
camera.Position = g3d.Vec3{0, 0, 3}
app.OnUpdate(func(dt float64) {
cube.Rotation.Y += float32(dt)
})
app.OnDraw(func(_ *gogpu.Context) {
renderer.Render(scene, camera)
})
app.Run()
}- Scene graph — hierarchical Node tree with parent-child transform propagation
- Cameras — Perspective and Orthographic with configurable clip planes
- Geometries — Box, Sphere, Plane, Cylinder, Cone, Torus + custom BufferGeometry
- Renderer — Forward rendering with 3-bucket sorting (opaque, alpha mask, transparent)
- Frustum culling — automatic visibility testing against camera frustum
- BasicMaterial — unlit, for prototyping and data visualization
- StandardMaterial — PBR metallic-roughness (GLTF standard), production quality
- ShaderMaterial — custom WGSL shaders for advanced users
- DirectionalLight — sun-like parallel light with shadow mapping
- PointLight — omnidirectional light with distance attenuation
- SpotLight — focused cone light with soft edges
- AmbientLight — uniform environment lighting
- GLTF 2.0 — binary (.glb) and JSON (.gltf) with PBR materials, animations, scene hierarchy
- Textures — PNG, JPEG, HDR for environment maps
- Zero-alloc render path — no GC pressure during frame rendering
- Instance batching — thousands of objects with minimal draw calls
- Pipeline specialization cache — compile shader variants once, reuse forever
- 4-level draw grouping — RenderPass → Pipeline → Material → Mesh → Instances
g3d deliberately does not include:
| Feature | Why Not | Where to Get It |
|---|---|---|
| Entity Component System | Game engine concern | Build on top, or use external ECS |
| Physics | Simulation concern | Integrate Bullet, ODE, or Pure Go physics |
| Audio | Unrelated to rendering | Use Oto, Beep, or platform audio |
| Networking | Unrelated to rendering | Use net/http, gRPC, WebSocket |
| Scripting | Engine concern | Use Lua/Wasm/Yaegi on top |
| Scene editor | Tool concern | Build with gogpu/ui + g3d |
This separation means g3d is reusable everywhere — game engines, CAD tools, scientific visualizations, AR/VR, data dashboards.
g3d renders through gogpu/wgpu, which supports:
| Backend | Platforms | Status |
|---|---|---|
| Vulkan | Windows, Linux | Stable |
| Metal | macOS | Stable |
| DirectX 12 | Windows | Stable |
| OpenGL ES | Windows, Linux | Stable |
| Software | All | Fallback |
All backends are Pure Go — zero CGO, single binary deployment.
g3d works without the gogpu application framework. Bring your own window and GPU device:
// Use g3d with any wgpu.Device — no gogpu dependency required
device, queue := myCustomGPUSetup()
renderer := g3d.NewRendererFromDevice(device, queue)
scene := g3d.NewScene()
// ... build your scene
renderer.Render(scene, camera)Your Application (game engine, CAD viewer, data viz, AR/VR)
|
gogpu/g3d — Scene Graph + PBR + GLTF + Render Pipeline
|
gogpu/wgpu — Pure Go WebGPU (Vulkan/Metal/DX12/GLES)
|
gogpu/naga — Shader Compiler (WGSL → SPIR-V/MSL/GLSL/HLSL)
g3d depends down (wgpu, naga), never up (gogpu, gg, ui). This ensures it can be used in any context.
go get github.com/gogpu/g3dRequirements: Go 1.25+
| Phase | Features | Status |
|---|---|---|
| Phase 1 | Scene graph, cameras, basic materials, box/sphere/plane, renderer | Planned |
| Phase 2 | PBR lighting, shadows, StandardMaterial, normal maps | Planned |
| Phase 3 | GLTF 2.0 loader, skeletal animation, morph targets | Planned |
| Phase 4 | Instance batching, environment maps, post-processing, skybox | Planned |
| Phase 5 | Frustum culling BVH, LOD, SIMD math, pipeline cache | Planned |
- Simple API — 15 lines for a lit rotating cube. Progressive complexity.
- Zero CGO — Pure Go on all platforms. Single binary deployment.
- Reusable — rendering library, not a framework. No opinions about your architecture.
- PBR from day one — metallic-roughness workflow, GLTF standard.
- Zero-alloc rendering — no GC pressure in the hot path.
- All GPU backends — Vulkan, Metal, DX12, GLES, Software through wgpu.
We welcome contributions! Priority areas:
- GLTF loading — parser and material mapping
- Shader development — PBR, shadows, post-processing in WGSL
- Geometry primitives — additional built-in shapes
- Examples — showcase real-world usage
- Testing — cross-platform GPU rendering tests
g3d is part of GoGPU — a Pure Go GPU computing ecosystem with 632K+ lines of code.
| Library | Purpose |
|---|---|
| gogpu | Application framework, windowing |
| wgpu | Pure Go WebGPU (Vulkan/Metal/DX12/GLES) |
| naga | Shader compiler (WGSL → SPIR-V/MSL/GLSL/HLSL) |
| gg | 2D graphics with GPU acceleration |
| g3d | 3D rendering (this library) |
| ui | GUI toolkit (22+ widgets, 4 themes) |
| systray | System tray (Win32/macOS/Linux) |
MIT License — see LICENSE for details.