Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Lord Alexion

SNES "Mode-7 effect" theory

This topic is 5340 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!