Tuesday, July 11, 2017

The pseudo-3D waterline

Reader Spinner asked:
Could you please explain at some point how the water effect in the backgrounds of Hidrocity 1 and Launch Base 2 is accomplished? You know, that pseudo-3d effect reminiscent of mode 7.
It's a combination of two effects. Opening up Hydrocity Zone 1 in SonLVL shows us two strips of placeholder patterns along the background, hinting this is yet another DMA-based animation. This one animates when the camera moves vertically rather than horizontally, though.


Within the graphics for Hydrocity Zone 1 are the following four patterns. These are DMA'd over the above placeholders depending on the camera's position.


When the camera is above the waterline, the top placeholder is filled entirely with the first pattern, while the bottom one is initially filled with the second pattern. As the camera descends, the second pattern is reapplied, but the game begins progressively skipping over rows of pixels as the view approaches the water.

As a result of skipping over rows, the height taken up by the second pattern starts decreasing. When the bottom end of the pattern is reached, the game fills any remaining space with rows from the fourth pattern.


Once the camera crosses over the waterline, the same process occurs, except in reverse. Now the bottom half is filled entirely with the fourth pattern, and as the camera continues to descend, the top half is replaced by rows of pixels from the third pattern. Any remaining space is filled with rows from the first pattern.


The final touch, which really brings it together, is a carefully aligned parallax scroll. Areas of the background filled with the first and fourth patterns all scroll horizontally at the same rate, but the rows of pixels between them scroll faster the closer they are to the waterline, giving it a meaty 3D effect.

4 comments:

  1. Thank you for explaining it. Gotta love all the awesome effects they were able to add to a "measly" Genesis game. I don't think any other Sonic game had that much effort put into it.

    ReplyDelete
  2. This is literally my favorite feature in all of Sonic. I don't quite understand how this works but I'm so happy to have found an explanation.

    ReplyDelete
  3. alguien sabe cómo replicar esto en game maker

    ReplyDelete