Clickteam Fusion 2.5 - Palette Swap Shader Finished 5/21/2021

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Just a tip: In this specific scenario, I don't know why, but you don't need the ps_main_pm or premultiplied version.
    To fix the white dithering on premultiplied you just need to multiply rgb by alpha at the end on ps_main, it will work for both

    That's very handy, thanks!
    It turns out that in DX11, dithering can be simplified a lot, since there isn't the limit on constants. Instead of using four separate 4x4 matrices, you can just use a single array[64].
    Oh, and I figured out how to make it a constant, defined outside of the main function, which ought to be marginally more performant than redefining it for every pixel.

    static const int ptn[64] = {
    0, 32, 8, 40, 2, 34, 10, 42,
    48, 16, 56, 24, 50, 18, 58, 26,
    12, 44, 4, 36, 14, 46, 6, 38,
    60, 28, 52, 20, 62, 30, 54, 22,
    3, 35, 11, 43, 1, 33, 9, 41,
    51, 19, 59, 27, 49, 17, 57, 25,
    15, 47, 7, 39, 13, 45, 5, 37,
    63, 31, 55, 23, 61, 29, 53, 21
    };

    // Get pattern index
    int ptnPixel = yIn * 8 + xIn;

    // Determine if the pixel should be 100% transparent or 100% opaque
    palPixel.a = ptn[ptnPixel] < alpha ? 1 : 0;


    I've updated the file here: Please login to see this link.


    Obviously you're welcome to add or remove whatever features you like, but I think my work here is done! Thanks again for your help :)

  • Kage - Nice. Good luck with the game :)

    Awesome! It's nice when people join forces to do something, we learn a lot by doing these :D

    Yep. Debugging DX11 shaders is definitely trickier than DX9, and I've experienced more "quirks" with it.
    I've had non-working shaders that stopped Fusion even running until they were deleted from the effects folder, and then this curious glitch here:

    Please login to see this picture.
    Keep watching. The shader didn't work, so that's why it's just a blank screen, but that's not the weird thing about it...

    The sprite is not animated, and I'm not changing the parameters (they're being updated "always", but only to the same values). So why the random glitch every few seconds?

  • The sprite is not animated, and I'm not changing the parameters (they're being updated "always", but only to the same values). So why the random glitch every few seconds?

    That's pretty confusing, I wonder if this "random" behavior can be exploited... I have this idea of making animated backdrops with shaders, but since you can't change their parameters it's not possible.

  • Yeah, I know, but the problem to me is object actually object limit... Backdrops are counted separately
    And quick backdrops are much more efficient when making a big rectangle, sure I could get a 1px object and stretch, but that would make so much more difficult for a shader to work correctly since it would scale with it.

  • The shader works fine, but I have some FPS drop when loading the palette from the hard drive, I think in my case it's better to use the shader variant from this topic, where all the palettes are already stored inside the character.
    NaitorStudios sorry to ask again, but could you add a flip function to this shader as well? I mean from Warguy555.

  • After I wrote this post, I realized that the shader from the topic cannot correctly show the 256 color palette, is there such a variant of the shader with internal storage of palettes in a row inside active object?

    Please login to see this picture.

  • Is it possible to use shaders to replace specific colors? As a replacement to "color replace" that isn't compatible with all exporters. Because i'm my case, i need to be able to change only some colors of a sprite, so i can customize some parts of the sprite only.

  • Sure, there are many shaders like this for Windows, these can be ported to mobile.

    Are shaders compatible with HTML5 (and then UWP)? My game is available on Steam, Xbox, Android and iOS so i need something compatible with all those exporters to replace my actual method that consist of using RGB coefficient and 3 sprites for the same object (1 for base color, 1 for dark colors and 1 for light colors)

  • HTML5, not at the moment.
    As for UWP, I doubt it will ever be, the UWP was discontinued by both Microsoft and Clickteam a long time ago...
    The only reason you can still use it is because not enough has changed to break it, child events may just work because internally it's not that different from normal events.

    Technically speaking UWP implementation would be the simplest of them all since Xbox uses DirectX/Direct3D as well, but since it's deprecated...
    But idk if it can be done without help from Clickteam.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!