excaliburjs/Excalibur

Investigate ways of doing split-screen cameras

eonarheim opened this issue ยท 8 comments

In order to do this, the entire in memory canvas needs to be up for grabs for rendering. Then you take the pixels in the specific camera frustum and compose the multiple frustums together.

engine.currentScene.cameras = [camera1, camera2];

// get individual frustums
var frustum1: ex.Texture = camera1.getFrustum();
var frustum2: ex.Texture = camera2.getFrustum();

// compose cameras
var composer = new CameraComposer();

engine.currentScene.cameraComposer = composer;

This will break all off screen culling logic :/

Proposal:

We shouldn't confine this feature to just 'split-screen' scenarios, we should allow different types of camera displays, in a 'Multi-camera' system.

multi-camera

In the above screenshot, you can see 2 players, with their own camera in a rectangle. On top of each player, they both have a mini-map, which is a separate camera that separately displays the map from each player's own position. On the bottom, a smaller version of the other player's view can be seen, for co-op style game play.

Obviously this is just an example, but I believe that allowing very custom/dynamic camera rendering would allow developers to do anything they can imagine (maybe?).

@eonarheim fyi

@pathurs Good point, I totally agree

This issue hasn't had any recent activity lately and is being marked as stale automatically.

Any updates here?

@JumpLink nothing recent, there is some work going on to refactor the WebGL renderer to allow easier post processing to render targets that might be eventually useful in creating multiple cameras.

I'll slot this into our v1 roadmap, but no promises on a timeline. This potentially will require some plumbing changes in Excalibur to allow multiple cameras, running the draw routines per camera, and compositing the results together.

Tentatively I've placed this on v0.27.0 #1161

A possible workaround would be to create several canvas elements / engine objects for a split screen. In this way you would be forced to outsource the multiplayer, but that could also be an advantage, as you could also implement online multiplayer in this way (as if you had several browsers open more firmly). In addition, it would be possible for the players to be able to move around in different worlds, even on the split screen. What do you think?

The current recommendation is to use multiple instances of excalibur once v0.28.0 drops which supports that.

Closing for now, I think we'll potentially revisit this as a post v1 feature