Using colour math with additive blending

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

Re: Using colour math with additive blending

Post by iNCEPTIONAL »

rainwarrior wrote: Sun Jul 10, 2022 3:00 pm
iNCEPTIONAL wrote: Sun Jul 10, 2022 2:43 pmI can't understand anything else from Mesen-S other than the stuff I can see visually. All the random values and stuff off to the side generally don't mean anything to me
If you put the mouse over a sprite in the sprite viewer, you can see exactly what the tile looks like and it brings it to the front with a rectangle showing where it is. It's very good for seeing how a layered sprite is put together, visually.
So, he's layered, yet both the body and the eyes/mouth/etc fade out together, so why even bother with the layering in that case?
With separate pieces they can move the eyes/mouth/arm across the body without a million huge unique sprites for every position. The pieces you see cover everything it does without needing any more tile data.
Anyway, how did you get to the boss that fast to check it? Do you have the game completed with the level saved and the you just went straight there? I don't have a completed and saved version of the game unfortunately.
You might find this site useful: https://www.zophar.net/savestates/snes.html
1. Good tip. I'll check that out.

2. Ah, yeah, that makes sense. I'll keep that in mind for any animation I want on larger bosses and the like.

3. Now that might be very useful indeed. But once I've downloaded them, how do I use them? Do I just run the game then choose Load State and navigate to the downloaded file and bingo?
creaothceann
Posts: 611
Joined: Mon Jan 23, 2006 7:47 am
Location: Germany
Contact:

Re: Using colour math with additive blending

Post by creaothceann »

rainwarrior wrote: Sun Jul 10, 2022 2:23 pm UI overlays could benefit from alpha gradients.

A version of many of these suggestions could be done with additive or subtractive only, but a full alpha blend does widen the possibilities
Additive already looks pretty good to me...

iNCEPTIONAL wrote: Sun Jul 10, 2022 2:54 pm
turboxray wrote: Sun Jul 10, 2022 2:49 pm It's takes up less rom space and less vram space when you construct a meta-sprite for layers
Now why is this?
Imagine an RPG where a playable character could select from a dozen weapons. It's much easier to use sprites for them instead of generating and storing all possible versions (each frame of each standing/walking/attacking/etc animation would have to include all possible weapons).

iNCEPTIONAL wrote: Sun Jul 10, 2022 3:04 pm how do I use them?
Find out where your emulator stores the *.SRM file, exchange that file with the one you downloaded. (It'll most likely have the same name as the ROM.)

https://www.youtube.com/results?search_ ... %26+States
Last edited by creaothceann on Sun Jul 10, 2022 4:16 pm, edited 1 time in total.
My current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
Catyak
Posts: 54
Joined: Mon Apr 25, 2022 4:33 pm

Re: Using colour math with additive blending

Post by Catyak »

iNCEPTIONAL wrote: Sun Jul 10, 2022 3:04 pm 3. Now that might be very useful indeed. But once I've downloaded them, how do I use them? Do I just run the game then choose Load State and navigate to the downloaded file and bingo?
Swap the file for the save file for the game that supports them. In Mesen-S, this is the "Saves" directory under the root directory, and the file to replace has the game's name. Rename the new save file to the name of the old one (after first copying the name of the current save file and then renaming it to anything else) Keep in mind these aren't save states, but (partially) completed save files for games that supported battery backup or other forms of on-cartridge saves. For games that didn't use battery backup save data, you can use in game debugging features like in game level selects (if present, look up the game on TCRF or similar sites to check), or if all else fails, cheat codes, to get to a specific area of a game. (Mesen-S has a built in database of cheats, which can be accessed through the Cheats menu under the Tools menu)

The same site has a SNES save state section, but only for save states that work in ZSNES, and no other emulator. Since ZSNES is pretty old and has several issues with certain games, I'd stick with a more modern emulator like Mesen-S and just use other means to get to the point of interest. (like in game debugging features and/or cheat codes)
iNCEPTIONAL

Re: Using colour math with additive blending

Post by iNCEPTIONAL »

By the way, I take it I can use the Main and Subscreen even if I don't intend to use any kind of colour math but just as a way to arrange layers and sprites that might help beyond the normal layer ordering and priorities, such as putting layer 3 elements on the Subscreen without applying any colour math so I can actually place them on top of Layer 2, which wouldn't normally be possible otherwise, right?

I mean, LMPunny actually already did this when testing my bridge level, but I just want to make sure that I understand you can basically use the Main and Subscreen for colour math as per normal/typical or you can use it as a further slightly cheaty way to arrange the order of layers and sprites more than normal (presumably so long as you're not using it for colour math effects at that time).
Last edited by iNCEPTIONAL on Sun Jul 10, 2022 4:59 pm, edited 1 time in total.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Using colour math with additive blending

Post by rainwarrior »

No, the subscreen is not visible. It only exists as a source for colour math. (Or for 512px resolution.)

You can do all the layering you're talking about on the main screen already though.
iNCEPTIONAL

Re: Using colour math with additive blending

Post by iNCEPTIONAL »

Catyak wrote: Sun Jul 10, 2022 4:22 pm
iNCEPTIONAL wrote: Sun Jul 10, 2022 3:04 pm 3. Now that might be very useful indeed. But once I've downloaded them, how do I use them? Do I just run the game then choose Load State and navigate to the downloaded file and bingo?
Swap the file for the save file for the game that supports them. In Mesen-S, this is the "Saves" directory under the root directory, and the file to replace has the game's name. Rename the new save file to the name of the old one (after first copying the name of the current save file and then renaming it to anything else) Keep in mind these aren't save states, but (partially) completed save files for games that supported battery backup or other forms of on-cartridge saves. For games that didn't use battery backup save data, you can use in game debugging features like in game level selects (if present, look up the game on TCRF or similar sites to check), or if all else fails, cheat codes, to get to a specific area of a game. (Mesen-S has a built in database of cheats, which can be accessed through the Cheats menu under the Tools menu)

The same site has a SNES save state section, but only for save states that work in ZSNES, and no other emulator. Since ZSNES is pretty old and has several issues with certain games, I'd stick with a more modern emulator like Mesen-S and just use other means to get to the point of interest. (like in game debugging features and/or cheat codes)
Cool. Thanks for that.
iNCEPTIONAL

Re: Using colour math with additive blending

Post by iNCEPTIONAL »

rainwarrior wrote: Sun Jul 10, 2022 4:53 pm No, the subscreen is not visible. It only exists as a source for colour math. (Or for 512px resolution.)

You can do all the layering you're talking about on the main screen already though.
So, how did LMPunny manage to make part of layer 3 appear on top of layer 2 in my bridge level when that's not normally possible? He said he used the Subscreen to do this.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Using colour math with additive blending

Post by rainwarrior »

I have no idea what ROM you're talking about, or what was said, so I really can't guess.

In Mode 1 BG3 can be placed both on top of BG1+2 and below them.

Opaque layering is not done with the subscreen. Though, in theory you could maybe use the main screen with layers that have colour math disabled, then a black background, and let the subscreen do additive blend "underneath" that... but it'd be pointlessly complicated when you can just layer them like that normally on the main screen already?
iNCEPTIONAL

Re: Using colour math with additive blending

Post by iNCEPTIONAL »

rainwarrior wrote: Sun Jul 10, 2022 5:11 pm I have no idea what ROM you're talking about, or what was said, so I really can't guess.

In Mode 1 BG3 can be placed both on top of BG1+2 and below them.

Opaque layering is not done with the subscreen. Though, in theory you could maybe use the main screen with layers that have colour math disabled, then a black background, and let the subscreen do additive blend "underneath" that... but it'd be pointlessly complicated when you can just layer them like that normally on the main screen already?
"what i did was mainscreen and subscreen manipulation per scanline. you can asign the four layers and sprites/objects to go on either the mainscreen or subscreen. what's on the mainscreen will always be in front of the subscreen no matter the priorities. so the cars (layer 3) for their scanlines are in mainscreen, and the road (layer 2) is in subscreen." -- LMPunny

That's what he said regarding how he managed to make the cars display on top of the bridge in my game, even though I accidentally put them on layer 3 thinking you could simply set the layer priorities to make any layer appear on top of any other layer, when, as I learned later later, normally nothing on layers 4 or 3 can appear on top of layers 2 and 1: https://youtu.be/IyrOCNQc_rs
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Using colour math with additive blending

Post by rainwarrior »

If you've got a ROM I could tell you exactly what it's doing, but I can't really guess much.

There's just not really a good reason I can think of to use subscreen to try and do opaque layering? The main screen already do this on its own, and recruiting the subscreen means you can't use colour math.

Like if this is just a kludge because the layers were set up incorrectly, and you don't need colour math anyway, I guess it's not wrong to do... though you could also just switch the BG address per-scanline to get the same effect on the main screen by itself. Or you could just fix the layers in the source art and not need any special solution.
93143
Posts: 1717
Joined: Fri Jul 04, 2014 9:31 pm

Re: Using colour math with additive blending

Post by 93143 »

This might actually be necessary to get BG3 to display in between BG1 and BG2 in Mode 1. In Mode 0 it's hard to see why you'd need to do this, because all four BGs have the same specs.
iNCEPTIONAL

Re: Using colour math with additive blending

Post by iNCEPTIONAL »

93143 wrote: Sun Jul 10, 2022 7:28 pm This might actually be necessary to get BG3 to display in between BG1 and BG2 in Mode 1. In Mode 0 it's hard to see why you'd need to do this, because all four BGs have the same specs.
Because BGs 4, 2 and 1 are all fullscreen overlapping layers, so, in order to have BG3 show the small bridge (or ship armada later in the level) behind the main bridge plus the cars on top of the road, it has to be both behind BG2 for part and in front of BG2 for part, which normally wouldn't be possible because BG3 can't go in front of BG2.
Last edited by iNCEPTIONAL on Mon Jul 11, 2022 1:04 am, edited 1 time in total.
iNCEPTIONAL

Re: Using colour math with additive blending

Post by iNCEPTIONAL »

rainwarrior wrote: Sun Jul 10, 2022 6:08 pm If you've got a ROM I could tell you exactly what it's doing, but I can't really guess much.

There's just not really a good reason I can think of to use subscreen to try and do opaque layering? The main screen already do this on its own, and recruiting the subscreen means you can't use colour math.

Like if this is just a kludge because the layers were set up incorrectly, and you don't need colour math anyway, I guess it's not wrong to do... though you could also just switch the BG address per-scanline to get the same effect on the main screen by itself. Or you could just fix the layers in the source art and not need any special solution.
Well, BGs 4, 2 and 1 are all fullscreen overlapping layers, so, in order to have BG3 show the small bridge (or ship armada later in the level) behind the main bridge plus the cars on top of the road, it has to be both behind BG2 for part and in front of BG2 for part, which normally wouldn't be possible because BG3 can't go in front of BG2 typically.

So it seems like right there is a good reason to use this method, or at least it definitely solved my problem with how to do the layers the way I had them set up in the mock-up I had made in Game Maker, which, as I learned, wasn't entirely accurate to how the layers normally worked on SNES.

Now, I don't know about just switching the BG address per scanline as you said, maybe that would work here too, but this Mainscreen/Subscreen method is what LMPunny used in this particular case.

Here's the early bridge level test build LMPunny made that runs in a SMW rom hack:
Mode0Bridge.zip
(583.63 KiB) Downloaded 12 times
Just press Start multiple times to get to the level.

On a side note, does that mean I couldn't have semi-transparency on the sprites for the ship shadows in the bridge level because of the way he used the Mainscreen/Subscreen in this situation?
Last edited by iNCEPTIONAL on Mon Jul 11, 2022 2:18 am, edited 1 time in total.
Myself086
Posts: 158
Joined: Sat Nov 10, 2018 2:49 pm

Re: Using colour math with additive blending

Post by Myself086 »

iNCEPTIONAL wrote: Mon Jul 11, 2022 12:42 am Now, I don't know about just switching the BG address per scanline as you said
We talked about this during our call the other day. However, I forgot to tell you that it doesn't work so well with mode 0 because each BG has its own 8 palettes.

It's even used in Puzzle Bobble, I think it's to change to a mode with offset-per-tile and one layer had to be moved to a different BG. I haven't fully looked into it. I mentioned this game during our call but without the exact name.
iNCEPTIONAL

Re: Using colour math with additive blending

Post by iNCEPTIONAL »

Myself086 wrote: Mon Jul 11, 2022 1:49 am
iNCEPTIONAL wrote: Mon Jul 11, 2022 12:42 am Now, I don't know about just switching the BG address per scanline as you said
We talked about this during our call the other day. However, I forgot to tell you that it doesn't work so well with mode 0 because each BG has its own 8 palettes.

It's even used in Puzzle Bobble, I think it's to change to a mode with offset-per-tile and one layer had to be moved to a different BG. I haven't fully looked into it. I mentioned this game during our call but without the exact name.
Yeah, I'm still not sure exactly how that would work in this case, as in what I would have to do as the artist and/or give the programmer in order for them to switch the BG address to get the BG3 elements to appear both behind and front of BG2 while also not conflicting with how the rest of the layers work, etc.

If it can be explained to me in a way I can understand and use when creating the assets for the levels, and it actually costs less resources and/or comes with less compromises than the Mainscreen/Subscreen method LMPunny used when all is said and done, then I'm more than happy to use the switching BG address method.

Ultimately, all I care about is achieving the desired end result in the most resource/code efficient way and being able to understand exactly what I have to do on my part in order for the programmer to achieve this.
Post Reply