8

Warning: My question contains some assumptions and mumbo jumbo. I attempt to learn how this stuff works and its correct terminology. And though I've implemented some of it (not all) from scratch over the years, I've done it my own way. As a result I'm sure I'm misusing some terms. Nevertheless I have partial technical knowledge of it whereas the web and YouTube if chock full of people attempting to discuss them with even less technical knowledge and misusing the terminology even worse than me. But here we should have some people expert enough to the field.

Affine transformations of bitmapped graphics can achieve scaling, shearing, and 2D rotation.

Homogeneous transformations of bitmapped graphics can additionally achieve 3D perspective mapping with foreshortening.

The Super Nintendo supported affine transformations for scaling and rotation in hardware, but also supported the famous "Mode 7", which could achieve perspective homogeneous transformations in the ground plane, X/Z, only (I believe) by cleverly adjusting the affine transformation a bitmap was undergoing on each scanline, the Y-axis.

The original PlayStation 1 only supported affine transformation which resulted in warped textures since affine transformations cannot do perspective foreshortening without clever tricks like that used by SNES Mode 7.

As far as I'm aware all the later consoles supported texture mapping with full homogeneous transformations and hence perspective-correct textures.

But for the Sega Saturn I can't seem to find good technical details. It could definitely do full affine transformations and apparently wasn't originally designed with full 3D texture mapping so many techniques were used to try to match the 3D capabilities of competing consoles of the day as best they could, to varying degrees of success.

So apart from any other limitations, could the Saturn do homogeneous transformations, only affine transformations, or could it achieve or approximate perspective correct texture mapping using some kinds of tricks similar to what the SNES did?

(I never owned any console but I did my own 3D graphics programming from scratch in the 8-bit days and affine texture transformations from scratch later on, but never managed homogeneous transformations from scratch.)


I want to include some diagrams to show the difference between an affine warp and a perspective projection. I haven't found good ones yet but while searching I realized that many images on the net labelled as "affine" are actually triangle based and show a warped square with the two triangular halves warped differently. This is what the PS1 does I believe since it was triangle based and this may cause people to believe this is what affine warping always looks like. The Saturn was quad based so will look different because although the texture won't be perspective-correct, it also won't be made of two mismatching triangular halves.

There's also the possibility of rendering a large area as a series of adjacent squares or rectangles, where the vertices of each will be correctly 3D projected but the textures within won't be. I have a hunch this may be what the Saturn did, which would result in less ugly warping that on the PS1, but more warping than on any of the later consoles.

Here's an image showing a 2D checkerboard, a PS-1 style projection made up of two mismatched affine-warped (non perspective) triangles, and a correctly perspective-mapped one: three checkerboards

This second image contrasts two affine-warped checkerboards. One made up of two mismatched triangles as the PS1 would do. The second rendered as a single affine-warped quad. Note that neither are perspective correct. two checkerboards

Here we have the 2D texture in the top left, the affine warped image made of two mismatched triangles in the top right, the affine warped image made of a single quad in the bottom left, and the perspective (homogeneous) projection in the bottom right: texture mapped four ways

3
  • 1
    I believe the answer is both: it can distort tiled backgrounds exactly like Mode 7 in one VDP, composite affine-distorted sprites into a frame buffer in another, and then combines the two during output. If I can find a compelling source, I’ll promote this comment to an answer.
    – Tommy
    Jun 10, 2023 at 16:07
  • 1
    This six year old thread says neither the PS1 nor the Saturn had perspective correct textures but says the Saturn's looked better because it worked with quads. So perhaps the only difference is the two mismatched affine triangles on the PS1 vs a single affine warped quad on the Saturn. But it doesn't say so explicitly: gamefaqs.gamespot.com/boards/204-classic-gaming/74022440?page=5 Jun 11, 2023 at 10:17
  • I have some technical knowledge in this field, but not enough. I've been using "affine" to cover quad-warping, but it may very well not be affine and I think it's more different to the two-triangle-affine than I thought. Still researching... Jun 11, 2023 at 11:13

3 Answers 3

7

An addition to the answer by Olivier. Going by the code of the yabause emulator (see this file) the distorted sprite algorithm is essentially a bi-linear interpolation on the four corner vertices. (It would render your bottom left baboon for such a trapezoid shaped target.)

