Skip to content

Tutorials · Light and Shadow · Chapter 1

Light starts from darkness

15 minutes Uses: AmbientLight

By the end

  • The starter open in the editor: the hall composed, and no light in it
  • An ambient node whose Ambient Light sets the hall’s darkness to a cold near-black, 0.08, 0.09, 0.16
  • Why the hall still looks the same, and when it will not
On this page

The starter

Light and Shadow does not start from an empty folder. It starts from a project with the hall built and no light in it, so that everything you add from here is a light, or something that blocks, shapes or answers one.

  1. Download light-and-shadow.zip, the starter (the overview says what is in it), and unzip it somewhere outside your other projects. You get one folder, light-and-shadow.
  2. Open Rengy. In the launcher, choose Open project… and pick the light-and-shadow folder.
  3. The editor opens the project’s startup scene, scenes/hall.ron. On the toolbar, click Look through, so that the Viewport shows the hall as the game’s camera sees it.
The editor on the starter, looking through the game camera: the Hierarchy lists Hall and the fourteen nodes under it, from camera to rune_c, the last five greyed out as hidden; the Viewport shows the hall at full brightness, a night-blue wall painted with a bright arched window, two round patches of warm bricks with a lantern each, two short pillars and a floor of green stone caps; the Inspector says nothing is selected

The Hierarchy holds Hall, and fourteen nodes under it. camera frames the hall. wall is the back wall: one painted picture, with its window, its arches and its lanterns painted in. window_glass is the window’s glass as a picture of its own, over the painted one. floor is a tile layer, the stone along the bottom. pillar_left and pillar_right are the two short pillars.

lantern_1, lantern_2 and lantern_3 are nodes laid exactly over the three painted lanterns. The first two hang over round patches of painted warm bricks. The third hangs on the bay’s right wall, over green stone with no glow painted round it. The five greyed names, door, arch, rune_a, rune_b and rune_c, are hidden until chapters 8 and 9.

The camera shows 640 by 360 world units, drawn at twice their size in a 1280 by 720 window. Every position on these pages is in those world units, with 0, 0 at the top left and y growing downward.

The starter as the game draws it: the whole hall at full brightness, the night-blue painted wall with its bright arched window, a warm patch of painted bricks round each of two lanterns, a third lantern on the bay’s right wall, two pillars and a floor of stone caps
The starter as the game draws it.

Why everything is bright

Nothing here is dark, and that is the first thing to know about light in Rengy. A scene with no light in it is drawn at full brightness, every sprite in its own colours, because a game with no lights should look like its art.

A light can light when it is switched on, its Intensity is above 0 and its reach is above 0; any other light lights nothing. The scene does not wait for one that can: the moment any light exists anywhere in it, in view or not, switched on or off, the scene is lit, and everything no light reaches goes dark. That is why you set the darkness first: so that the first light you add finds a dark hall.

The hall’s darkness

Once a light can light, every sprite is drawn as dark as the room’s ambient: the colour that anything no light reaches is left at. An Ambient Light sets it. Ambient Light lists its two fields.

  1. Select Hall, press + Add node, and choose Ambient Light. Rename it ambient.
  2. Set its Position to 16 and 16, out of the way in the top-left corner. Where an Ambient Light stands does not matter.
  3. In its AmbientLightComponent, leave Enabled ticked. Click Color, and press U8 at the top left of the picker that opens, so it reads F: the picker then shows each value from 0 to 1, as this tutorial gives every colour, until you close the editor.
  4. Set Color to 0.08, 0.09, 0.16, alpha 1: a cold near-black.
  5. Press Ctrl+S.
The ambient node selected, its Inspector narrowed to its Ambient Light: Enabled ticked, and a Color swatch of a dark blue-grey; the Viewport shows the node’s small gizmo in the top-left corner of the hall, which still looks as bright as before; the Hierarchy ends with ambient under Hall
Enabled
Whether this node sets the hall’s darkness. Only the first enabled Ambient Light in the Hierarchy counts, so a second one does nothing while the first is on. With none, a lit scene falls back to a dim blue, 0.10, 0.12, 0.20: a hall whose ambient is switched off gets no lighter.
Color
The colour a part of the hall that no light reaches is left at: three numbers from 0 to 1, and an alpha that is not used. Near 0.02 the painting is gone in the dark; near 0.3 it reads as dusk, not night. 0.08, 0.09, 0.16 here, with a little more blue than red to keep it cold.

To see what the ambient does before you have a lantern to show it, here is the hall of chapter 2 with its lantern shrunk to a dot: the scene is lit, and only the ambient shows. The three pictures differ only in the ambient’s colour.

The hall in almost total darkness: the window’s glass a dim lilac-grey, the stone caps along the floor and the bricks faintly brown, everything else black
For comparison: chapter 2’s hall with its lantern shrunk to a dot, so only the ambient shows, at 0.02, 0.02, 0.04.
The hall in a deep blue dark: the window’s glass a dim lilac-grey, the bricks, the pillars and the floor caps just readable against a navy wall
… at 0.08, 0.09, 0.16, the colour you set.
The hall at dusk: the whole painted wall readable in dark teal, the bricks brown, the window’s glass pale grey, the pillars and floor caps clear
… at 0.3, 0.3, 0.4.

The night ambient

FieldValue
Enabledticked
Color0.08, 0.09, 0.16, alpha 1

Check it works