WHY is doom's sky backwards?

Discuss anything ZDoom-related that doesn't fall into one of the other categories.
Post Reply
User avatar
bimshwel
Posts: 704
Joined: Tue Jul 15, 2003 5:15 pm
Location: misplaced
Contact:

WHY is doom's sky backwards?

Post by bimshwel »

I have known since 1995ish that it is, when galaxia's text file pointed it out, and i can find now a few pages with essentially the same information saying that it happens, along with appropriately enough the galaxia text file from ages ago, but does anyone know why it happens? Was it ever explained anywhere? Is there a deliberate piece of source code which makes this happen on purpose?

The closest I can guess is that since it is used as a ceiling and ceilings are always backwards, which makes them more manageable in level creation since sector layouts always show the ground and the ceiling layout is opposite. But since the sky is drawn as a wall there would be no reason for flat rules to apply to it, and anyhow when it is placed on the ground it is still drawn from the top of the screen and still backwards!

The super nes port of doom, which is not based on the source code, has non-mirrored sky, though other ports retain the mirroring, and nobody cares. Nor should they, but *I* do

If I understand correctly, based on something I read ages ago and have not recently attempted to verify, Apogee borrowed floor rendering code from Doom for Blake Stone, Rise of the Triad and whatnot, but Rott's and Duke Nuken 3d's skies aren't backward, though Duke3d has numerous graphics that are stored internally backwards for no clear reason, which I have a longstanding odd habit of noticing, after being bothered by seeing letters in mirrors as a small child.
User avatar
Enjay
 
 
Posts: 26534
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: WHY is doom's sky backwards?

Post by Enjay »

My assumption - with absolutely no knowledge or anything to back it up in any way shape or form - was that it's because we see the sky projection from the inside and it would look fine from the outside. :lol:
User avatar
bimshwel
Posts: 704
Joined: Tue Jul 15, 2003 5:15 pm
Location: misplaced
Contact:

Re: WHY is doom's sky backwards?

Post by bimshwel »

That works from a desktop universe sort of perspective, where an enormous being or group of enormous beings is setting up hoards of tiny people to fight each endlessly other for its own amusement, but if it physically wrapped the impression of a sky around those things it would not be able to watch them!
User avatar
InsanityBringer
Posts: 3386
Joined: Thu Jul 05, 2007 4:53 pm
Location: opening the forbidden box

Re: WHY is doom's sky backwards?

Post by InsanityBringer »

I'm not super well versed with Doom's renderer code, but I have an idea what's going on looking at the code. So Doom angles are stored such that angle 0 is facing east, and as the angle increases, you turn counterclockwise. The view angle for a given sky column is scaled and directly used as which column to render, which is where the inverse happens. The graphics are stored so that the lower numbered columns are to the left, and the higher numbered columns are to the right, but the sky angle is inverted. The angle on the left of your screen is higher than the angle on the right of your screen, and when the column is grabbed, it's grabbing the higher numbered columns before the lower numbered ones, causing the flip.

My understanding is that engines like Build and ROTT use a different projection. Whereas doom uses a basic cylindrical projection for the sky, they use a "flat" projection, where the sky maintains an equal scale across the screen, minimizing the effect you see in the original Doom where the sky stretches out horizontally near the edges of your screen.
User avatar
bimshwel
Posts: 704
Joined: Tue Jul 15, 2003 5:15 pm
Location: misplaced
Contact:

Re: WHY is doom's sky backwards?

Post by bimshwel »

thank you for the explanation! I do not quite grasp this "column" business and maybe my confusion comes from that. I am used to angle 0 = east from trying to grasp acs. the angle on the left would be west, which by virtue of not being east, is higher? all wall graphics go left to right, right? Why aren't they all backwards, then? is the stretching effect that build engine lacks directly responsible for the reversing?
When you say the sky "angle" is inverted, is that something done on purpose, or is it just incidental? Would you be able to show which bit of code specifically sets this up?
User avatar
InsanityBringer
Posts: 3386
Joined: Thu Jul 05, 2007 4:53 pm
Location: opening the forbidden box

Re: WHY is doom's sky backwards?

Post by InsanityBringer »

here's where the sky rendering occurs. It's relatively straightforward, but it does require some context from the rest of the renderer that's a bit hard to establish here. viewangle is of course the current view angle, and xtoviewangle is a lookup table that gets the angle offset for a given column of the screen. It's scaled to the sky's resolution (1024 wide), and then drawn as columns like a wall or sprite.
User avatar
bimshwel
Posts: 704
Joined: Tue Jul 15, 2003 5:15 pm
Location: misplaced
Contact:

Re: WHY is doom's sky backwards?

Post by bimshwel »

oh! I see, I think; the angle number increases going the opposite way that textures are made, just by chance. It isn't about east being 0, just about angles increasing counter clockwise in general. So I wonder if THAT happens for any particular reason. I didn't think of the stretching happening in a similar manner to how sprites seem get moved when you spin around in the game but i suppose it is similar.
perhaps the build engine didn't think it was necessary to match the sky to angles since they could simply count the total number of pixels that appear in a full rotation.
thank you for helping me to stop dwelling on this!
Gez
 
 
Posts: 17835
Joined: Fri Jul 06, 2007 3:22 pm

Re: WHY is doom's sky backwards?

Post by Gez »

I think it's accidental and since it didn't really matter for the sky textures used, it wasn't picked up during development.

If they had been making Duke Nukem 3D instead of Doom and they tried to make a Hollywood Hills skybox, then perhaps they'd have noticed the flipping and fixed it after seeing the sign rendered as ⱭOOWY⅃⅃OH in-game.
User avatar
Enjay
 
 
Posts: 26534
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: WHY is doom's sky backwards?

Post by Enjay »

Or, if it was easier, they would probably just have flipped the graphic and left the code alone.

It seems odd that someone wouldn't have realised that the graphics were reversed (especially as the artist was right there with the dev team playing deathmatch games). In saying that, I'd been replacing skies in Doom for some time before I noticed. :lol:
User avatar
bimshwel
Posts: 704
Joined: Tue Jul 15, 2003 5:15 pm
Location: misplaced
Contact:

Re: WHY is doom's sky backwards?

Post by bimshwel »

I understand not noticing it for episode 1, where they used someone else's photograph and barely edited it at all, and the two dark mountains resemble yet sort of face away from each other, but episode 2 just has the one mountain that very plainly is facing to the right. My guess would have to be that somebody did notice and simply did not care or think it worth mentioning.
when I opened up the duke3d grp thing looking for graphics i fully expected to find hollywood in there facing the wrong way but it appeared exactly as it did in the game!
Post Reply

Return to “General”