📜 ⬆️ ⬇️

3D mode in Diablo 2

This is a translation of the post Don't Starve, Diablo - Parallax 7 from the blog of Simon Schreibt on February 25, 2014.
Careful, heavy gifs.

In the 90s, games began to move from 2D to 3D. If the UFO then visited the earth, the aliens would have decided that the low-poly models used at that time were not needed by anyone without any filtering, and would have destroyed the Earth.

Over time, of course, they would have learned what made people special: even in the 2D era, they had an incredible desire to render in 3D, even though it was simply impossible then! It all started with the implementation of the parallax effect (depending on the "distance", some elements moved faster than others). This parallax effect blew people’s brain back in 1982:
')

Game: Moon Patrol source: YouTube

Indeed, it is interesting that several planes moving in different ways create such an impressive effect. But it looks a little flat, right? A promising camera above the ground would have looked better, but could it not be done without the use of “real” 3D? Ok, let's use the time machine and move to the SNES era:


Game: Moon Patrol source: YouTube

It looks like 3D, but it is not 3D! This is a SNES technology called “ Mode 7 ”. To visualize it, Nintendo manipulated textures (reducing height in favor of depth) using some kind of programmer magic. Here are the words of a person who knows how to apply it (he talks about the Gameboy Advance , but as far as I know, the recipe is also suitable for SNES):
“GBA has no hardware capabilities to render 3D, but you can fake it by smartly controlling the scale and transitions of REG_BGxX-REG_BGxPD for each line,” Cearn

By the way, even today some people go crazy over Mode 7 and use it for projects with RPG Maker . Impressive!
Today, you can render each resource in “present” 3D to add volume, but there are examples where it is simply not necessary. In fact, sometimes it's even better to use an old school:


Source: Don't Starve

All bushes, trees and enemies in Don't starve are flat. I think it looks cool!
For me, Diablo 2 (2D ARPG 2000) was the first game that combined the parallax effect from Moon Patrol and something similar to the Mode 7 approach.
Let's take a look at the game with the default settings. Pure 2D. No prospects. No parallax:


Source: Diablo 2

But the game had “Perspective Mode”. Let's turn it on! Notice that the stakes cover different pixels on the ground at different times:



It looks like Don't Starve, but remember: Diablo 2 is a 2D game! There was no official information about this mode. Everything that you are reading now has become known thanks to the excellent tools / documentation by Tom Amigo and Paul Simari . Special thanks to Paul for answering all my questions and in many ways supporting me.

It may seem that Blizzard programmers just somehow moved the sprites, but if you compare the game with the perspective mode turned on and turned off, and do not move, you will notice that they, in fact, shifted everything relative to the horizon line.



If you replace the texture of the earth with an excellent chess texture, you can see even better:



In a sense, think about this: each resource in the scene had to be somehow transformed so that it looked promising without gaps at the edges of the sprite. Especially considering the number of sprites in the scene (the chance to get a gap was big enough ...):




In this case, the code of the game should not be too confusing! So please keep in mind that Blizzard divided the sprites into 32x32px pieces . Download only those parts of the picture that are needed - it looks like an optimization. Plus, it becomes useful when you need to apply a transformation. See how the sprites are divided in the game:


Source: D1 format by Paul Simary

I draw lines on every transparent texture every 32px to show a false grid. The result exceeded my expectations! As the vertical lines show, the sprite has a “real” vanishing point deep in the ground (what could you expect from a perspective):



However, I do not know why the bottom edge is so arched. For perspective, this is not necessary (below there is a scene from 3ds Max, showing that if the camera does not rotate around its axis, then the horizontal lines remain straight):



In any case, the wizards of Blizzard know why they did it. Maybe it does not cost anything, but such a deformation depends on the “angle” under which you look at the sprite (player / camera position). See how the bottom edge straightens:



Here is a screenshot for those who are interested in the distortion of the chess texture:



If you think that this is all interesting enough, then read on and go crazy. Paul writes that sprites can have some kind of orientation value. Depending on this value, the sprites are distorted differently (yes ... even more difficult)! Here is an example: the wall has directions (Left edge, top edge, left bottom edge, etc.)


Source: DT1 format by Paul Siramy

Let me demonstrate how (in my opinion) this is done. The following image shows the standard ISO view. Below are the steps I took to make sprites "promising." I had to move them, scale them and deform them twice to achieve this effect.



As you can see, the transformation in my view is a bit confusing. Let's see how this is actually done in the game:



This sprite is oriented differently than in the example I mentioned earlier. See, the deformation is completely different! The upper and lower boundaries are no longer bent, instead, they seem to “look” at the vanishing point on the left. Again, let's look at an example of how it looks in 3ds Max:



Apparently, the game exaggerates the distortion to avoid the gaps between the sprites and it seems to me, quite successfully, because every sprite of the fence is great. Note that the direction of the faces (top and bottom) changes depending on their location:



The following example shows how important the value of orientation is in sprites. If you just say the game: “this is not the left wall, but the right one”, it is time for the slots:



This mode could only be activated in full-screen mode with D3D (Diablo 2 also supported Glide and Software Acceleration modes), which made me try to deal with the old DirectX documentation, without success.

So ... our journey ends here, and I hope that you are impressed with this example of craving to make 2D look like 3D, just like me. The lack of official information and the absence of official statements about this (look at the government’s website, there’s nothing on the “Perspective Mode in Diablo 2”) led me to the inevitable conclusion:

This is all alien technology!

Tools used:

Thanks to Hans Wust for this wonderful article on image distortion, it all looks almost like Diablo 2 (with perspective mode enabled). I don’t know, maybe D2 programmers used exactly this information, but it looks very familiar.

Source: https://habr.com/ru/post/235735/


All Articles