Two simultaneous mode 7 textures?

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
iNCEPTIONAL

Two simultaneous mode 7 textures?

Post by iNCEPTIONAL »

Question: How plausible would it be to have a different "texture"* for the top part of the Mode 7 graphic and the bottom half in the examples [MOD edit: in this post viewtopic.php?p=282026#p282026 ] ?

Example: Could you have something like this cool scrolling cloud effect using half of the Mode 7 background on the top portion of the screen, https://youtu.be/VWClU1hk7iA?t=1367, and then something like the brick floor as in other examples in this thread for the bottom half?

The video above shows that actual effect in motion, but I've added a static image here just for a quick reference directly visible in the post:
DifferentHalves.png
DifferentHalves.png (57.72 KiB) Viewed 1644 times
Note: I understand this might mean using half of the tiles in the image for each section in order to fit it all into one background in video ram or whatever, so obviously that would have to be considered when drawing the art and deciding how much of the image to assign to the sky and how much to the ground. Or, maybe it would require using HDMA to switch to a totally different set of background tiles about half way down the screen, almost like switching background mode but just to Mode 7 again but with a new tilemap or whatever. And I understand that maybe you couldn't even do any rotation in the particular case, which is fine for what I'm asking, as I'm actually thinking of the Mode 7 ground just scrolling to the left in my shmup game anyway, but with the Mode 7 sky additionally moving towards the screen as it scrolls to the left. So, hopefully you can take into account that this would obviously be something I'd like to be considered if necessary.

Note 2: And I understand this might require doing something slightly different to your specific goal and use of Mode 7 in here too, and I apologise if it's going off the main goal of the topic slightly, but you just made me think of an idea I had before for how I might mess around with a particular Mode 7 effect for a level in my game, and, since you seem to have a very good grasp on how Mode 7 works, I just wanted to ask.

*Please forgive me for not really knowing the correct way to describe what all the tile graphics/art are called when thinking of them in a rotated/scaled/sheered background in Mode 7, which makes them look almost like a texture-mapped quad, so that it's clear what I'm talking about
Last edited by iNCEPTIONAL on Tue Aug 02, 2022 3:02 pm, edited 2 times in total.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Kulor's Guide to Mode 7 Perspective Planes

Post by lidnariq »

iNCEPTIONAL wrote: Tue Aug 02, 2022 2:54 pm Question: How plausible would it be to have a different "texture"* for the top part of the Mode 7 graphic and the bottom half in the examples above?
"Texture" is fine.

Unfortunately, the SNES can only hold one "texture" for mode 7, and doesn't really have the ability to change it mid-screen.

The best one can do is just-so-happen to be able to fit both camera views into the one texture and make sure each camera can't see the other half of the texture, or a palette swap between the SNES's configurable palette and the R3G3B2 fixed palette, or a bunch of black scanlines in the middle for a more interesting palette swap.

I think this is why all the games with mode7 floors use not-mode-7 for the skybox.
none
Posts: 117
Joined: Thu Sep 03, 2020 1:09 am

Re: Kulor's Guide to Mode 7 Perspective Planes

Post by none »

Terranigma had a nice solution for faking a sky

https://youtu.be/Nsb2eFt7BCs?t=4290
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Kulor's Guide to Mode 7 Perspective Planes

Post by rainwarrior »

none wrote: Tue Aug 02, 2022 3:52 pm Terranigma had a nice solution for faking a sky

https://youtu.be/Nsb2eFt7BCs?t=4290
So, subtracting yellow from the overhead map to get blue? That's kinda funny.
iNCEPTIONAL

Re: Kulor's Guide to Mode 7 Perspective Planes

Post by iNCEPTIONAL »

lidnariq wrote: Tue Aug 02, 2022 3:08 pm
iNCEPTIONAL wrote: Tue Aug 02, 2022 2:54 pm Question: How plausible would it be to have a different "texture"* for the top part of the Mode 7 graphic and the bottom half in the examples above?
"Texture" is fine.

Unfortunately, the SNES can only hold one "texture" for mode 7, and doesn't really have the ability to change it mid-screen.

The best one can do is just-so-happen to be able to fit both camera views into the one texture and make sure each camera can't see the other half of the texture, or a palette swap between the SNES's configurable palette and the R3G3B2 fixed palette, or a bunch of black scanlines in the middle for a more interesting palette swap.

I think this is why all the games with mode7 floors use not-mode-7 for the skybox.
And it's not possible to sort of have a Mode 7 background [that maybe only uses about half of the available tiles, so less vram] at the top of the screen, stop showing/drawing any of it for a chunk in the middle of the screen, where you'd just draw the background colour for a while as you fetch/load any new tiles/tilemaps and stuff, and then switch the background mode using HMDA to another background Mode (but really just to Mode 7 again) with the new "texture" [that maybe only uses around half the available tiles, so less vram] for that "new" background mode and new background (similar to how you might when using the same method to switch from a Mode 7 sky at the top to a normal Mode 1 level usimg different backgrounds and tiles at the bottom, like they did in that Geomon game), and then start drawing the new Mode 7 background instead for the rest of the screen, or something to that effect?

Note: I'll not ask any more questions on this in this thread after this one, just so I don't take away from Kulor's amazing work here and the proper conversation around that.
Last edited by iNCEPTIONAL on Tue Aug 02, 2022 5:32 pm, edited 6 times in total.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Kulor's Guide to Mode 7 Perspective Planes

Post by rainwarrior »

iNCEPTIONAL wrote: Tue Aug 02, 2022 4:23 pmAnd it's not possible to sort of have a Mode 7 background at the top of the screen, stop showing any of it for a chunk in the middle of the screen, so nothing except the background colour is being drawn for quite a few scanlines, while switching the background mode during that time using HMDA to another background Mode, but really just to Mode 7 again, and load in the "texture" for that "new" background mode and new background, as you might when using the same method to switch from a Mode 7 sky at the top to a normal say Mode 1 level at the bottom, or something to that effect?
No.

1. Blanking mid-screen is black, not background colour.

2. The mode 7 tilemap is 16kb. I think you'd have to blank about half the screen to upload this much? (...and you'd also have to replace this twice in each frame, not just once.)

If you're going to do this, it would be as lidnariq already suggested. Find some area of the map not currently visible on the floor, and replace that. That's theoretically doable, but limits your view and severely complicates the update process.

Otherwise, all other modes except mode 7 can relocate their data anywhere in VRAM, so it's practical to switch between separate sets of data in any mode except mode 7.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Kulor's Guide to Mode 7 Perspective Planes

Post by lidnariq »

iNCEPTIONAL wrote: Tue Aug 02, 2022 4:23 pm And it's not possible to sort of have a Mode 7 background at the top of the screen, stop showing/drawing any of it for a chunk in the middle of the screen, so nothing except the background colour is being drawn for say 32 scanlines, while switching the background mode during that time using HMDA to another background Mode (but really just to Mode 7 again), and load in the "texture" for that "new" background mode and new background
Correct. No meaningful ability to update the texture during rendering at all. You could turn off rendering, but that's solid black, not a solid color, and DMA bandwidth (160.5 bytes per black scanline) isn't high enough to swap out any significant portion of the tilemap or tile library (16384 bytes each).

As rainwarrior points out, you also have to swap the map/library back for the top half, so the time needed for two full swaps (forwards and back) is 206 scanlines, which means on a 50Hz console you've got 112 scanlines to divide between the top and bottom windows, with 103 black ones in the middle.

And due to how mode7 works, reserving some of the tile library for each texture is only enough to make this doable at all - only updating part of the tilemap only works if you're doing extremely restricted camera things, and only updating part of the tile library only works if both textures are extremely simple. (Each black scanline gets you 2.5ish new tiles)

This is why F-Zero is single player and fast-paced (you only need one texture and you can update it at the edges during normal blanking), and Super Mario Kart is multiplayer and slow-paced (both players have to render the map out of the same texture)
93143
Posts: 1717
Joined: Fri Jul 04, 2014 9:31 pm

Re: Kulor's Guide to Mode 7 Perspective Planes

Post by 93143 »

iNCEPTIONAL wrote: Tue Aug 02, 2022 2:54 pmI'm actually thinking of the Mode 7 ground just scrolling to the left in my shmup game anyway
You shouldn't need Mode 7 for that. Linescroll works fine.
TrekkiesUnite118
Posts: 92
Joined: Fri Mar 08, 2013 5:56 pm

Re: Kulor's Guide to Mode 7 Perspective Planes

Post by TrekkiesUnite118 »

lidnariq wrote: Tue Aug 02, 2022 5:17 pm
iNCEPTIONAL wrote: Tue Aug 02, 2022 4:23 pm And it's not possible to sort of have a Mode 7 background at the top of the screen, stop showing/drawing any of it for a chunk in the middle of the screen, so nothing except the background colour is being drawn for say 32 scanlines, while switching the background mode during that time using HMDA to another background Mode (but really just to Mode 7 again), and load in the "texture" for that "new" background mode and new background
Correct. No meaningful ability to update the texture during rendering at all. You could turn off rendering, but that's solid black, not a solid color, and DMA bandwidth (160.5 bytes per black scanline) isn't high enough to swap out any significant portion of the tilemap or tile library (16384 bytes each).

As rainwarrior points out, you also have to swap the map/library back for the top half, so the time needed for two full swaps (forwards and back) is 206 scanlines, which means on a 50Hz console you've got 112 scanlines to divide between the top and bottom windows, with 103 black ones in the middle.

And due to how mode7 works, reserving some of the tile library for each texture is only enough to make this doable at all - only updating part of the tilemap only works if you're doing extremely restricted camera things, and only updating part of the tile library only works if both textures are extremely simple. (Each black scanline gets you 2.5ish new tiles)

