3d-games
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese3D Game Development
3D游戏开发
Principles for 3D game systems.
3D游戏系统开发原则
1. Rendering Pipeline
1. 渲染管线(Rendering Pipeline)
Stages
阶段
1. Vertex Processing → Transform geometry
2. Rasterization → Convert to pixels
3. Fragment Processing → Color pixels
4. Output → To screen1. Vertex Processing → 变换几何图形
2. Rasterization → 转换为像素
3. Fragment Processing → 为像素上色
4. Output → 输出到屏幕Optimization Principles
优化原则
| Technique | Purpose |
|---|---|
| Frustum culling | Don't render off-screen |
| Occlusion culling | Don't render hidden |
| LOD | Less detail at distance |
| Batching | Combine draw calls |
| 技术 | 目的 |
|---|---|
| Frustum culling | 不渲染屏幕外的对象 |
| Occlusion culling | 不渲染被遮挡的对象 |
| LOD | 远处对象使用低细节模型 |
| Batching | 合并绘制调用 |
2. Shader Principles
2. Shader 原理
Shader Types
Shader 类型
| Type | Purpose |
|---|---|
| Vertex | Position, normals |
| Fragment/Pixel | Color, lighting |
| Compute | General computation |
| 类型 | 用途 |
|---|---|
| Vertex | 处理位置、法线 |
| Fragment/Pixel | 处理颜色、光照 |
| Compute | 通用计算 |
When to Write Custom Shaders
何时编写自定义 Shader
- Special effects (water, fire, portals)
- Stylized rendering (toon, sketch)
- Performance optimization
- Unique visual identity
- 特殊效果(如水、火、传送门)
- 风格化渲染(卡通、手绘风格)
- 性能优化
- 打造独特视觉风格
3. 3D Physics
3. 3D 物理系统
Collision Shapes
碰撞形状
| Shape | Use Case |
|---|---|
| Box | Buildings, crates |
| Sphere | Balls, quick checks |
| Capsule | Characters |
| Mesh | Terrain (expensive) |
| 形状 | 使用场景 |
|---|---|
| Box | 建筑物、板条箱 |
| Sphere | 球体、快速检测 |
| Capsule | 角色 |
| Mesh | 地形(性能开销高) |
Principles
核心原则
- Simple colliders, complex visuals
- Layer-based filtering
- Raycasting for line-of-sight
- 碰撞器用简单形状,视觉模型用复杂细节
- 基于层级的过滤
- 用射线检测实现视野判断
4. Camera Systems
4. 相机系统
Camera Types
相机类型
| Type | Use |
|---|---|
| Third-person | Action, adventure |
| First-person | Immersive, FPS |
| Isometric | Strategy, RPG |
| Orbital | Inspection, editors |
| 类型 | 用途 |
|---|---|
| Third-person | 动作、冒险类游戏 |
| First-person | 沉浸式、FPS游戏 |
| Isometric | 策略、RPG类游戏 |
| Orbital | 场景检查、编辑器 |
Camera Feel
相机体验优化
- Smooth following (lerp)
- Collision avoidance
- Look-ahead for movement
- FOV changes for speed
- 平滑跟随(使用lerp插值)
- 碰撞避让
- 移动时提前预判视角
- 根据速度调整FOV(视野)
5. Lighting
5. 光照系统
Light Types
光照类型
| Type | Use |
|---|---|
| Directional | Sun, moon |
| Point | Lamps, torches |
| Spot | Flashlight, stage |
| Ambient | Base illumination |
| 类型 | 用途 |
|---|---|
| Directional | 模拟太阳、月亮光照 |
| Point | 台灯、火把等光源 |
| Spot | 手电筒、舞台聚光灯 |
| Ambient | 基础环境照明 |
Performance Consideration
性能注意事项
- Real-time shadows are expensive
- Bake when possible
- Shadow cascades for large worlds
- 实时阴影性能开销高
- 尽可能使用烘焙阴影
- 大型场景使用级联阴影
6. Level of Detail (LOD)
6. 细节层级(LOD)
LOD Strategy
LOD 策略
| Distance | Model |
|---|---|
| Near | Full detail |
| Medium | 50% triangles |
| Far | 25% or billboard |
| 距离 | 模型细节 |
|---|---|
| 近处 | 全细节模型 |
| 中距离 | 保留50%三角形 |
| 远处 | 保留25%三角形或使用公告板 |
7. Anti-Patterns
7. 反模式
| ❌ Don't | ✅ Do |
|---|---|
| Mesh colliders everywhere | Simple shapes |
| Real-time shadows on mobile | Baked or blob shadows |
| One LOD for all distances | Distance-based LOD |
| Unoptimized shaders | Profile and simplify |
Remember: 3D is about illusion. Create the impression of detail, not the detail itself.
| ❌ 错误做法 | ✅ 正确做法 |
|---|---|
| 到处使用网格碰撞器 | 使用简单碰撞形状 |
| 移动端使用实时阴影 | 使用烘焙阴影或 blob 阴影 |
| 所有距离使用同一LOD | 基于距离设置LOD |
| 使用未优化的Shader | 分析并简化Shader |
要点提示: 3D游戏的核心是营造视觉错觉,无需真实还原所有细节,只需让玩家感受到细节即可。