SRB2 handles transparency in a weird way. When rendering a transparent object on top of a background, most modern game engines will need to calculate a formula to 'blend' the foreground and background colors of each pixel. There are lots of different ways to do this of course, with lots of different potential effects, but it's 1993 and math is expensive, so like many things in the Doom engine, we save time by using a lookup table.
With only 10 transparency levels and 256 colors in SRB2's pallete, these "transtables" just have to store the result value for every combination of two pixel colors for a given transparency level. They do this in the form of a series of 10 256x256 flats just sitting in the iwad waiting to be messed with.
So let's mess with them.
This is the vanilla table for 50% transparency. The x value corresponds to the palette index of the background color, and the y value to the palette index of the foreground color.
One way you could think of it is as two copies of this image- one rotated 90 degrees- overlaid on top of each other. If you do that in photoshop, and set the rotated image's opacity to 50%, then use SLADE to convert it to SRB2's palette, you get something pretty close (although curiously not identical) to the vanilla transtables.
Photoshop has a bunch of other blending modes though, which provides us an easy way to experiment with different options and see how they look in SRB2.
Photoshop calls this blending mode "Linear Dodge," but I've also seen it called "Additive." The math is pretty simple, and it pops up in a lot of game engines a cheap part of some nifty effects.
Here's a comparison of the vanilla blending versus additive blending in a case where additive is pretty neat. The brighter spots on the sprite are more opaque than the darker parts, and the whole thing converges on bright, desaturated whites. It makes things look softer and more energy-like.
SMS' Corona is another good use case for additive blending. On the flip side, ACZ is full of spots where it looks pretty terrible. The tornado effect's shading is completely gone, and the wall textures break for reasons I don't fully understand.
Additive blending is at its best when applied to a particle system. Denser areas of particles converge on brighter colors, and things can be made to look genuinely on fire. I bet you didn't even know SRB2's software renderer could look like that.
Of course, the transtable mod also broke CEZ1's colormap here. We're pretty limited by the fact that to my knowledge, our only way to add more transtables is to replace the vanilla ones. They also only seem to work when loaded via launch parameters- from something like a batch file. When loaded by addfile or the addons menu, they just kinda don't do anything.
For one last experiment, I decided to try getting really weird:
This transtable is completely opaque- with the exception of a range of blacks and whites, which will specifically not render in front of a range of blues. The sprite is used for another simple particle system. The result?
The stroke only appears on the very edges of the particle system- creating the illusion of a single coherent sprite. If you wanted, you could create some very interesting blob effects using this technique.
These were the most interesting results of my experiments, but there's all kinds of wacky things you can do with transparency tables. I encourage anyone who's interested to try messing around with them.
With only 10 transparency levels and 256 colors in SRB2's pallete, these "transtables" just have to store the result value for every combination of two pixel colors for a given transparency level. They do this in the form of a series of 10 256x256 flats just sitting in the iwad waiting to be messed with.
So let's mess with them.
This is the vanilla table for 50% transparency. The x value corresponds to the palette index of the background color, and the y value to the palette index of the foreground color.
One way you could think of it is as two copies of this image- one rotated 90 degrees- overlaid on top of each other. If you do that in photoshop, and set the rotated image's opacity to 50%, then use SLADE to convert it to SRB2's palette, you get something pretty close (although curiously not identical) to the vanilla transtables.
Photoshop has a bunch of other blending modes though, which provides us an easy way to experiment with different options and see how they look in SRB2.
Photoshop calls this blending mode "Linear Dodge," but I've also seen it called "Additive." The math is pretty simple, and it pops up in a lot of game engines a cheap part of some nifty effects.
Here's a comparison of the vanilla blending versus additive blending in a case where additive is pretty neat. The brighter spots on the sprite are more opaque than the darker parts, and the whole thing converges on bright, desaturated whites. It makes things look softer and more energy-like.
SMS' Corona is another good use case for additive blending. On the flip side, ACZ is full of spots where it looks pretty terrible. The tornado effect's shading is completely gone, and the wall textures break for reasons I don't fully understand.
Additive blending is at its best when applied to a particle system. Denser areas of particles converge on brighter colors, and things can be made to look genuinely on fire. I bet you didn't even know SRB2's software renderer could look like that.
Of course, the transtable mod also broke CEZ1's colormap here. We're pretty limited by the fact that to my knowledge, our only way to add more transtables is to replace the vanilla ones. They also only seem to work when loaded via launch parameters- from something like a batch file. When loaded by addfile or the addons menu, they just kinda don't do anything.
For one last experiment, I decided to try getting really weird:
This transtable is completely opaque- with the exception of a range of blacks and whites, which will specifically not render in front of a range of blues. The sprite is used for another simple particle system. The result?
The stroke only appears on the very edges of the particle system- creating the illusion of a single coherent sprite. If you wanted, you could create some very interesting blob effects using this technique.
These were the most interesting results of my experiments, but there's all kinds of wacky things you can do with transparency tables. I encourage anyone who's interested to try messing around with them.
Attachments
-
Vanilla Trans50.png32.2 KB · Views: 1,072
-
background.png3.7 KB · Views: 858
-
TRANS50.png41.9 KB · Views: 862
-
normaladditivecomparison.png286.6 KB · Views: 878
-
srb20024.png73.8 KB · Views: 840
-
srb20025.png101.2 KB · Views: 870
-
srb20073.gif2.3 MB · Views: 915
-
srb20075.gif1.9 MB · Views: 848
-
Corona - Copy - Copy (2) - Copy.png17.4 KB · Views: 816
-
BLOB.png4.3 KB · Views: 824
Last edited: