• Do not use Works in Progress as a way of avoiding the releases system! Works in Progress can be used for sharing early betas and for getting suggestions for improvement. Releases of finished content are not allowed in this forum! If you would like to submit a finished addon, click here for instructions on how to do so.

Fun with transtables

Status
Not open for further replies.

Princess Plushima

Princess of Dreams
Judge
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.
attachment.php

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.

attachment.php

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.

attachment.php

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.
attachment.php


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.

attachment.php
attachment.php


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.
attachment.php
attachment.php

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:


attachment.php
attachment.php


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?


attachment.php

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.png
    Vanilla Trans50.png
    32.2 KB · Views: 879
  • background.png
    background.png
    3.7 KB · Views: 755
  • TRANS50.png
    TRANS50.png
    41.9 KB · Views: 772
  • normaladditivecomparison.png
    normaladditivecomparison.png
    286.6 KB · Views: 757
  • srb20024.png
    srb20024.png
    73.8 KB · Views: 749
  • srb20025.png
    srb20025.png
    101.2 KB · Views: 779
  • srb20073.gif
    srb20073.gif
    2.3 MB · Views: 839
  • srb20075.gif
    srb20075.gif
    1.9 MB · Views: 752
  • Corona - Copy - Copy (2) - Copy.png
    Corona - Copy - Copy (2) - Copy.png
    17.4 KB · Views: 738
  • BLOB.png
    BLOB.png
    4.3 KB · Views: 744
Last edited:
That last one's an awesome effect - hadn't ever considered the transtables being used like that.

I've always wondered how the hexadecimal values from colormaps/fogs are translated into the transtables; anyone have any insight on that?
 
I've always noticed these but wasnt fully sure how to edit them. I was frankly a bit worried i would break something if i touched it. But this is pretty interesting!

If only there was a way we could use different transmaps on the fly to apply certain blends to different things. I.e normal transmaps for the whole game but the shield uses additive transmaps
 
This is absolutely fascinating. Given the Doom engine's limitations, is it possible in theory to use different transtables for different objects?
 
This is absolutely fascinating. Given the Doom engine's limitations, is it possible in theory to use different transtables for different objects?

I don't see why it wouldn't be. Slopes were impossible once, and this is an order of magnitude more tame than that.

Heck, on modern CPUs you could probably do all these different blending modes with math rather than lookup tables with minimal performance penalty, though it could be interesting if you were to let modders define their own lookup tables.
 
This is absolutely fascinating. Given the Doom engine's limitations, is it possible in theory to use different transtables for different objects?
Sorry for sounding pompous but isn't this game using a modified version of the Doom Legacy engine rather than the original one from 1993?
 
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.
That's because patched textures use translucency as well.

A good example of this is CEZ's sky having translucent cloud patches.

attachment.php
 

Attachments

  • example.png
    example.png
    37.6 KB · Views: 426
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top