Class hours: 10:05 – 2:45
Mr. Bohmann | wbohmann@ewsd.org
10:05 Today’s Notes & Attendance
- Week 34
- Catching up / Past Dayplans – remember the dayplans are your reference materials. Code, terminology, what we covered can be found in the dayplans.
- Team Game Dev Projects – Due tomorrow
- Demo of playable game by 1pm
10:10 Lighting in Unity
Lighting is a nice way to give your level, scene, interaction some more personality. There are several light types, let’s explore a few.
FIRST: Let’s Create a New Scene together, add the Modular Character Controller and a small 3 sided room with ProBuilder Tools or regular 3D objects. In the Middle of your room, add three boxes (we’ll pretend they are crates)
The Skybox is a a lighting option for your scene. Skyboxes can be made from an HDRI or Procedural. Both options require using the Skybox shader. Let’s customize our lightbox options.
Directional Light is most like the Sun. You can change direction and rotation but it is always shining and illuminates everything in one direction only. This is a Realtime Light.
Realtime lighting is lighting that shows up during game time, interacts with other objects in the game and is dynamic. Realtime lighting is resource heavy. Good for times when you want to show the environment changing over time (like night and day cycle) and how objects interact with it.
Baked Lighting is lighting that does that is used to create mood and ambiance. The light is pre calculated before game run time – so it does not use a lot of resources. In order for light data to be captured, objects must be set to Static (or accept global illumination)
Mixed Lighting is a combination of both. Lights data can be baked, however the light can also interact with other game objects during run time, allowing for more intractability (shadows, etc…)
Point and Spot lights control the location, direction and rotation of lights. Let’s look at each.
Point Lights emits light in all directions
Spot Lights include a falloff value and emits light in a cone shape
Both of these lights can be set to Realtime, baked or Mixed. However, Unity limits how many realtime lights you can have. Checkout Windows/Light Explorer for a summary
Area Lights are defined by a rectangle or disc shape and emits light in all directions uniformly from its surface but only from one side of the mesh. Area Lights require baking to be able to view. Also, we must set objects to static if we want the light to impact them.
ProTip: When baking lighting, change to GPU and set the environment samples down for faster bake times – which is good for testing
We can also make lights out of gameObject by making them emissive. An emissive material will emit light on to other game objects if (and only if) those game objects are static. To make an emissive material work, we have to bake (render the lightmaps) to the scene. Let’s try.
Volumes are a great way to add nice effects to your scene. We can create post processing effects globally or locally. In order to render the post-processing effects, we’ll need to enable post processing on our camera. Then we’ll create some volume effects either locally or globally depending on what your scene demands. Let’s look at some features. there too.
To add Post Processing, we’ll need to head over to the package manager and install. We’ll add a Post-Processing Layer to the Camera and add a Post Processing Volume game object to our scene. The camera will see the post processing.
Assignment: Using your Modeling skillsets with Blender or ProBuilder Tools, set up a static scene in Unity and create a nice rocky path illuminated. Use materials and lighting in Unity for your scene. Don’t forget the work we did with terrain tools. Remember those? You’ll have to add from the package manager. Render as a nice .jpg. Assignment is due on Monday, May 20th.
Light Flicker Code
using UnityEngine;
using System.Collections.Generic;
// Written by Steve Streeting 2017
// License: CC0 Public Domain http://creativecommons.org/publicdomain/zero/1.0/
/// <summary>
/// Component which will flicker a linked light while active by changing its
/// intensity between the min and max values given. The flickering can be
/// sharp or smoothed depending on the value of the smoothing parameter.
///
/// Just activate / deactivate this component as usual to pause / resume flicker
/// </summary>
public class LightFlickerEffect : MonoBehaviour
{
[Tooltip("External light to flicker; you can leave this null if you attach script to a light")]
public Light light;
[Tooltip("Minimum random light intensity")]
public float minIntensity = 0f;
[Tooltip("Maximum random light intensity")]
public float maxIntensity = 1f;
[Tooltip("How much to smooth out the randomness; lower values = sparks, higher = lantern")]
[Range(1, 50)]
public int smoothing = 5;
// Continuous average calculation via FIFO queue
// Saves us iterating every time we update, we just change by the delta
Queue<float> smoothQueue;
float lastSum = 0;
/// <summary>
/// Reset the randomness and start again. You usually don't need to call
/// this, deactivating/reactivating is usually fine but if you want a strict
/// restart you can do.
/// </summary>
public void Reset()
{
smoothQueue.Clear();
lastSum = 0;
}
void Start()
{
smoothQueue = new Queue<float>(smoothing);
// External or internal light?
if (light == null)
{
light = GetComponent<Light>();
}
}
void Update()
{
if (light == null)
return;
// pop off an item if too big
while (smoothQueue.Count >= smoothing)
{
lastSum -= smoothQueue.Dequeue();
}
// Generate random new item, calculate new average
float newVal = Random.Range(minIntensity, maxIntensity);
smoothQueue.Enqueue(newVal);
lastSum += newVal;
// Calculate new smoothed average
light.intensity = lastSum / (float)smoothQueue.Count;
}
}
10:50 Break
11:00 English with Mx. Yopp
11:50 CAWD Fun Games Studio
This is a work session for Finnder and Wal-Martial Law game studios.
Deliverables
To be successful as a team, you need to know the deliverables:
- One Game Design Document
- A playable game (prototype is fine) Simmer.io or published as .exe file
- A Home Screen with Game Title
- Play Button that opens the game
- Credits Button that opens Credits Screen (credits list roles of all team members)
Tomorrow at 1pm:
- A representative will share the story of the team
- Process
- Successes
- Challenges
- Organizational Strategies
- Game Overview
- Sample Gameplay
12:25 – 12:55 Lunch
12:55 Independent Reading
1:20 Break
1:30 Design Challenge
1:55 Production Time and Guided Support
One Button Game proposal
2:40 Dailies
Dailies can be placed in the CAWD2 Dailies Folder on the CAWD2 Public Folders drive