Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a global illumination demo (4.0-dev) #718

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, why did you change this? Input.get_axis(&"move_forward", &"move_back") is what we want.

Copy link
Member Author

@Calinou Calinou Apr 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's likely accidental, as I don't remember performing this change.

)

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