The actual algorithm is complicated by the way in which it makes discrete pixel steps and tries to correct for missing pixels in the result. This algorithm will produce near-correct perspective texture mapping only for the most trivial cases (orthogonal 2D transformations).

Note that this scheme also differs form the PSX affine texture mapping: the Saturn will render a quad differently than the PSX would by splitting it into two triangles.

In short: the Saturn uses neither affine, nor perspective correct texture mapping, but uses bi-linear interpolation on quads. It may in some simple cases give the same result.

A more in-depth exposition about bi-linear interpolation for quad rendering here (not Saturn specific).

4
  • I believe this bilinear interpolation is known as "warping", an overloaded term unfortunately. My level of technical knowledge breaks down here because I feel in some way that it's a kind of affine transform but as it's not possible via combining rotation, scaling, and shearing, it must not be. I tried at least once to implement this and failed thought I was able to do the affine transforms. The only time it would give the same result as perspective mapping is when looking directly at the quad so that it's flat. But at slight angles it will differ only a little. Jun 11, 2023 at 11:12
  • 1
    @hippietrail Indeed, a bi-linear mapping is a quadratic mapping in its inputs and therefore, technically speaking, not affine.
    – WimC
    Jun 11, 2023 at 11:16
  • Yes my math breaks down. I read a lot of this of this stuff and implemented some of it but can't speak all the lingo or grok some of the math. But I just did a quick Google and read and I'm sure you got it. Jun 11, 2023 at 11:22
  • I've awarded this answer because I both find it technical and can understand it. I couldn't understand much of dirkt's answer though it was technical. I couldn't follow enough of Olivier's answer to know if he understands it or just did his best with Googling. Oddly now that I know it's quadratic mapping, Googling for that term plus "Saturn" returns very few hits. Jun 11, 2023 at 11:45
9

All right, I'll try to sum it up.

Disclaimer: I never coded anything on Saturn, only theory. But I did try to code a PPU for the 32X (dubbed SuperVDP), and also a sprite deformation engine à la Neo Geo, still on 32X.

First of all, the Saturn indeed has two VDP, but only one (VDP1) can manipulate sprites. I won't talk about the second one (VDP2) as I don't know enough about it. But have a look at antime's vault. This may help ;).

Regarding your definitions of affine transformations, you said:

Affine transformations of bitmapped graphics can achieve scaling, shearing, and 2D rotation.

Let's quote from the Sega Saturn VDP1 User's manual which says that the VDP1 can:

  • scaleFigure 1.3 Scaled Sprites p6
  • and distortFigure 1.5 Distorted Sprites p8

sprites.
The first picture easily tells us that the Saturn can scale and shear sprites. The second one shows us that it also can rotate sprites.
Great !

Regarding the perspective mapping now, this is an other story.
Of course the VDP1 can distort sprites, moving each corner of the quad as needed. Here, you could say that the VDP1 can apply perspective mapping ... but not exactly. Because even if main shape is good, the very perspective will be wrong. If we look at the distorted sprite in the above picture, we definitely can tell that this deformation is 2D only. If we try to figure it in a 3D world, something feels weird. That's because this transformation is a bit too affine indeed, and it preserves ratio between rows and columns.

If we take a look at a typical Mode 7 distorted backgroundThis basic Super NES demo uses Mode 7 as you suggest, we can clearly see that the lowest lines, the lines from which the viewer is nearer, are bigger than the upper lines, the one from which the viewer is th furthest. That is what projections are, and that is what the Saturn lacks.

Finally, to sum it up:

  • the VDP1 cannot apply any transformation, as with a transformation matrix, or something like glTransform.
  • nevertheless, the VDP1 can achieve affine transformation, even a transformation that will look a bit like a 3D projection.
  • the VDP1 can not achieve a true projection.
  • I don't know whether the VDP2 can achieve a true projection.
  • the Saturn can apply any effects (affine, homogeneous matrix, projection... you name it), with software. SH2 or DSP, your choice.

Finally, regarding the mighty - and underrated - Saturn, I'll leave the end quote to Yu Suzuki:

I think that only 1 in 100 programmers are good enough to get this kind of speed out of the Saturn.

