Question about sprite palettes and colour math
Forum rules
- For making cartridges of your Super NES games, see Reproduction.
-
SNES AYE
- Posts: 370
- Joined: Mon Nov 07, 2022 11:28 am
Question about sprite palettes and colour math
I'm aware that basically half of the palettes available for sprites can be used with and are affected by colour math to achieve various sprite transparency effects, but I just want to get clear in my head, can you individually choose to use say one or two sprite palettes from those available for colour math for transparency and leave the others still as opaque, or are all the objects using the palettes available for colour math basically automatically shown as semi-transparent on-screen as soon as you use any one of those palettes for transparency effects?
I am neurodivergent, so if any of my posts unintentionally upset you, I apologize.
-
Oziphantom
- Posts: 1980
- Joined: Tue Feb 07, 2017 2:03 am
Re: Question about sprite palettes and colour math
the pallets that are affected by colour maths will always be affected by colour maths, and the ones that aren't will never be.
-
SNES AYE
- Posts: 370
- Joined: Mon Nov 07, 2022 11:28 am
Re: Question about sprite palettes and colour math
So, if you're going to use colour math for transparency on any of the sprites on-screen, you only have four palettes left that you can use for all of the sprites on-screen that you don't want to have any transparency applied to at all, correct?Oziphantom wrote: Sun Jul 28, 2024 12:12 am the pallets that are affected by colour maths will always be affected by colour maths, and the ones that aren't will never be.
I am neurodivergent, so if any of my posts unintentionally upset you, I apologize.
-
Oziphantom
- Posts: 1980
- Joined: Tue Feb 07, 2017 2:03 am
Re: Question about sprite palettes and colour math
yup, but you can limit colour maths with windows.
-
SNES AYE
- Posts: 370
- Joined: Mon Nov 07, 2022 11:28 am
Re: Question about sprite palettes and colour math
Does that effectively mean that if you use a window or two to limit colour math affecting certain sprites, you can basically use any of the eight sprite palettes on those sprites regardless of colour math being used with some other sprites on-screen?
I am neurodivergent, so if any of my posts unintentionally upset you, I apologize.
-
Oziphantom
- Posts: 1980
- Joined: Tue Feb 07, 2017 2:03 am
Re: Question about sprite palettes and colour math
yes outside of the colour math enabled windows you are free to use all sprites pal - as far as I know, not sure anybody has really tested this, but its what the docs say should happen.
-
creaothceann
- Posts: 863
- Joined: Mon Jan 23, 2006 7:47 am
- Location: Germany
Re: Question about sprite palettes and colour math
Color math can be enabled or disabled for the six different pixel sources that can appear on the MainScreen:SNES AYE wrote: Sun Jul 28, 2024 1:43 am if you use a window or two to limit colour math affecting certain sprites, you can basically use any of the eight sprite palettes on those sprites regardless of colour math being used with some other sprites on-screen?
Code: Select all
register $2131 "CGADSUB"
bit 0: enable color math on mainscreen BG1 pixels
bit 1: enable color math on mainscreen BG2 pixels
bit 2: enable color math on mainscreen BG3 pixels
bit 3: enable color math on mainscreen BG4 pixels
bit 4: enable color math on mainscreen OBJ pixels
bit 5: enable color math on mainscreen backdrop pixels
bit 6: half color math: if 1 the result of color math is divided by 2, except if $2130.1 = 1 and the fixed color is used, or when color is clipped with the window function
bit 7: 0 = add subscreen to mainscreen, 1 = subtract subscreen from mainscreenWhen color math is enabled for OBJ (sprites), only sprites with palette rows 4..7 (colors 192..255) participate in color math. It cannot be disabled for individual sprites except via their palette row setting.
The windows (horizontal regions on a scanline that can be combined in various ways) can be used together with register $2130 to control color math.
Code: Select all
register $2130 "CGWSEL"
bit 0: 1 = DirectColor mode (256-color BGs only)
bit 1: 1 = use subscreen, 0 = use fixed color
bit 2: -
bit 3: -
bit 4: \ prevent color math
bit 5: / 00 = never, 01 = outside Color Window, 10 = inside Color Window, 11 = always
bit 6: \ clip colors to black before color math
bit 7: / 00 = never, 01 = outside Color Window, 10 = inside Color Window, 11 = alwaysMy current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
-
Señor Ventura
- Posts: 277
- Joined: Sat Aug 20, 2016 3:58 am
Re: Question about sprite palettes and colour math
there is a green mushroom in super mario world due to something like this, if i remember well...SNES AYE wrote: Sun Jul 28, 2024 12:54 amSo, if you're going to use colour math for transparency on any of the sprites on-screen, you only have four palettes left that you can use for all of the sprites on-screen that you don't want to have any transparency applied to at all, correct?Oziphantom wrote: Sun Jul 28, 2024 12:12 am the pallets that are affected by colour maths will always be affected by colour maths, and the ones that aren't will never be.
-
93143
- Posts: 1916
- Joined: Fri Jul 04, 2014 9:31 pm
Re: Question about sprite palettes and colour math
If a sprite is on the subscreen, you get colour math regardless of palette. You could use each individual sprite's priority with respect to background layers to select math per-sprite, with some limitations (you can't blend with the backdrop colour using this approach, so for a clean effect you may want a completely solid BG layer).SNES AYE wrote: Sat Jul 27, 2024 4:31 am I'm aware that basically half of the palettes available for sprites can be used with and are affected by colour math to achieve various sprite transparency effects, but I just want to get clear in my head, can you individually choose to use say one or two sprite palettes from those available for colour math for transparency and leave the others still as opaque, or are all the objects using the palettes available for colour math basically automatically shown as semi-transparent on-screen as soon as you use any one of those palettes for transparency effects?
For example, say BG1 is on the main screen, but not on the subscreen, and colour math is on for BG1. To simplify the example, no other BG layers are present. Sprites are on both main and sub screens (you don't get to pick individual sprites; they all go to both if both are selected as sprite destinations).
In this example, if a particular sprite has sprite-vs.-BG priority such that it is in front of BG1, and that sprite's palette doesn't use colour math (or colour math is turned off for sprites), it will show up solid, because it's the highest-priority pixel on the main screen and nothing on the subscreen is allowed to math with it. But a sprite using the same palette, but with a priority below BG1, will be occluded by BG1 on the main screen. Since BG1 isn't on the subscreen, though, this second sprite will show up on the subscreen, meaning it will math with BG1. This remains true even if colour math is turned off for sprites, because colour math enable is for the main screen.
This second sprite will obviously not math with any sprites that show up on the main screen, since sprites are flattened to a single layer by applying sprite-sprite priority before being sent to math. Sprites can math with themselves if they're using math palettes (which this isn't) if the pixel in question is in front on both screens, but the opportunity to math with other sprites can simply never arise because each screen pixel can only have one sprite in it at the point where the math happens.
Note that in this example, if there are holes in BG1, the second sprite will simply appear solid through them, since the (math-less) main screen copy of the sprite is still there behind BG1 and will show through the holes. If the main and subscreen backdrops are black and the blend mode is additive without halving, this doesn't matter because it would look the same anyway, but in other cases it could look weird.
Also note that since subtraction is not commutative, the effect of using subtraction between a main screen BG layer and a subscreen sprite will not be the same as it would be for a main-screen sprite using a math palette blending with a subscreen BG layer. Whatever is on the subscreen is subtracted from whatever is on the main screen, so you get a colour inversion. Additive modes are commutative (same result regardless of which side of the + sign the values are on) so it doesn't matter.
-
SNES AYE
- Posts: 370
- Joined: Mon Nov 07, 2022 11:28 am
Re: Question about sprite palettes and colour math
OK, that clarifies some stuff for me there and introduces some other options I wasn't aware of. Thanks.
I am neurodivergent, so if any of my posts unintentionally upset you, I apologize.