XL2 Cracks “Impossible” Saturn Hardware Environment Mapping

XL2 continues to push the Saturn beyond what many have thought to be impossible… His latest exploit? Hardware-based UV Texture Environment Mapping!

Saturn Hardware-Based UV Texture Environment Mapping – Proof of Concept
Saturn Hardware-Based UV Texture Environment Mapping – Proof of Concept

Sunday I was watching John Burton’s (Coding secrets – GameHut) video again on environmental mapping as seen in Sonic R. He mentioned in the video that it’s impossible to do environment mapping using the Saturn hardware, as it lacks textures coordinates. So the only known solution was to do some kind of work on the CPU side of things, either to generate a new texture with the effect applied or to fully software render the effect (as in Sonic R).

That sounded like a challenge!
-XL2

“Because of the way Saturn handled texture mapping, it was actually impossible for the hardware to produce environment-mapped polygons” -Jon Burton (Traveller’s Tales)

Here are some key examples (from the video above) of UV Texture Mapping in software, rather than in hardware. It’s very important to keep in mind that, while visually impressive, a software-based approach like this is achieved at the expense of nearly all system resources, so it could not be implemented in gameplay to any practical degree…
By creating this effect in hardware, one sacrifices a large chunk of the color ram, but is able to implement the feature with no performance penalties whatsoever…

Software-Based Environment Mapping
Software-Based Environment Mapping

What you see below is an UNTEXTURED polygon.
By using gouraud shading, you can actually use the palettes as texture – with the shading being the texture coordinate (x = red, y = green). So by simply using a fully untextured command, I just need to have the cmdColr center around red = 16 and green = 16. The gouraud shading takes care of the rest, as the texture is actually the palette. 16 will be the center UV (0).

You can also clip the textures, which is normally impossible on VDP1.
Of course, that means you are limited to 32×32, which takes half the CRAM.
By using the blue shading and ratios you could also have it change colors depending on the background.
You could also limit the resolution to something like 32×16 or even 32×8 to save some CRAM.

So while this effect is useless for most cases because of the super low res and very high CRAM usage, it can be used for reflective mapping as the objects are unlikely to be huge.

Think of a stupid vase on the ground, a sword, a shield, etc…
You would just need to bake the chrome/gold color to the texture directly.

To compensate the low resolution, you could just stream new 32×32 chunks as you rotate the camera around, out of a, say, 256×128 texture or 128×64 texture.

Take a look at the video Mrkotfw made today, which shows the UV effect in action :
-XL2

This is an untextured draw command…
This is by simply merging 2 vertices together and giving them the same value. Magic!
The texture gets clipped (mostly) properly!
-XL2

About the author

SaturnDave

A massive Saturn fan since Christmas '96, Dave is enthusiastic about growing the community and spreading Saturn love and knowledge to fans old and new. Co-founding the SEGA SATURN, SHIRO! podcast back in 2017 and creating the SHIRO! SHOW in 2020, he seeks to create interesting and engaging Saturn-related content for the community. Dave's interests circle around game preservation, and he is a huge fan of game magazines and developer interviews.

Readers Comments (3)

  1. While this works in a tech demo, I have some doubts it would work in a real, complex game. The effect is very low resolution and already takes half the CRAM. You still need to add everything else to the screen and render it. You still need to add game logic to it.

    • SaturnDave 2021-09-10 @ 10:34

      Edexote, I don’t think XL2 will exploit the hell out of this effect throughout a game, but rather use it sparingly…
      Here’s a quote from XL2 regarding similar concerns that others have expressed…
      “Imagine a sword, an armor, a shiny pot, etc.. The Sonic R effect was too expensive to use in game, while here it’s free, even cheaper than rendering a texture…
      I may sacrifice half my pallet bank for one texture, but so did Mario 64… I only use like 1/6 of my CRAM as it is, so I’ll have more than enough” -XL2

      • That’s cool. Still, it’s a nice effect and something that was considered impossible to render in hardware.

Leave a comment

Your email address will not be published.


*