Advertisement

F-Zero style graphics...

Started by September 10, 2000 10:11 PM
18 comments, last by Wyrframe 24 years, 3 months ago
Mode 7 allowed the sprites to be passed through a 2x2 matrix in hardware. That allowed for rotations and skews. F-Zero and Mario Kart used the technique to fake a 3d effect.

-R

I think everybody lost the real focus of this... What my main interests where...


> REALISM. The "camera" looked very realistic. No poor stretching, no popping bands of pixels, and if you payed attention, it does not rotate around a point "straight down" from the camera... it was rotated downwards far enough so that you could see the rotation point at about 1/8 of the way from the bottom of the screen.

> MEMORY. The SNES had very little RAM, and it even used the same processor as the original NES! They just upgraded the RAM and the video "card" (For lack of better term).

> SPEED. This was almost pure software rendering, on a 5 Mhz chip. Think about it.

So, WITHOUT D3D, OPENGL, or ANY OTHER HARDWARE CLIENT, how do I make a similar effect without taking up 80Mb of ram for the "map" image?

RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.
Advertisement
quote:
> REALISM. The "camera" looked very realistic. No poor stretching, no popping bands of pixels, and if you payed attention, it does not rotate around a point "straight down" from the camera... it was rotated downwards far enough so that you could see the rotation point at about 1/8 of the way from the bottom of the screen.


The SNES PPU''s Mode 7 handles the scaling and rotation of the screen. The hardware does a good job of handling the artifacts caused by the scaling and rotation it. The hardware can also redefine the center of the screen.


> MEMORY. The SNES had very little RAM, and it even used the same processor as the original NES! They just upgraded the RAM and the video "card" (For lack of better term).


Actually, the SNES uses a 65c816 (2.68-3.58 mhz depending of bus waits) processor while the NES used a 6502.


> SPEED. This was almost pure software rendering, on a 5 Mhz chip. Think about it.


It was done completely in harware actually.


So, WITHOUT D3D, OPENGL, or ANY OTHER HARDWARE CLIENT, how do I make a similar effect without taking up 80Mb of ram for the "map" image?


F-Zero, as well as all other SNES games use tiles. Find a nice way of putting a set of 256 8x8 tiles together to form your maps. And encode the actual map data into a set of objects, for example defining a barrier wall, like the ones in f-zero, as the position, witdh and lentgh in tiles. Then fix the deconder to draw the edge tiles properly based on position on the object, like drawing the proper tile in the corners.

As for the actual effects done to the background in f-zero, any routines for stretching and rotateing a bitmap will work. But, if you want to actually clone, grab some SNES technical documents (mode 7 is a very simple system using only 6 registers the control the rotation/scaling, each register consisting of only a single number).
quote: Original post by Wyrframe


> REALISM. The "camera" looked very realistic. No poor stretching, no popping bands of pixels, and if you payed attention, it does not rotate around a point "straight down" from the camera... it was rotated downwards far enough so that you could see the rotation point at about 1/8 of the way from the bottom of the screen.


That's what I meant by skewing, its basically scaling something not at the center point, but tilting it so you can see it go into the horizon, it's just a modification of a simple scaling routine.

quote:
> SPEED. This was almost pure software rendering, on a 5 Mhz chip. Think about it.


It wasn't done in software, it was a hardware trick, that's why it was so fast, most of the SNES rendering functions had some kind of hardware support on the display side, that's how it got by with a slow processor.

quote:
So, WITHOUT D3D, OPENGL, or ANY OTHER HARDWARE CLIENT, how do I make a similar effect without taking up 80Mb of ram for the "map" image?


You have to code the routines yourself, and if you do them in ASM you can get it running fast enough on a P2 200, maybe even on a slower machine. Then you make your map out of tiles, and you'll only need a tiny amount of RAM. Maybe you should look up how tiles work first.

------------
- outRider -

Edited by - outRider on September 13, 2000 5:01:51 PM
Well, some options that are possible w/o hardware acceleration for reproducing the effect in Mario Kart and F-Zero are:

- Making your own perspective poly renderer (my recommendation).
- Realtime raytracing (using interpolation) an infinite plane.

Other than those you can try reproducing the original effect, which in my opinion is way more complex than the previous options, but it will be faster (depending on how you code it ).

First though, a bit of background on SNES hardware. Mario Kart utilized Mode 7 and the DSP1 chip for it's background image generation, while F-Zero got by with just Mode 7. Mode 7 allowed for having a 256 color playing field (still tile based) that could have shearing/warping effects applied to it, while the DSP1 chip accelerated some 3d effects, such as vector transformations and such (for the sprites). These effects were accomplished by specifying a center of rotation and a 2x2 transformation matrix for the source layer.

What Mario Kart and F-Zero did (I think) was set up the center of rotation and rotation values to make it appear as though you were turning, then vary the scaling values on every scan line to produce the illusion that the driving track went off into the distance. So, suppose you are starting from the bottom scanline (the one that would appear closest to you) and moving upwards. What you would do as you move up in scanlines is to decrease the horizontal scaling value (to fit more terrain in) and also decrease the vertical scaling value (again, to fit more terrain in). These should be non-linear decreases hitting just above 0 on the last scan line for optimal realism.

The 2x2 matrix is constructed using 4 terms as follows:

A. COS ( rotation angle / X Scaling ) | B. SIN ( rotation angle / X Scaling )C. SIN ( rotation angle / Y Scaling ) | D. COS ( rotation angle / Y Scaling )


And the formula applied to individual pixels as you go through the image are:

X2 = AB * X1-X0 + X0
Y2 = CD * Y1-Y0 + Y0

where:
X0,Y0 is the center of rotation
X1,Y1 is the source coordinate
X2,Y2 is the final coordinate to draw

This kind of algorithm, if optimized to the hilt could run on computers in the P60 range, but requires much more programming effort. So, it's up to you if you want to do that, or go with one of the easier options above.

Whew.. That's almost a document there =) I think I might just have to implement that just to see if I was right . Hope this is enough implementation details for you . Have fun!

(Forgot to include credits for my information: Yoshi's SNES documents and the SNES9X source were where I got the info about Mode 7 and DSP1)

PreManDrake

Edited by - Premandrake on September 13, 2000 11:02:48 PM
Hooo boy... lots to awnser here...

First, the Anonymous poster with one giant quote.

Yes, I know how to use tiles. However, if you take a good look at F-Zero again, slow down and look at shock-walls at the the "corners" of the tracks. Or even the "dirt" on the track. Neither follows an axis close enough to possibly be actual tiles, unless we're talking a 1024x1024 tile map here, with a single "circle" in the shock-wall being not 1 tile, but 4 adjacent tiles...

In any case, would I render an area of tiles around the camera into a "buffer", like a overhead 2D view? And then use that buffer as the source for the pixel-pushing routine that draws the ground?

Next, outRider.

Okay, on further study of the game, especially the "zoom in from above" thing that is does at the start of each race, yeah, it is just a modified 2D stretch thingy (That's about as technical as I get at this time of night )

And I actually have seen the same technique, on a 2Mhz Atari ST, 512Kb of RAM, using software. Albeit it was done in 16 colors. The Atari ST didn't have all these cool (And useful) extra graphics modes, although it did support 256 color display modes of up to 640x480!

Finally, Premandrake.

I did use a technique just like that, the adjusting the scaling and step values, for a lead-up program before this. However... It was using VB5, using StretchBlt to do the scanlines, from a 512x512 bitmap. It sucked, it was slow, and it can't rotate. But it worked... I am having the trouble in efficiently and realisticly rotating the camera, like in F-Zero.

That code bit should come in damn handy, Thanks! Just two questions about it, though.

> What sort of For- or Do-loop would I put around it?

> And will (X2, Y2) be a pixel or percentage value across the viewport? (On a 640x480 screen, will it be [320,240] or [0.5,0.5])



Edited by - Wyrframe on September 14, 2000 2:07:41 AM
RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.
Advertisement
quote: Original post by Wyrframe
Hooo boy... lots to awnser here...

First, the Anonymous poster with one giant quote.

Yes, I know how to use tiles. However, if you take a good look at F-Zero again, slow down and look at shock-walls at the the "corners" of the tracks. Or even the "dirt" on the track. Neither follows an axis close enough to possibly be actual tiles, unless we''re talking a 1024x1024 tile map here, with a single "circle" in the shock-wall being not 1 tile, but 4 adjacent tiles...

In any case, would I render an area of tiles around the camera into a "buffer", like a overhead 2D view? And then use that buffer as the source for the pixel-pushing routine that draws the ground?


If you take a close look at the map, the dirt has a definite pattern to it. I am not completely sure what you mean by ''not following an axis close enough'', but if some seem to be at a weird position, it is probably a simular, but different tile.
The walls probably are four adjacent tiles, it seems that way from how the wall looks when direction changes by 45 degrees. By the way, in the case of the SNES, the part of the of the map in VRAM probably maxes out at 64x64(not sure, but it may be 128x128 for mode7, but every other mode has a max of 64x64) tiles.

As for the actual rendering, yes, you should, probably, think of it as an overhead 2D map for the source of the image.

As for the rendering, yes, you, probably, should think of it as an overhead 2D map

Okay. I did mean 1024x1024 for the entire track, but anyways...

Yes, it does look that way, at times. Yes, perhaps there would be many different tiles, like a "half-dirt" tile, but with my SNES experience, I didn''t think they had enough VidMem to handle so many tiles, AND so many vehicle sprites (5 or 6 ranges, 8 rotations for every range except closest, with 16 behind and 8 in front)

Gotta go. Might finish this later tonight...
RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.
To answer the first poster''s question, Mode 7 was used to scale/rotate background images, basically what they did for F-Zero was take a bird''s eye view of the map (like you see right as you''re entering the race), scale it in and then rotate it to the right perspective. Then they made a scrolling background (easy with coding on the snes) and made transparent added gradients to give it that lighted look (notice it gets more white as it goes towards the background). Then they made 4 or 5 sprites per race car as they scrolled towards the background (notice the cars were always choppy when they were coming towards you?). F-Zero was a no-brainer compared to other great SNES games like FF3 but definitely was fun for its time.

Okay... this has helped a lot!

I''ve got lots of theory, a bit of code, and much more SNES hardware info. That should do for now... I''ll make a new topic if I really need more help.

Many thanks to everybody who helped out!
Mis mereikta velenta!
Muchos gracias!
RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.

This topic is closed to new replies.

Advertisement