Tag Archives: light

Lighting in PlayCanvas

In this tutorial you will learn how to add and modify lighting in your game. You can use different types of lights and have multiple lights in any scenes to change the feel and atmosphere of the game. The three types of lights you can use are:

  • Directional light – light rays come from one direction
  • Point light – a sphere of light that shines in all directions
  • Spot light – a cone of light

Watch the video below to see how you can use lighting in your own PlayCanvas game.

Adding fog and lens flares to a scene in Unity

This video explains how to add fog and lens flares to your 3D game scene in Unity. Watch the video below and scroll down to see some of the sample fog and lens flare images.

Here are some examples of fog applied to a scene in Unity.

A light fog (in Scene mode).
A light fog (in Scene mode).
Thick fog (in Game mode).
Thick fog (in Game mode).

Here are some examples of lens flares in Unity.

A 50mm Zoom flare in Unity.
A 50mm Zoom flare in Unity.
A Sun Flare in Unity.
A Sun Flare in Unity.
A Small Flare in Unity.
A Small Flare in Unity.

Lighting in Unity

This video explains how to add different types of lighting to your 3D game environment in Unity. Different types of lights can be used for different purposes in a game. For example, light could emit from headlights on a car, a lantern held by a player, a street light, a lamp in a room, or a sun in a solar system.

Here are some examples of the different types of lighting available in Unity. Scroll down to watch the video.

A directional light setup in Unity
A directional light setup in Unity
A point light setup in Unity.
A point light setup in Unity.
A spotlight setup in Unity.
A spotlight setup in Unity.

Watch the video below to find out how to add lighting to your own 3D game project in Unity.

Basic lighting and emitting light from objects in Maya

This tutorial explains how to use lights in Maya and also how to emit light from an object such as the Sun or a light bulb (so that it glows). Please note that this video is a basic overview to get you started with some of the many lights and lighting effects you can use in Maya. You can also download printed instructions here.

Adding light decay

You can download the instructions from here if you would like light in your project to lose its intensity or reach over a distance.

Making an LED Sensor Light with Arduino

This video tutorial explains how to use an Arduino Uno to make an LED light. A light sensor will detect low-light conditions to turn on an LED and also turn off an LED when light is present.

The project involves an Arduino Uno board, an LED, a light sensor which can detect different levels of light and return a value, and a breadboard with jumper wires.

The way the project works is as follows. Use the light sensor to get light readings constantly. You can specify a value which, when the light is less than this value an LED light will be turned on, and when the light is greater than this value the LED light will be turned off.

This project allows you to work with getting readings from a sensor (input), use if statements to test conditions, and use an LED to produce some form of output.

Click Tools > Serial Monitor and set to 9600 baud to view the light sensor readings received from the Arduino when it is connected via USB to the computer.

Watch the video below or click here to view it on YouTube.

Downloads:

The source code is also available here:

int led = 13;
int lightReading = 0;

void setup () {
  pinMode(led, OUTPUT);
  Serial.begin(9600);
}

void loop () {
  lightReading = analogRead(A2);
  Serial.println(lightReading, DEC);
  if (lightReading < 50) // change this value to suit light conditions. Ranges from 0 (very dark) to 1023 (very bright).
  {
    digitalWrite(led, HIGH); // turns the light on
    Serial.println("light on");
  } 
  else
  {
    digitalWrite(led, LOW); // turns the light off
    Serial.println("light off");
  }
  // Delay of 1000ms before checking light level again
  delay(1000);
  
}

Diagram and photos

ArduinoLDR

The photos below show the same layout although a 470 Ohm resistor is also being used.

1

2 3

Light sensor readings
Light sensor readings

Blinking LED Arduino project

This video tutorial has been designed for those just starting out with Arduino. For this beginner project you will need an Arduino Uno board (or compatible board), an LED of any colour, a 470-Ohm resistor, two jumper wires, a breadboard, a male A-B USB cable, and a computer (Mac/Windows) with the Arduino IDE software installed.

This project involves programming your Arduino Uno to make an LED light blink on and off. To get started, watch the video below or click here to view it on YouTube. Access the links below to get a copy of the code, printed instructions, schematic, and a guide to resistors.

Downloads:

The source code is also available here:

/*
 Blink
 Turns on an LED on for one second, then off for one second, repeatedly.
*/
 
// Give the LED a name - it will be connected on PIN 13
int led = 13;
 
// the setup routine runs once when you press reset:
void setup() { 
 // initialize the digital pin as an output.
 pinMode(led, OUTPUT); 
}
 
// the loop routine runs over and over again forever:
void loop() {
 digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
 delay(1000); // wait for a second (1000 = 1 sec.)
 digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
 delay(1000); // wait for a second
}

Photos

1 2 3 4