Stereoscopic

For developmental things relating to the graphics of the game.
Post Reply
abonin
Posts: 2
Joined: Mon Nov 18, 2019 2:04 am

Stereoscopic

Post by abonin » Mon Nov 18, 2019 2:29 am

Hi, I want to change the viewport so i could have a Stereoscopic type of view using a googlecardboard for the game. At first i though about going into split screen mode for 2 players but changing the viewport player for player 1 to have the same screen side by side. Any idea what i should change in the code to help me do that ? ( example of viewport i want : https://farm1.static.flickr.com/119/256 ... 1e50_o.jpg )

User avatar
Z-Man
God & Project Admin
Posts: 11220
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne, Jabber: [email protected]
Contact:

Re: Stereoscopic

Post by Z-Man » Tue Nov 19, 2019 10:40 pm

You get the basic stereoscopic shift by, well, shifting one of the cameras to the side by the distance of the eyes. What you do is that you set up basic side-by-side splitscreen and modify the code for the second view so that instead of the usual camera update, it just copies all values from the first view's camera (pos, dir, fov, z, rise, top should do), then move 'pos' a little to the side, like this:

Code: Select all

    float eyeDistance = 0.05;
    pos = pos + dir.Turn(0, eyeDistance);
Important to know: our units are approximately meters, walls have a height of 1. It may look better if you assume that's actually 1.5 meters...

Of course, for a true Cardboard view, what's missing would be some distortion to compensate for what the lenses are doing. It seems you can get away without that.

abonin
Posts: 2
Joined: Mon Nov 18, 2019 2:04 am

Re: Stereoscopic

Post by abonin » Wed Nov 20, 2019 4:22 pm

Do you know where I need to change the code and add that line ?

User avatar
Z-Man
God & Project Admin
Posts: 11220
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne, Jabber: [email protected]
Contact:

Re: Stereoscopic

Post by Z-Man » Wed Nov 20, 2019 10:19 pm

Search for eCamera::Timestep. That's the function you can put this stuff into. Or eCamera::Render. Render has the advantage that you don't have to worry about ordering: Put your code at the top. It will then run between both Timestep calls (one for each view, one of them doing an update you don't actually want) and right before actually setting the view parameters up for rendering, so nobody is going to mess with your setup any more.

Post Reply