godot-demo-projects/viewport/dynamic_split_screen
ShatteredReality b4c73f4888
Fix README links to asset library (#1078)
This updates all links to point to the 4.2 demos instead of the 3.5 ones.

Co-authored-by: A Thousand Ships (she/her) <96648715+AThousandShips@users.noreply.github.com>
2024-06-24 19:29:58 +02:00
..
screenshots Improve dynamic split screen demo (#815) 2023-01-17 21:41:02 +01:00
README.md Fix README links to asset library (#1078) 2024-06-24 19:29:58 +02:00
camera_controller.gd Use static typing in all demos (#1063) 2024-06-01 12:12:18 +02:00
default_env.tres Update Viewport demos to Godot 4 2022-03-26 19:29:53 -05:00
icon.webp Use 128×128 WebP icons for all demos (#885) 2023-03-29 18:59:57 +02:00
icon.webp.import Use 128×128 WebP icons for all demos (#885) 2023-03-29 18:59:57 +02:00
player.gd Use static typing in all demos (#1063) 2024-06-01 12:12:18 +02:00
project.godot Use static typing in all demos (#1063) 2024-06-01 12:12:18 +02:00
split_screen.gdshader Improve dynamic split screen demo (#815) 2023-01-17 21:41:02 +01:00
split_screen.tscn Use static typing in all demos (#1063) 2024-06-01 12:12:18 +02:00
wall_coloring.gd Use static typing in all demos (#1063) 2024-06-01 12:12:18 +02:00

README.md

Dynamic Split Screen

This sample project showcases an implementation of dynamic split screen, also called Voronoi split screen.

Language: Godot shader language and GDScript

Renderer: Compatibility

Check out this demo on the asset library: https://godotengine.org/asset-library/asset/2806

Details

A dynamic split screen system displays a single screen when the two players are close but a splitted view when they move apart.

The splitting line can take any angle depending on the players' position, so it won't be either vertical or horizontal.

This system was popularized by the Lego videogames.

How it works

Two cameras are placed inside two separate viewports and their texture, as well as some other parameters, are passed to a shader attached to a TextureRect filling the whole screen.

The SplitScreen shader, with the help of the CameraController script, chooses wich texture to display on each pixel to achieve the effect.

The cameras are placed on the segment joining the two players, either in the middle if they're close enough or at a fixed distance otherwise.

How to use it

Open and launch the project inside the Godot engine, then use WASD to move the first player (in red) and IJKL (or arrow keys) to move the second player (in blue).

The camera_controller.gd script sets parameters to tune the distance at which the screen splits and also the width and color of the splitting line.

Screenshots

Screenshots