HomeForumsWhat's newResources 
 
 
Texture coordinates on the Saturn!
XL2 - Sep 7, 2021
 XL2 Sep 7, 2021
Sunday I was watching again John Burton's video (Coding secrets - Gamehut) on environmental mapping as seen in Sonic R. He mentionned 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 CPU side of things, either to generate a new texture with the effect applied or to fully software render the effect (like in Sonic R).

That sounded like a challenge!

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 actualy the palette.
16 will be the center UV (0).
You can also clip the textures, which is impossible normally on the VDP1.
Of course, that means you are limited to 32x32, 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 32x16 or even 32x8 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 32x32 chunks as you rotate the camera around, out of a, say, 256x128 texture or 128x64 texture.
I simply made a quick proof of concept test yesterday to confirm it works, but you should take a look at the video Mrkotfw made today, which shows the UV effect in action :








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 Sep 8, 2021
Proof of concept reflection mapping using this technique. My maths are probably wrong, but it looks nice overall imo.

 XL2 Sep 9, 2021
Here is the iso.
The guys at Sega Saturn shiro also made an article as well :

 celsowm Sep 10, 2021
Amazing, @XL2...

Would it be possible, just as prof-of-concept, using GitHub - NaomiMod/games-ExtractTools... to extract Dural from VF3 and using the same technique to display her on a stock Saturn?


 nando Sep 10, 2021
That's really cool! I always wondered, after seeing Sonic R, if AM2 could have made Dural reflective (even if at a lower resolution).

It might be limited in use, but it's a neat effect that could be great for specific situations.

 XL2 Sep 10, 2021

celsowm said:

Probably, but that model would need to have a reduced polygon count. But yes, you could totally make a way more impressive Dural than what we got...

 celsowm Sep 10, 2021

XL2 said:


Thanks for your reply.
Such a pity I am still very a newbie on 3D programming (I am just a regular dev java, php etc...)
I tried something in JoEngine but without success The API level is a little bit hard for me
One type of prof-of-concept that I really would love to see is a, even totally static, Virtua Fighter 3 demo on Sega Saturn.

 XL2 Sep 29, 2021
Another test :
https://youtube.com/TjSNdY20Sh8


 Danthrax Sep 29, 2021
That looks cool at nighttime. Might look nice to have the reflection on the car disappear when it goes through a shadow, if that's possible.

 XL2 Oct 8, 2021
Another demo, hopefully looking better :

https://youtube.com/Zs3l5SDlIJ8


 nando Oct 8, 2021
I love the blood coming out of the cars, lol.

Since you don't plan on making an actual racing game - any chance you'd post code examples for others to use for one?

 celsowm Oct 9, 2021
A good package of low poly cars:


 Guardian Pura Sep 18, 2022
XL2, I know this thread is over a year old, but I've had a set of questions about your technique for some time.

1. Since the image being 'reflected' is a palette, is it possible to use palette cycling to present animation, a la Mark Ferarri's 'Living Worlds'?

2. If so, is it possible to alter the playback rate of the palette cycling to match the player's movement speed through the environment?

3. Also, would it be possible to alter the playback direction (play 'frames' of the palette cycle backwards) based on the player's movement direction through the environment?

 Ponut Sep 18, 2022
The answer to all of your questions is maybe, if anyone ever gets around to programming it.

 Guardian Pura Sep 18, 2022

Ponut said:

If I wanted to commission it, what price range are we talking about for a tech demo to be open sourced to the community?

 XL2 Sep 19, 2022
The palette cycling would actually be like changing the whole image, not the palette. The palette here is really just a direct color bitmap

 nando Sep 20, 2022

Guardian Pura said:

I'd put up money for an open source code example of the original idea, much less these advanced ideas - I understand XL2's idea in concept, but as far as actual coding, I have no idea where I'd start.

I keep thinking about Dural in VF2 and more technically, Fighters Megamix, since it actually used gouraud shading to begin with (my limited knowledge of Saturn video coding - I don't think you can use high-res mode and gouraud shading at the same time?). A Dural demo would be pretty awesome. I'd be willing to put up some money for that.

 Ponut Sep 20, 2022
You guys make it sound way harder than it is. You can ask us at least to point to to a place to start with an open-source drawing pipeline wherein you have control of the command tables, which is in either Yaul or my demos. Then you just have to put your texture in color RAM, draw an untextured polygon with a palette code as the color, and then use the texture coordinates as the red channel for goraud. I know that's a lot of steps but that is basically it. All of this is documented.