Did you ever notice that the theater in level 1 of Duke Nukem 3D has a big hallway off the lobby, and when you go through there, it's a bathroom? Just the one.

It's a doorless unisex public bathroom with urinals. Weird.
BTW I'm certain the real reason they put a bathroom in this level was this stupidly huge mirror.
This is a huge flex from the engine: look at us, we can do fucking MIRRORS
you can even see ENEMIES in the mirror!
you can shoot them with a gun, and they will get bullet holes, and then if you hit them with an explosive (even one that hasn't exploded yet...), it STOPS BEING A MIRROR
here's the best part: if you use a noclip code, you can walk through them.
because it turns out that the way the engine handles mirrors is by having surfaces tagged as mirrors, and there's an identical copy of the room on the other side, with some Magic to make the sprites work out
like in the bathroom there's a phone number on one of the walls.
If you're inside the mirror, you can see it's been mirrored
but here's a fun question: so the game has remote-controlled bombs, right? and you can use them to destroy mirrors.

So what if you're in the mirror when you destroy it?
it gets SLIGHTLY weird and broken
The game also automaps areas you go into, but it will not automap the area behind mirrors
fun fact: You can explore around in the mirror dimension but if you go to far, you will die.

even with God Mode active.
so to learn more we need to open up the level in the editor.
Here's the bathroom in 2D mode, and that red line at the top is the mirror.
then if we switch into 3D mode, you can see that it's got something weird going on with it. That "S" is a special effect called a Sector Effector
Duke3D uses a lot of these. You basically stick these sprites in areas and it'll control some special attributes of that area.
But here's the neat thing about Duke3D's mirrors:
So there's two ways this might "obviously" work, either:
1. The level developer has to manually create a copy of the room
2. The engine automatically clones the room at run time
And the answer is #2... but only mostly.
Because here's a differently centered view of that 2D map before.
See what's on the other side of the mirror? There's a room there.
and if you zoom out, it turns out there's a HUGE room back there.
if we go in there, we can see back into the bathroom
but yeah. it's just a big empty room
BECAUSE it turns out that yes, the BUILD engine can build a reflection for you, but it does it at load time.
When the level is loaded, it finds the mirrors and copies that geometry into the room on the other side of the mirror
So to include a mirror, you have to leave enough room for the game to copy the geometry, or the mirror won't work properly.
this is also why you die if you wander too far inside the mirror: you've moved outside the map.
Because the game considers the empty room to be the area you can move around in, not the real geometry.
SO here's the next question:
it won't work if the mirror-room is too small, right?

what exactly will happen?

TIME TO EDIT THE LEVEL AND SEE WHAT HAPPENS!
so it turns out that the answer is... the mirror just doesn't work, unless you're inside the area of the room on the other side of the mirror. Basically the mirror-geometry is only defined for that size of a space.
you can see here that it's working fine, then you back up too much and it breaks, then it starts working again when you get closer
You see the same "deader than God" effect when you go into it, too.
You can walk into it with noclip, but as soon as you step outside the map's real geometry, it kills you.
This sort of thing was honestly my favorite part of FPSes in the 90s: Getting a game, then getting hold of the level editors and finding how much of it was just a big hack
for example, here's the first shot of the game, in the editor.
Doesn't it look cool? You've got sloped surfaces, a huge vista of a city, and SHADOWS on the ground! Isn't that neat?
it turns out the ceiling is a sort of skybox, which is normal for games, really, but it's implemented very weirdly.
The room has an actual shape, but by marking the ceiling as parallax, it's hidden.
As for the shadows: if you look at the 2D version of the level, you'll notice that the part in the middle isn't shaped how you'd expect. it's just a rectangle, right? nope, it's got a weird border around it, but only on two sides.
because it turns out you can adjust the brightness level of sectors individually, and so to build a shadow, they split the floor into multiple sectors, then manually darkened those sectors to fake a shadow
And you know that neat bit near the beginning of the first level, where you fall down an AC shaft and onto the street?

The build engine can't do that! It's impossible!
So like Doom and Wolfenstein 3D, Duke Nukem is a "2.5D" engine. It's really a 2D map being rendered in 3D, using a lot of trickery.

So how could the roof be above the street?
Now, the BUILD engine does have a neat trick where it can KINDA do "Room over Room", which is what this effect is called.
Basically if you get into the two overlapping rooms from different sectors, it can tell which one you're in, and not get confused.
But that's not being used here.
so if you zoom out, it turns out the whole rooftop set looks like this. It's just a rectangle inside a bigger rectangle. There's no street here at all.
and if you zoom out, you'll see that the street is actually way over there, in a different part of the map.
and if you zoom in on that air vent, you'll see it's LOUSY with sprites, some of which are doing special things...
because it's a teleporter!
because yeah, the part you fall down is not on the roof. it's on the street.
As soon as you step into the air vent, it teleports you over here to that tube on the street, and you fall down that.
You can sorta see what's happening if you watch the automap
or if you enable the coordinates overlay.
another fun thing about the effect: So, you see these canisters and the warning signs, so naturally you shoot them, and they blow up, and the air vent blows up too.
Is that just natural splash damage?
Nope! it turns out it's cheating. See the those little vertical lines?
it turns out those are more explosive-barrel sprites, just squished down real thin.
It turns out the Build engine was designed so that if you make sprites super thin, they just don't render.
They may be linked somehow to make sure they go off, I'm not sure. I can't easily tell.
BTW you may have noticed something in the corner of that zoom-out. There's a set of sectors in the corner of the level that you can't get to... they say AHB
That's Allen H. Blum III, who has worked on every Duke Nukem Game. He wrote the level editor for Duke Nukem 1, and drew many of the graphics.
Here's another fun thing about how the Build engine works. So, episode 1 level 3, we've got a submarine in a lake. You can go underwater, and see the bottom of the sub.

But wait, there's no room-over-rooms. How does this work?
So check out the coordinates. I'm just going up and down here, in and out of the water. Only the Z coordinate should be changing.
So here's where the sub is in the map.
Well, half the sub.
the other half is over here.
and if you go into 3D mode, you'll see that this is the underwater half
and yeah, it turns out the two halves are in completely separate parts of the map. It's a teleporter again! it's just teleporting you from the surface version to the underwater version
So yeah, that's how Duke 3D does underwater sections, like lakes and pools and such. Because the surface of the water is opaque, you can't tell that this is happening.
BUT GUESS WHAT: they didn't leave it that simply

let me zoom out more...
DUN DUN DUN there's actually THREE submarines!
Because once you have the ability to teleport the player when going up out of the water, there's no reason you have to make it always go to the same place.
so yeah, they put another level of water on the bottom of the sub (a moon pool) and let you go "inside" the submarine. In reality, you're not going UP into the submarine, you're going sideways into another room
They even ensure that the illusion isn't shattered by teleporting projectiles between the rooms. You can fire a rocket into a pool, and it'll hit the bottom of the pool
In that same level there's this bit. Look, there's an upper floor there! How do you have an upper floor walkway if there's no real Room-over-Room?
and if you pull it up in the BUILD editor you'll see... yep. It looks like a bunch of floors floating over other floors. WEIRD!
it turns out there's no sector effects happening here.
You can hover over a sprite in the editor, and make it a billboard (always facing the player), a wall-texture, or a floor-texture.
and yeah, that's all this is: sprites.

You can place sprites, make them flat, then set them to block the player and now the player can walk over them like they're a floor!
fun fact: we've seen this before in this thread.
if we go back to that air vent in the first level...
remember how it blows up?
that's because it's sprites!
finally, what about the secret apartment in the first level? How's that work? Teleporters, weird portal effects, sector effectors?
it's actually none of those.
It's just using the fact that Build lets you set wall textures as single-sided, so that you can't see into the apartment from the outside. It's actually there where it appears to be.
and if you turn that off, you'd be able to see right into the room.
You can follow @Foone.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: