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.
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 »

iNCEPTIONAL wrote: Mon Jul 11, 2022 12:42 amOn 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?
Yes. Using the subscreen means that colour math is already spoken for and can't be used again for a second purpose.
iNCEPTIONAL wrote: Mon Jul 11, 2022 2:10 amUltimately, 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.
Just put the cars on layer 2 and the road on layer 3. Then you don't need any workarounds.
iNCEPTIONAL

Re: Using colour math with additive blending

Post by iNCEPTIONAL »

rainwarrior wrote: Mon Jul 11, 2022 11:39 am Just put the cars on layer 2 and the road on layer 3. Then you don't need any workarounds.
You know, that might be possible if I cut off the top of the trucks and leave them on layer 3 to go along with the roads that would have moved there too and then move the rest of the cars to layer 3. This wouldn't have worked previously but I got a bit lucky there because I had already cut off the bottom part of the reflections for the bridge in the background to get this all to work in the first place, which isn't ideal but not noticeable so long as the main bridge remains there in front of everything in the background. Although I was planning on destroying parts of the main bridge later in the level, but I can deal with that later and figure out how to add the full bottom part of the reflections for the far bridge when necessary, and I would have had to do that either way.

Edit: Ah, nope, I'd still need to bring the top of the trucks in front of layer 2 again. Probably why I just left it the way it was in the first place.

I think the only way to do it without having to move part of layer 3 above layer 2 would be to use sprites for the tops of the trucks, which would just mean I'd need to make sure I don't put too much sprites per scanline on those scanlines where the top of the truck sprites would be. That would be manageable, I think.

Edit 2: Ah, wait, I think I can move part of the layer 2 bridge girder section to layer 3 also, just the tile row where the top of the trucks would overlap, and that would work. . . .
Last edited by iNCEPTIONAL on Mon Jul 11, 2022 1:51 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 »

If you want to keep it as-is, just include the 2 pixels worth of rear bridge that the trucks overlap on layer 3 with the road.

(Or, maybe more practically: fill in the holes in the rear wall of the bridge with dark red so they're opaque and then keep 8 pixels of that on layer 3 with the road.)
iNCEPTIONAL

Re: Using colour math with additive blending

Post by iNCEPTIONAL »

rainwarrior wrote: Mon Jul 11, 2022 1:34 pm If you want to keep it as-is, just include the 2 pixels worth of rear bridge that the trucks overlap on layer 3 with the road.

(Or, maybe more practically: fill in the holes in the rear wall of the bridge with dark red so they're opaque and then keep 8 pixels of that on layer 3 with the road.)
Yeah, I just moved the 8-pixel row of the lower girder part of the bridge where the tops of the trucks overlap to layer 3 along with the road and it's fine.
Last edited by iNCEPTIONAL on Mon Jul 11, 2022 4:29 pm, edited 2 times 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 »

Myself086 wrote: Mon Jul 11, 2022 1:49 amIt'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.
The game basically has two layers. The background is 2bpp. The foreground is divided into regions. The fixed part at the top/bottom is mode 1 with 4bpp, and the playing area is mode 4 with 8bpp and OPT.

So, because the 2bpp background is: BG3 of mode 1 = BG2 of mode 4, they have to swap out the address when they switch modes. (Also the OPT data has to go at the BG3 address in mode 4.)

The reason they use mode 4 is to have 8bpp for the bubbles on the foreground. Each bubble is only 8 colours, but because they stick together in a hexagonal packing, 16-colour palettes can't cover all the possibilities where you get a two-bubble combination tile.

OPT lets them shift the bubbles down in the middle while keeping the frame at the sides steady.

There's other ways they could have done this, but switching from mode 1 to mode 4 necessitates the BG address switch.

(Interestingly, they probably could have used a colour math window for the "transparent" looking panel behind the playfield, but that's actually just a darkened palette on the background layer. This also means that levels with a scrolling background don't have this transparency effect.)
Post Reply