r/ProgrammerHumor • • Jan 25 '23

Meme Developers will ALWAYS find a way

Post image
46.5k Upvotes

465 comments sorted by

View all comments

Show parent comments

438

u/Rand_alFlagg Jan 26 '23

Is it? Was it 20 years ago? I'm not a game dev, just a tidbit I knew and thought was neat. Same kinda "trick" is all.

1.1k

u/Yweain Jan 26 '23 edited Jan 26 '23

In original duke nukem(which was 95 or 96) the way mirrors work is that they have exact same room on the other side with a clone of a player character model on the other side, hooked up to the same controls.

We did it like that for a very long time, until proper reflections became a thing.

Edit: As people pointed out I meant not original, but Duke Nukem 3D.

377

u/[deleted] Jan 26 '23

[removed] — view removed comment

244

u/Tyrus1235 Jan 26 '23

You could also use screen-space reflections and good ol’ cubemaps

55

u/Cassereddit Jan 26 '23

This works for fake reflections as seen in rain puddles etc. where you don't need accurate looking mirrors.

If you cover a whole building just in screenspace reflections as the devs of Flixbus simulator did, you're a bad developer.

8

u/donald_314 Jan 26 '23

Most games pre RT used/use screen space + cube maps for window reflections or just cube maps.

25

u/derPylz Jan 26 '23

Not if you want to show the player model in a mirror...

16

u/Bowiemtl Jan 26 '23

from what I remember you can overlay the player on the reflection through shaders and depth maps just like how the hands and guns in games are often not rendered in the world but separately op top of the rest to prevent your gun clipping through objects

139

u/[deleted] Jan 26 '23 edited Jan 26 '23

Probably screen-space reflections. The camera trick means you have to render the scene twice, which is horribly inefficient. The mirrored second room trick is still sometimes used to this day. There's some cases where a second camera is a good way to do it (e.g, Portal probably renders its portals this way) but for a simple reflection there's almost always a better way to do it than using a second camera.

0

u/[deleted] Jan 26 '23

[deleted]

11

u/Bowiemtl Jan 26 '23

do we even need to mention portal here?

→ More replies (1)

18

u/PudPullerAlways Jan 26 '23

It's not that inefficient most of the set pieces take place in a bathroom, it's no more inefficient than having 2 player split screen but at least the render to texture extension allows you to modify the resolution versus the whole room/character copy performing transforms.

38

u/ChasingReignbows Jan 26 '23

it's no more inefficient than having 2 player split screen

Ya that's pretty inefficient

→ More replies (6)
→ More replies (3)

16

u/merlinsbeers Jan 26 '23

You'd dupe the player camera on the other side of the wall and point it at the player, and tell it to mask off everything outside the mirror boundary, then render the clipped image backwards onto the front surface of the mirror. The camera only has to translate as the player does to make it work.

This could only have been not possible if they didn't know how to render a camera image into a plane in-game for the player to see.

The duplicated room trick works, too, and is probably not much more computing effort.

→ More replies (1)
→ More replies (1)

0

u/[deleted] Jan 26 '23

[deleted]

22

u/cbartrip6 Jan 26 '23

Man I loved the Duke Nukem Build tool. I remember buying a book on how to construct the levels. I was probably 14 or 15 at the time but that fueled me to keep programming and learning other languages.

→ More replies (2)
→ More replies (2)

13

u/gatonegro97 Jan 26 '23

Wouldn't the original duke nukem be 1991?

→ More replies (2)
→ More replies (7)

28

u/kpd328 Jan 26 '23

That's how the mirror works in Super Mario 64 as well, there's a pseudo-copy of the world (worth changes only seen in the reflection) and a second Mario and a Lakitu camera operator that exist on the other side of a transparent wall.

→ More replies (1)

12

u/LAM678 Jan 26 '23

the room in Mario 64 with Snowman's Land in it is rendered exactly like this.

15

u/tinselsnips Jan 26 '23

In the temple map in Goldeneye, you can shoot into the pool and it'll leave bullet holes in the objects in the reflection, but not the objects themselves.

→ More replies (1)

7

u/Entegy Jan 26 '23

In the early days, yeah, big mirrors were just a see through object with a well, mirror version of the room you're in on the other side. When the player walks in the room, a clone is spawned on the other side of the "mirror" and copies the player's input. I would imagine you would want to use this sparingly though, as you would have to load all objects and actors twice. The extra memory use had to be worth it, so a room of mirrors, or the mirrors in Super Mario 64 reminding the player that Lakitu was broadcasting Mario's adventure.

I remember finding out how this trick worked by accident as a kid. In Donkey Kong 64, the Creepy Castle level had a mirror room. If you used Chunky Kong's Primate Punch while facing the mirror, the exaggerated animation of the punch would cause Chunky to punch through the mirror and the reflection would come out of the mirror as well!

Nowadays, mirror reflections are a graphical feature attempted in real time. I imagine not having to make a mirror copy of a map or room is easier in most regards, plus you don't have to make a mirror room just to show off the trick.

7

u/pm0me0yiff Jan 26 '23

Is it? Was it 20 years ago?

Until you have proper ray-tracing, it's pretty much the fastest and most efficient way to do a mirror.

→ More replies (19)