5
  • 2
    You should mention the hardware support for Gouraud shading, and how that helps with 3D rendering, and how you can transform vertices of quads in software, and use the sprites as textures. Also, the VDP2 can actually also apply hardware transformations.
    – dirkt
    Jun 10, 2023 at 20:11
  • The Sega manual is not very explicit about the algorithm that is used for distorted sprites. (“drawing is done with lines” can mean anything.) Do you perhaps have a reference to the actual algorithm/implementation? Also, clearly the diagram in the manual is more an artist’s impression than an accurate depiction of the distortion, so that is not a convincing source.
    – WimC
    Jun 11, 2023 at 9:29
  • In their diagram the part labelled "Distorted" clearly is using perspective. The bottom half of the "B" is clearly larger than one quarter of the quad. But that doesn't mean the diagram is correct as it seems to be hand-drawn and not generated by the device, so the artist could've used their own assumptions. Jun 11, 2023 at 9:38
  • @dirkt Gouraud shading is totally orthogonal to texture mapping. It's a lighting effect, not a texture effect. Jun 11, 2023 at 9:41
  • The answer seems to contain assumptions and mumbo jumbo. I'm rubbish at matrices but I've coded affine texture scaling, shearing, and rotation without them. So the Saturn's APIs or hardware could also do so without them. I also don't know gl so I have no idea if the "apply any translation" is correct or even makes sense. An affine transformation will never look "a bit like a 3D projection". What does "true projection" even mean? "Project" is a versatile term that covers any way of representing 3D on a 2D plane, you probably mean "perspective projection". Others include isometric and oblique. Jun 11, 2023 at 9:46
2

I want to include some diagrams to show the difference between an affine warp and a perspective projection.

I also don't know gl

So here is some additional information that will help you understand the answers.

Graphic pipelines consist of several steps, and have changed a bit over time.

Very roughly speaking, you have a vertex transformation step, which uses a matrix multiplication. You can implement an affine transformation on any number of dimensions by using an augmented matrix and by extending the point coordinates with an additional "virtual" coordinate that is always one (homogenous coordinates). An affine transformation matrix will have zeros in the last row except for the last entry. If the last row has non-zero entries, you have a projective transformation (and you have to normalize the vectors again).

The vertices define the corners of a polygon mesh (often triangulated). On the polygons itself, a second step applies texture mapping by interpolating pixels, applying shading calculations (Gouroud or others), and so on. This is what you call an "affine" transformation, but in normal 3D-pipeline speak at this stage all transformations have already happened, and you are just shading pixels.

So in your terminology, all modern graphics hardware is "affine", no modern graphics hardware is "homogenous", and you are not aware that the actual affine/homogenous transformations happen before.

In modern terminology, the affine/homogenous transformations happen during vertex transformation, and it doesn't apply these words to the pixel shading.

What the Sega Saturn hardware can do is that the VDP1 actually has some 2D-hardware acceleration that would correspond to a modern pixel shader. So you could implement a modern 3D pipeline on the Saturn by doing the first vertex transformation step in software (and then you can do whatever transformations you like), and by using the quad hardware transformation as the pixel shader.

Note that the VDP2 actually has a full transformation matrix and 3D parameters for backgrounds, so the answer to your question

could the Saturn do homogeneous transformations, only affine transformations,

(in your terminology) is "the VDP1 does affine pixel interpolating transformations, the VDP2 does homogenous pixel interpolating transformations on backgrounds only". But none of this matters for a modern 3D pipeline, which works differently, and applies the terminology differently.

The answer seems to contain assumptions and mumbo jumbo.

Instead of insulting people who know those things, I'd suggest to actually learn something about modern 3D pipelines, then maybe you could understand the answers, and they wouldn't look like mumbo jumbo to you.

2
  • 1
    I didn't intend to be insulting. My questions and comments also include assumptions and mumbo jumbo because I only partially understand this stuff. When you Google or watch YouTube videos there's a lot more people talking about it who don't understand it than who do and that manifests in assumptions and mumbo jumbo. Nevertheless I apologize if anyone was insulted as that wasn't my intention. I have actually tried to learn these things a bunch of times over the last 30 years but haven't found anything that can fill in my knowledge gaps without confusing me. Jun 11, 2023 at 11:25
  • 1
    @dirkt Congratulations for your answer which brings so much to the table, especially regarding VDP2. And thank you for the kind words. I also was a bit surprised by the form and substance of OP comments but hey, as long as they accepted an answer, I guess I'm happy.
    – Olivier
    Jun 11, 2023 at 18:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .