SNES "Mode-7 effect" theory

Started by
16 comments, last by Lord Alexion 20 years, 1 month ago
I really wanted to know this... I wanted to understand the principle behind that pseudo-3D thing you see at some classical console RPGs, or in Mario Kart/Top Gear/etc. I know it has to do with scaling the 2D image line per line. and I also know it is possible to create a relation between the height of the "camera", it''s angle, and thew way the image is disrorted. And I wanted to know exactly how to do it... I tried really hard, but I can''t find any materials on the internet that talk about this... could somebody point me to a document, tutorial, etc. that explains this technique in detail? thanks a lot
Advertisement
The SNES had custom hardware that provided the Mode7 effects. I remember reading an atricle that said you could get some very good effects by simply experimenting with differant value in the PPU registers (if you want to search this may be a good strating point).

To do the same thing on a PC you should probably look at OpenGL or Direct3D (direct draw does not let you rotate 2D images which was a part of many mode7 effects). Scaling and rotating a textured quad should provide something approximating what you are looking for.
There''s stuff about Mode 7 in this article (scroll a fair way through it).
I read that article, but it didn't help me much... it used a method where you used pixel-by-pixel drawing, and this unfortunately does not suit me... -_- I need something more theorical.

Also, I'm using a 2D engine to do this. If I could, I'd simply do it by mapping the 2D map into a 3D surface and positioning it on the screen... but I'm stuck with 2D scaling.

[edited by - Lord Alexion on March 5, 2004 11:21:45 AM]
quote:Original post by Lord Alexion
I really wanted to know this... I wanted to understand the principle behind that pseudo-3D thing you see at some classical console RPGs, or in Mario Kart/Top Gear/etc.
You mean 2.5D?

You basically have a sprite-based 2D system, but every sprite also has a z-coordinate. (You can choose whether larger or smaller z values represent being closer to or further from the viewing plane - whether the z-axis points into or out of the screen.) When it''s time to render your objects, you sort them by z and scale them linearly. Presto!

This is what Wolfenstein 3D did for the character sprites, after it had performed the raycast for the environment.
Yea, but I needed to know HOW to scale things... and I needed to know more about the environment.

I know you achieve that by scaling the 2D map, but I needed to know the relation between camera angle, geight, and scale factor...
quote:Original post by Lord Alexion
Yea, but I needed to know HOW to scale things... and I needed to know more about the environment.
Scaling a sprite down is a question of averaging pixel values. Say you have a NxM-pixel sprite that you are scaling down by a factor of two. The new dimensions will be (N/2)x(M/2) (which you can determine is 4 times smaller). Consequently, you will need to process your sprites two horizontal pixels and two vertical pixels (4 pixels square) at a time, averaging their color values and rendering the result. It''s similar to anti-aliasing.

Scaling up is the inverse. Rather than averaging, you replicate pixels. Done raw this rapidly makes the image blocky, so you also anti-aliase the edges to improve blending.

quote:I know you achieve that by scaling the 2D map, but I needed to know the relation between camera angle, height, and scale factor...
If you want arbitrary camera angles, it''s probably better to employ billboarding - place your sprites on polygons (which are naturally scaled, along with the polys that make up the environment) that always face the camera.
erm,... OK, but... my problem is not with the sprites, but with the environment. And I''m using a 2D engine to achieve this, so I can''t use polys or surfaces. I want to render the ground as a "mario-kart/early final fantasy overworld map" clone.
I answered this question a few weeks ago. Search the forums before asking, you''ll usually get your answer much faster.

------------
- outRider -
I''ve never gotten a full mode7 effect going before, but you might want to check out www.gbadev.org, as the GBA has a similar graphics mode and is thusly used to do the mode7 effect pretty frequently. There''s a couple of tutorials on it in the docs section, the one by DarkFader explains a method for calculating the screen coords by raycasting, although he doesn''t explain it too clearly so I haven''t managed to implement it myself. The easiest method is to simply divide the scale by (screen height - current line) and use that. Haven''t figured out how to calculate sprite positions with that method, but it does do the ground. I think you need a more mathematical method like the raycasting to really use in a game. Or a bigger brain than mine to better understand the dividing method.
Also http://www.taswegian.com/TwoHeaded/mode7.html has some theory on it, although I didn''t find it very useful.

This topic is closed to new replies.

Advertisement