This is why F-Zero is single player and fast-paced (you only need one texture and you can update it at the edges during normal blanking), and Super Mario Kart is multiplayer and slow-paced (both players have to render the map out of the same texture)
Is switching the palette mid frame possible? If so one thing you could do is set up your artwork so that with one set of palettes it looks like the ground, and with another set of palettes it looks like a sky. It would require a lot of thought going into your artwork and tiles, but it could be good enough to be convincing for a different ground and sky texture with out having to completely change your tiles and tile map.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Kulor's Guide to Mode 7 Perspective Planes

Post by rainwarrior »

TrekkiesUnite118 wrote: Tue Aug 02, 2022 6:16 pmIs switching the palette mid frame possible?
It's possible to switch some of the palette, but mode 7 is 8bpp already (256 colours). I think there's plenty of available palette entries for a separate sky without doing any mid-frame switching.

Though, maybe this digression about "can you do a separate mode 7 sky" deserves its own thread at this point.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Kulor's Guide to Mode 7 Perspective Planes

Post by lidnariq »

TrekkiesUnite118 wrote: Tue Aug 02, 2022 6:16 pm Is switching the palette mid frame possible? If so one thing you could do is set up your artwork so that with one set of palettes it looks like the ground, and with another set of palettes it looks like a sky.
20 entries out of of the 256 can be changed on a scanline during hblank and if there are no sprites.
Otherwise, you can turn on "directcolor" mode, which won't be so nice for a blue sky since that fixed palette only provides 2 bits of blue.

oh, also: MOD: I split this tangent into its own thread
93143
Posts: 1717
Joined: Fri Jul 04, 2014 9:31 pm

Re: Two simultaneous mode 7 textures?

Post by 93143 »

Using EXTBG makes a BG2 available in Mode 7. It's identical to BG1 (it uses the same pixel fetch from VRAM, so you can't scroll it separately or anything) except that the top bit of the CGRAM index is repurposed as a priority bit. This has the side effect of translating colour indices from 128 to 255 into the range 0 to 127. (Unfortunately the range 128 to 255 is almost entirely sprite palettes; there are only 8 guaranteed free colours in that range.)

Or you could use direct colour. It doesn't need to be the sky; it could be the ground. Using EXTBG might be a way around the sprite palettes - since BG2 never uses them, you can use the full colour range of direct-colour BG1 without worrying about shared colours on the other layer.
MSonage
Posts: 22
Joined: Fri May 06, 2022 4:34 pm

Re: Two simultaenous mode 7 textures?

Post by MSonage »

There's this effect in Chaos Conflix:
Image

This was probably done with a tilemap with 2 different textures, then scrolling and resetting the positions to keep each texture on the right line.
And of course, "interlacing" each lines between each texture.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Two simultaneous mode 7 textures?

Post by rainwarrior »

MSonage wrote: Tue Aug 02, 2022 9:18 pmThis was probably done with a tilemap with 2 different textures
Is that not just the same cloud texture twice? The interlacing does make it seem like 2 layers together, sort of.

I couldn't find the game by that name... I did discover a BS game called Treasure Conflix, though it doesn't seem to run correctly in any emulator I've tried yet...

I was starting to think about ways to do a perspective-plane effect without Mode 7, so you could use that as an alternative for the requested sky effect. The Famicom game Tetrastar has an interesting technique, where the game has library of graphics where each page is a single horizontal-line worth of ground presented at a series of expanding magnifications. To render the tilted plane, each scanline switches in the corresponding page from the library.
tetrastar_technique.png
Unfortunately, SNES can't bankswitch graphics tiles per-scanline like this, and would have to DMA them in advance somehow. There might be a clever variation on this idea suitable for the VRAM situation, though I can't think of one offhand.

Otherwise you might be able to fit a looping cloud plane animation in the available VRAM, or maybe even software-render one and DMA it, with various levels of compromise to deal with.
iNCEPTIONAL

Re: Kulor's Guide to Mode 7 Perspective Planes

Post by iNCEPTIONAL »

lidnariq wrote: Tue Aug 02, 2022 3:08 pm The best one can do is just-so-happen to be able to fit both camera views into the one texture and make sure each camera can't see the other half of the texture, or a palette swap between the SNES's configurable palette and the R3G3B2 fixed palette, or a bunch of black scanlines in the middle for a more interesting palette swap.
So, could half of the texture be drawn by the artist as a sky and half of the texture be drawn as the ground*, even if you need to use less than half of the available tiles for each to fit each half into the camera view and move each half separately, and then it just be split in code like you said and each half moved in a different direction?

If not, I'm not quite clear on what you're saying there.

*Certainly, there's more than enough tiles and colours in the tilemap for any artist to draw the background with those two things on it. I think it's like a 128x128 tilemap for Mode 7 backgrounds, right, so half or less than half for each part--and it really can be as small as needed as far as I'm concerned, so long as the end result looks like a decent sky and a decent ground texture
Post Reply