mkst / sm64-port

My mirror of the sm64-port. You probably want to look at the 3DS port branch: https://github.com/mkst/sm64-port/tree/3ds-port
https://discord.gg/7bcNTPK
251 stars 34 forks source link

N3DS port with 3D #1

Closed mkst closed 4 years ago

mkst commented 4 years ago

This PR takes Gericom's changes, stacks them on top of the latest sm64-port master and attempts to add 3D.

Progress:

3D

Apply 3D effect to everything in the 3D space.

2D

We need to work out what is 2D and ensure we are not applying a 3D effect to that.

Extra

Notes:

vaguerant commented 4 years ago

Mario's shadow seems to disappear in fixed camera locations. Places like the first doorway inside the castle, or the hallway leading to Bowser in the Dark World (the first Bowser level). It reappears in 2D or when leaving areas with fixed camera. There's some additional shadow weirdness once you get inside BitDW, with 3D on the shadow seems to be on a higher z index, it darkens Mario's feet rather than being below them.

The snowflake effect in Cool, Cool Mountain (and elsewhere probably) is 2D and being scaled in a similar manner to the skybox. It's not really that noticeable, just means the snowflakes are all in front if the image instead of really seeming to be part of the world.

The thing with popping out vs. dropping in I don't think is strictly about inverting the 3D, it's just that the focal point is currently too deep into the image. You want to focus behind Mario, not on Mario. A good place to test this is the rug in the main castle room. When you pause, the textbox is basically inside Mario in a 3D perspective sense; they're sharing the same location optically and it's unpleasant to look at, because Mario shouldn't be on the baseline, he should be behind it. A focal length of 1.6f looks pretty nice in stereoscopy terms. However, shortening the focal length also means the two cameras are pointing more sharply inward, which I think has the side-effect of increasing the apparent depth because of the increased parallax. So in line with a focal length increase you'd probably also want to decrease the stereo separation (i.e. divide iod by some factor maybe?).

Along the same lines, reducing the focal length also means you can see more at the left/right edges, since ... the cameras are pointing that way more. With just the 1.6f focal length I noted above, this does lead to some visible object culling. I don't have any idea how to resolve that, I suppose however culling works in SM64 it needs to be adjusted to either be stereoscopy-aware (i.e. widen the cone of visible objects by the proportion that stereoscopic viewing adds) or just ... widen it in general.

EDIT: Even that reduced focal point becomes problematic in some situations, like talking to Bob-Ombs and stuff. The camera zooms right in on Mario and we're back to the same problem again where Mario and the text box occupy the same 3D space. Is the solution just to keep lowering the focal length until this doesn't happen any more? That's going to lead to some very cross-eyed cameras.

Here's the settings I ended up landing on just through trial and error, using the first Bob-Omb in BOB as a gauge for what "too close" is.

    float iod = gSliderLevel/4.0f;
    float focalLen = 0.75f;

This does horrible things to the title screen, Goddard, save select, etc., it only works at all for gameplay. The slider divider there might need to be a larger number, I've been looking at it too long and I can't tell if it's too deep with 4. Provisos aside, I do think this is the right approach, a low focal length is needed to keep things looking right by preventing the game and interface elements like text boxes from sharing 3D space.

mkst commented 4 years ago

Cheers @vaguerant. My current method for tweaking iod/focal length was firing up citra which crashes before Goddard, so only had the first title screen to determine too much/not enough before then ftp-ing to my 3DS to test - basically getting feedback in 1 second via citra or ~30seconds via 3DS. I'll try a non-master version of citra to see if I can get things working there...

And yes, I had wondered whether lower focal length would work, but like you experienced, after you've been staring at it for ages, you lose the ability to see straight :D

Edit perhaps we can hook into the camera.c to determine distance between camera & Mario and adjust based on that. Need more operations that the 2d hook I added, but might be an approach?

hacker1024 commented 4 years ago

How can we build this for N3DS? make seems to produce a native Linux binary.

mkst commented 4 years ago

Either checkout this branch, or try the 3ds-port branch.

Master branch is clean.

hacker1024 commented 4 years ago

Turns out I needed to set TARGET_N3DS=1 - it's set to make the native Linux version by default. Thanks for the suggestion, though.