Back to Game Development

Module 3: 3D Graphics & Rendering

Master 3D modeling, materials, shaders, lighting, and create stunning game visuals

🎨 What is 3D Graphics?

Imagine sculpting a character from clay, painting it with colors, and then shining lights on it to make it look real! 3D graphics is the art and science of creating visual content for games. It combines modeling (shape), texturing (surface details), and lighting (atmosphere) to create believable worlds.

Simple Definition

3D Graphics is the process of creating three-dimensional objects and scenes that can be viewed from any angle. Unlike 2D images, 3D models have depth, volume, and can be lit from different directions to create realistic or stylized visuals.

The 3D Graphics Pipeline:

1. Model (3D shape) → 2. Texture (surface details) →

3. Material (how it reacts to light) → 4. Lighting (illumination) →

5. Rendering (final image on screen)

Why Learn 3D Graphics?

Visual Quality

Great graphics make games more immersive and appealing

Creative Expression

Bring your artistic vision to life in 3D space

Industry Skill

3D skills apply to games, film, VR, AR, and more

Performance Optimization

Understanding graphics helps you optimize game performance

📚 Learn More:

🗿 3D Modeling Basics with Blender

3D modeling is like digital sculpting! You start with basic shapes (cubes, spheres, cylinders) and transform them into characters, props, and environments. Blender is a free, professional-grade 3D modeling tool used by indies and studios alike.

Understanding 3D Meshes

A mesh is made of vertices (points), edges (lines between points), and faces (surfaces between edges). Think of it like a wireframe sculpture - the more vertices, the more detail you can have, but also the more processing power needed!

Mesh Components:

Vertices: Points in 3D space (X, Y, Z coordinates)

Edges: Lines connecting two vertices

Faces: Surfaces formed by 3+ edges (usually triangles or quads)

A cube has 8 vertices, 12 edges, and 6 faces!

Blender Basics

Essential Blender Controls

Middle Mouse: Rotate view

Shift + Middle Mouse: Pan view

Scroll Wheel: Zoom in/out

G: Grab/Move selected object

R: Rotate selected object

S: Scale selected object

Tab: Toggle Edit Mode

Shift + A: Add new object

X: Delete selected

Modeling Workflow

Start with primitive shapes (cube, sphere, cylinder), then use modifiers and editing tools to shape them into what you need.

1. Box Modeling: Start with cube, extrude and shape faces

2. Subdivision Surface: Add smoothness to blocky models

3. Mirror Modifier: Model one half, mirror for symmetry

4. Array Modifier: Duplicate objects in patterns

5. Boolean Operations: Combine or subtract shapes

💡 Modeling Tips for Games:

  • Keep poly count low: Mobile games: 1k-5k triangles, PC: 10k-50k
  • Use quads in modeling: Easier to work with, convert to triangles for export
  • Think modular: Create reusable pieces (walls, floors, props)
  • Scale matters: Keep consistent scale (1 Blender unit = 1 meter)

✨ Materials, Shaders, and Textures

Materials define how surfaces look - shiny metal, rough wood, transparent glass. Shaders are programs that calculate how light interacts with materials. Textures are images applied to surfaces to add detail without extra geometry.

Understanding Materials

A material is a collection of properties that define surface appearance. Think of it as a recipe: color, shininess, transparency, texture maps, etc.

Key Material Properties:

Albedo/Base Color: The main color of the surface

Metallic: Is it metal (1) or non-metal (0)?

Smoothness/Roughness: Shiny mirror or rough stone?

Normal Map: Fake surface bumps and details

Emission: Does it glow in the dark?

Transparency: Can you see through it?

Shader Basics

What is a Shader?

A shader is a program that runs on the GPU to calculate pixel colors. Unity provides built-in shaders (Standard, URP Lit, etc.) and you can write custom ones for special effects!

Standard Shader: Physically-based, realistic lighting

Unlit Shader: No lighting calculations, always bright

Toon Shader: Cartoon/cel-shaded look

Transparent Shader: For glass, water, ghosts

Custom Shaders: Special effects (dissolve, hologram, etc.)

Creating Materials in Unity

// Steps to create a material:

1. Right-click in Project → Create → Material

2. Select the material in Project window

3. In Inspector, choose shader (Standard, URP/Lit, etc.)

4. Adjust properties (color, metallic, smoothness)

5. Drag textures into texture slots

6. Drag material onto 3D object in scene

Texture Mapping

Texture mapping is wrapping a 2D image around a 3D model. UV coordinates (like X,Y but called U,V) tell the model which part of the texture goes where.

Common Texture Types:

Albedo/Diffuse: Base color texture

Normal Map: Adds surface detail (bumps, scratches)

Metallic Map: Which parts are metal (black/white)

Roughness Map: Shiny vs rough areas

Ambient Occlusion: Shadows in crevices

Emission Map: Glowing parts

🎨 Texture Best Practices:

  • Power of 2 sizes: 512x512, 1024x1024, 2048x2048 (GPU friendly)
  • Compress textures: Use DXT/BC compression to save memory
  • Texture atlases: Combine multiple textures into one (better performance)
  • Mipmaps: Enable for distant objects (prevents shimmering)

💡 Lighting and Shadows

Lighting is the most important factor in visual quality! Good lighting creates mood, guides players, and makes scenes believable. Shadows add depth and realism. Master lighting, and your games will look professional.

Types of Lights in Unity

Directional Light

Use for: Sun, moon, outdoor lighting

Simulates distant light source. All rays are parallel (like sunlight). Affects entire scene. Perfect for outdoor environments.

Point Light

Use for: Light bulbs, torches, explosions

Emits light in all directions from a point. Has range and intensity. Great for indoor lighting and dynamic effects.

Spot Light

Use for: Flashlights, car headlights, stage lights

Cone-shaped light beam. Has direction, range, and angle. Perfect for focused lighting and dramatic effects.

Area Light

Use for: Windows, TV screens, soft lighting

Rectangular light source. Creates soft, realistic shadows. Only works with baked lighting (not real-time).

Lighting Modes

Realtime Lighting

Calculated every frame. Lights can move, change color, turn on/off. Most expensive but most flexible. Use sparingly!

Baked Lighting

Pre-calculated and saved to textures (lightmaps). Very fast at runtime but lights can't move. Perfect for static environments!

Mixed Lighting

Combination of both. Static objects use baked lighting, dynamic objects use realtime. Best balance of quality and performance!

Shadow Settings

Shadow Quality vs Performance

No Shadows: Fastest, but looks flat

Hard Shadows: Fast, sharp edges (good for stylized games)

Soft Shadows: Slower, realistic soft edges

Shadow Distance: How far shadows render (lower = faster)

Shadow Resolution: Higher = sharper but more memory

💡 Lighting Tips:

  • Three-point lighting: Key light (main), fill light (soften shadows), rim light (outline)
  • Color temperature: Warm (orange) for cozy, cool (blue) for mysterious
  • Contrast: Mix bright and dark areas to guide player attention
  • Ambient light: Add subtle fill light so nothing is completely black
  • Light probes: Use for dynamic objects in baked scenes

🎬 Post-Processing Effects

Post-processing effects are applied after the scene is rendered, like Instagram filters for your game! They can dramatically improve visual quality with effects like bloom, color grading, depth of field, and more.

Common Post-Processing Effects

Bloom

Makes bright areas glow and bleed into surroundings. Perfect for magical effects, neon lights, and sci-fi aesthetics. Don't overdo it!

Color Grading

Adjust overall color tone and mood. Make scenes warmer, cooler, more saturated, or desaturated. Essential for establishing atmosphere!

Depth of Field

Blurs objects based on distance from camera, like a real camera lens. Focuses player attention and adds cinematic quality.

Ambient Occlusion

Adds subtle shadows in corners and crevices. Makes scenes look more grounded and realistic. Small performance cost, big visual impact!

Motion Blur

Blurs fast-moving objects. Can make movement feel smoother but some players dislike it. Use sparingly or make it optional!

Vignette

Darkens screen edges. Focuses attention on center and adds cinematic feel. Subtle effect with big impact on composition.

Setting Up Post-Processing in Unity

For URP (Universal Render Pipeline):

1. Install Post Processing package (Window → Package Manager)

2. Create Post-Process Volume (GameObject → Volume → Global Volume)

3. Create Volume Profile (click "New" in Inspector)

4. Add effects (Add Override → choose effects)

5. Adjust settings for each effect

6. Enable Post Processing on your camera

⚠️ Performance Tips:

  • • Post-processing has performance cost - test on target hardware!
  • • Mobile: Use sparingly, avoid expensive effects like depth of field
  • • PC: Can use more effects, but still optimize
  • • Combine effects wisely - too many can tank framerate
  • • Make effects optional in settings for player choice

🎯 Complete Example: Beautiful 3D Scene

Let's create a complete, visually stunning 3D scene in Unity using everything we've learned - models, materials, lighting, and post-processing!

Project: Stylized Environment

Step 1: Create the Base Scene

1. Create new Unity project (URP template for better graphics)

2. GameObject → 3D Object → Plane (ground, scale to 20x20)

3. Add some cubes and cylinders for buildings/props

4. Position camera at interesting angle (not straight-on)

Step 2: Create Materials

Ground Material:

• Create Material, name it "Ground"

• Shader: URP/Lit

• Base Color: Earthy green (#4a7c59)

• Smoothness: 0.2 (rough)

• Metallic: 0

Building Material:

• Create Material, name it "Building"

• Base Color: Light gray (#cccccc)

• Smoothness: 0.5

• Add subtle normal map for texture

Accent Material (glowing):

• Create Material, name it "Glow"

• Base Color: Bright cyan (#00ffff)

• Emission: Enable, same cyan color

• Emission Intensity: 2

Step 3: Set Up Lighting

Main Light (Sun):

• Use existing Directional Light

• Rotation: (50, -30, 0) for nice angle

• Color: Warm white (#fffacd)

• Intensity: 1.5

• Shadows: Soft Shadows

Fill Light:

• Add new Directional Light

• Rotation: (-30, 150, 0) opposite side

• Color: Cool blue (#add8e6)

• Intensity: 0.3 (subtle)

• Shadows: None

Accent Lights:

• Add Point Lights near glowing objects

• Match emission color

• Range: 5-10

• Intensity: 2-3

Step 4: Add Post-Processing

1. GameObject → Volume → Global Volume

2. Create new Profile

3. Add Override → Bloom

• Intensity: 0.3

• Threshold: 1.0

4. Add Override → Color Adjustments

• Saturation: 10 (slightly more vibrant)

• Contrast: 5

5. Add Override → Vignette

• Intensity: 0.3

6. Add Override → Ambient Occlusion

• Intensity: 0.5

Step 5: Polish

• Add skybox (Window → Rendering → Lighting → Skybox Material)

• Adjust camera FOV (Field of View) for cinematic look (60-70)

• Add fog (Window → Rendering → Lighting → Fog)

• Bake lighting for better quality (Window → Rendering → Lighting → Generate Lighting)

Advanced: Custom Toon Shader

// Simple Toon Shader (Shader Graph or code)

// This creates a cel-shaded, cartoon look

Shader "Custom/ToonShader"

{

Properties

{

_Color ("Color", Color) = (1,1,1,1)

_RampTex ("Ramp Texture", 2D) = "white" {}

}

SubShader

{

Tags { "RenderType"="Opaque" }

Pass

{

CGPROGRAM

#pragma vertex vert

#pragma fragment frag

float4 _Color;

sampler2D _RampTex;

// Calculate lighting in discrete steps

float NdotL = dot(normal, lightDir);

float lightIntensity = smoothstep(0, 0.01, NdotL);

float4 light = lightIntensity * _LightColor0;

return _Color * light;

ENDCG

}

}

}

🎓 What You've Created:

  • • Complete 3D scene with proper composition
  • • Multiple materials with different properties
  • • Three-point lighting setup for professional look
  • • Post-processing stack for enhanced visuals
  • • Understanding of how all graphics elements work together
  • • Foundation for creating any visual style you want!

📚 Learning Resources

3D Modeling

Unity Graphics

🎯 What's Next?

You now understand 3D graphics and rendering! In the next module, we'll dive into Game Physics and Math - learning vectors, collision detection, rigidbody physics, raycasting, and pathfinding algorithms to make your games feel realistic and responsive!