Skip to content

Commit

Permalink
Merge pull request #718 from Calinou/add-global-illumination-demo-2-4.0
Browse files Browse the repository at this point in the history
Add a global illumination demo (4.0-dev)
  • Loading branch information
aaronfranke authored Apr 25, 2022
2 parents 60457b4 + 31b962a commit 560ea5a
Show file tree
Hide file tree
Showing 20 changed files with 249 additions and 2,351 deletions.
28 changes: 3 additions & 25 deletions 3d/global_illumination/README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,21 @@
# Global Illumination

This demo showcases Godot's global illumination systems:
[GIProbe](https://docs.godotengine.org/en/stable/tutorials/3d/gi_probes.html),
[BakedLightmap](https://docs.godotengine.org/en/stable/tutorials/3d/baked_lightmaps.html)
(indirect only and fully baked) and
[ReflectionProbe](https://docs.godotengine.org/en/stable/tutorials/3d/reflection_probes.html).
VoxelGI, SDFGI, ReflectionProbe and screen-space effects like SSAO and SSIL.

Use the mouse to look around, <kbd>W</kbd>/<kbd>A</kbd>/<kbd>S</kbd>/<kbd>D</kbd>
or arrow keys to move.

Language: GDScript

Renderer: GLES 3[^1]

Check out this demo on the asset library: https://godotengine.org/asset-library/asset/1290
Renderer: Vulkan

## How does it work?

A glTF scene (which acts as the level mesh) is imported with its **Light Baking**
option set to **Gen Lightmaps**.
This is required for BakedLightmap to work (but is not required for GIProbe
or BakedLightmap).

The level mesh is duplicated several times to allow displaying it with various bake settings:

- No baking (uses GIProbe or environment lighting).
- Baked indirect lighting. Slower, but allows for real-time shadows to display
on baked surfaces.
- Baked direct *and* indirect lighting. Faster, but does not allow for real-time
shadows to display on baked surfaces.

A sphere and box are parented to the camera to showcase dynamic object lighting.
A ReflectionProbe is parented to the sphere to showcase real-time reflections.
When the ReflectionProbe is hidden, it is disabled. In this case,
GIProbe or environment lighting will be used to provide fallback reflections.
VoxelGI, SDFGI or environment lighting will be used to provide fallback reflections.

## Screenshots

Expand All @@ -45,7 +27,3 @@ GIProbe or environment lighting will be used to provide fallback reflections.
map "zdm2" and is
[licensed under CC BY 4.0 Unported](https://github.com/Calinou/game-maps-obj/blob/master/sauerbraten/zdm2.txt).
The OBJ file which it was converted from is available in the [game-maps-obj](https://github.com/Calinou/game-maps-obj) repository.

[^1]: This demo can be made to work with GLES2, but GIProbe will not work.
Additionally, lightmaps have to be rebaked with the **Atlas > Generate** property
disabled in BakedLightmap.
6 changes: 3 additions & 3 deletions 3d/global_illumination/camera.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func _input(event):
rot.y -= event.relative.x * MOUSE_SENSITIVITY
# Vertical mouse look.
rot.x = clamp(rot.x - event.relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
transform.basis = Basis(rot)
transform.basis = Basis.from_euler(rot)

if event.is_action_pressed("toggle_mouse_capture"):
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
Expand All @@ -29,9 +29,9 @@ func _input(event):

func _process(delta):
var motion = Vector3(
Input.get_axis(&"move_left", &"move_right"),
Input.get_action_strength("move_right") - Input.get_action_strength("move_left"),
0,
Input.get_axis(&"move_forward", &"move_back")
Input.get_action_strength("move_back") - Input.get_action_strength("move_forward")
)

# Normalize motion to prevent diagonal movement from being
Expand Down
Loading

0 comments on commit 560ea5a

Please sign in to comment.