Making a Simple Game - Part 2: Lighting and Materials
In Part 1 you placed the stadium and the ball. In this part you light them. One image of a sky will become both the background and a source of light from every direction, and the ball will get a glossy finish that shows it off.
You need the project you made in Part 1. To compare your work, open the finished project.
1. Make a Cubemap from the Sky
The Textures folder holds stadium-sky.png, a panorama of a sky above a green field. PlayCanvas uses a sky like this as a cubemap: six square images that surround the scene.
- In the Assets panel, open Textures and right-click
stadium-sky.png. - Select Create Cubemap. The Editor adds six face textures and a cubemap called
stadium-sky_cubemap. - Select the cubemap. At the bottom of the Inspector, under Prefiltering, select PREFILTER CUBEMAP. When it has finished, the button changes to DELETE PREFILTERED DATA.

Prefiltering makes blurred copies of the sky. A rough surface reflects a blurred sky and a polished one reflects a sharp sky, so the engine needs both. This is called image-based lighting.
2. Set the Skybox
- Select the cog icon at the bottom of the toolbar to open Settings, and expand Rendering.
- Drag
stadium-sky_cubemapfrom the Assets panel onto the Skybox slot.
The Viewport now has a sky, and everything in the scene is lit by it: blue from above and green from below.
3. Choose the Tone Mapping
Tone mapping decides how the bright values in the rendered picture are fitted into the range a screen can show. It is a property of each camera.
- Select Camera.
- In the Camera Component, set Tonemapping to Neutral.
Neutral keeps colors close to the ones you chose, which suits the bright, simple look of this game. Try the other options to see how each one changes the picture.
4. Cast Shadows
A shadow on the pitch shows the player where the ball is.
- Select Light.
- In the Light Component, check that Cast Shadows is turned on. It already is for the Light in a new project.
- Set Resolution to
2048 x 2048, Cascades to2and Distance to420. - Set Shadow Bias to
0.3and Normal Offset Bias to0.2.
Distance is how far from the camera shadows are drawn. The stadium is large, so it has to be large too. Cascades splits that distance into ranges with a shadow map each, which keeps the ball's shadow sharp. The two bias values stop surfaces from shadowing themselves at this scale.
5. Polish the Ball
The football uses three materials: Ball Light for the white panels, Ball Dark for the black ones and Ball Seam for the grooves between them. They are in Models > Football.
- Select
Ball Lightand expand Clearcoat in the Inspector. - Set Clear Coat Factor to
0.4. More settings appear below it. - Under Clear Coat Gloss, set Glossiness to
0.85. - Do the same for
Ball Dark.
Clear coat adds a thin glossy layer over the material, like varnish. The ball now picks up a reflection of the sky.
While you have a material open, look at its other sections:
- Diffuse sets the base color. Change the Color of
Ball LightandBall Darkto put the ball in your own team's colors. - Specular holds Metalness and Glossiness, which decide how mirror-like the surface is.
The stadium's materials, in Models > Stadium, show three more techniques. Crowd takes its color from a texture in its Diffuse slot. Boards also has its texture in the Emissive slot, so the advertising boards glow like screens. In its Opacity section, Net has an Intensity below 1 and a Blend Type of Alpha, which makes the goal net see-through.
Check Your Progress
Launch the game again:

The scene has its finished look, but it is still a picture. In Part 3: Making the Ball Move you write the scripts that turn it into something you can play.