don't click here

Working Palette Cycling in GM

Discussion in 'Fangaming Discussion' started by Mercury, May 7, 2011.

  1. Mercury

    Mercury

    His Name Is Sonic Tech Member
    1,740
    21
    18
    Location Location
    AeStHete
    It's no secret that I like palette cycling. What I've always found pretty annoying, though, is that there's no native workable solution to get the effect running in Game Maker (which is what I'm making my Sonic engine in). Some levels absolutely rely on it or they look lifeless and lame - just picture Techno Base without it! More importantly, it's used to animate huge waterfalls that would be a real pain to make with sprites in GM.

    Well, after lots of searching and beating my head against solid surfaces, I finally found a pixel shader solution that works. It's easy for me to implement even with my feeble grasp of shaders, and runs on both of my machines (they're about 5 years old, I guess) without slowdown.

    So, I want to know how it works for anybody else. Download this demo of the effect and run it. If it runs on a fair amount of systems, I'll go ahead and use it for my engine (and by extension Sonic Time Twisted will get the benefit, too).

    (If I'm feeling particularly generous - and not too self-conscious about how kludged together it all is - I might also write a tutorial explaining how I did it. =P )

    Thanks in advance! :)

    EDIT: I realise now that, though I'm using this for a Sonic engine, it's really only tangentially related to Sonic and mods might want to move this to Technical Discussion (?).
     
  2. Miles3298

    Miles3298

    Member
    581
    19
    18
    It works on my relatively lower end Vista and Windows 7 computers just fine.

    On my XP Pro computers (the best of which is this, which isn't that great to begin with), not so fine.

    The worst result was of the lowest possible form of low-end computers:
    [​IMG]

    On my other XP machine, it gave me an error in the creation event of your object, telling me that Pixel Shader 1.4 was needed to run it.

    I think most users here have way above my set-ups.

    @ the guy below: There are easy, way-less-efficient methods of doing that.
     
  3. Lapper

    Lapper

    Lappering Tech Member
    1,763
    951
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    Hey, this is pretty good, you can now have animated backgrounds in GM, I haven't seen it done before.

    It works fine for me (W7) in the demo, don't know how it would effect the speed of a game though.
     
  4. Cinossu

    Cinossu

    Administrator
    2,832
    44
    28
    London, UK
    Sonic the Hedgehog Extended Edition
    Runs fine on here, Intel Core 2 Duo @ 2.2GHz, 4GB RAM, with the ATI Mobility Radeon HD 4570, running on Win7 Ultimate 64-bit.

    As for the topic.. considering it's using Game Maker, and will be implemented into a fangame, I think it'd be better to have the topic in Fangames Discussion. It could be considered technical, with the use of the pixel shader, but I feel it'd be better placed for its resulting outcome.
     
  5. LOst

    LOst

    Tech Member
    4,891
    8
    18
    Hi Mercury. Your shader works on my computers. That was to be expected as shaders MUST work on my dev computers. Looks just like the water palette animation in Green Hill Zone.

    About your shader, you are probably doing some fancy stuff like turning things grayscale as well as using the resulting 0-1 value as a texture coord...

    As you can see I stopped there because I don't want to be too rude. Just prove that High Level Shading Language (edit: it is actually asm code, not HLSL) can be easily "stolen" from RAM, in form of the original source code :( That's the main drawback of shaders.
     
  6. Techokami

    Techokami

    For use only on NTSC Genesis systems Researcher
    1,373
    81
    28
    HoleNet!
    Sonic Worlds Next
    It works on my modern computer system (Intel Core i7, NVIDIA GeForce GT 240, Win7 Ultimate x64), but I don't feel like digging out my old 5+ year old laptop to test it on an older 64-bit AMD machine.
     
  7. Mercury

    Mercury

    His Name Is Sonic Tech Member
    1,740
    21
    18
    Location Location
    AeStHete
    Actually my entire engine is going to be open source, so I don't mind if people can see the shader code. In fact, it's stored as a string in GM and passed to the shader extension to be compiled at initialisation, allowing someone with knowledge of shaders to easily make modifications. That someone wouldn't be me at present though - I'm just using a direct copy of an open source example here. I plan on boning up on them, though, now that I have a way to actually use them in GM easily.

    Also, thanks to those who have tested so far! :thumbsup:
     
  8. Overbound

    Overbound

    Member
    607
    21
    18
    Iowa
    Sonic Time Twisted Creator
    Works great for me Mercury. So glad you got this worked out. The water animation created as a result looks more fluid than the original GHZ.
     
  9. Overlord

    Overlord

    Now playable in Smash Bros Ultimate Moderator
    19,218
    965
    93
    Long-term happiness
    Runs fine with a solid frame rate on my PC. Core 2 Quad Q8300, 4GB RAM, GeForce 9800 GT 512MB, Windows 7 Home Premium x64.
     
  10. DimensionWarped

    DimensionWarped

    Erinaceous! Oldbie
    Works fine. Radeon HD5770.
     
  11. Mercury

    Mercury

    His Name Is Sonic Tech Member
    1,740
    21
    18
    Location Location
    AeStHete
    Great! STT won't have to have that static "Game Maker Sonic" look anymore.

    That might be because I didn't bother to find out the actual speed of the original. =P

    Though, certainly this shader solution can allow improvements to the look - more tweener colours, more colours cycling at once, etc.

    Also I've been learning about shaders and have done a few tests - water/heat distortion should be possible, too.
     
  12. Azu

    Azu

    I must be stupid. Member
    I have no issues here. Works just fine. 8400GS.
     
  13. Works perfectly on my 64-bit Window 7 Home Premium.

    Also the framerate drops down a bit when you move the window around, but I don't think thats much of an issue.
     
  14. amphobius

    amphobius

    doing more important things with my life Member
    2,120
    0
    16
    life
    Runs with considerable frame-skip. Seems to be too system intensive for my computer.
     
  15. Overbound

    Overbound

    Member
    607
    21
    18
    Iowa
    Sonic Time Twisted Creator
    Using shaders sounds like it will open up a lot of possibilities for us. But I also wonder are their limits? In Attraction Attack for instance we talked about doing the spot lights coming from the city in the background. Vexer also made a couple of flashing decorations that could be done with tiles and shaders or animated objects. Then of course there's the house shoe pattern again. So I guess the question is how resource intense are these shaders?
     
  16. Andrew75

    Andrew75

    Technical Artist Member
    2,030
    107
    43
    Project AXSX(Sonic Xtreme) + Misc Projects
    Works very well with this low end nforce 6100.
    hnmm,,,, wonder if it would be easier to pull off the effect using ult 3D plug-in and its shader functions.
    however, I know that may not be a path your looking to take.
     
  17. Mercury

    Mercury

    His Name Is Sonic Tech Member
    1,740
    21
    18
    Location Location
    AeStHete
    Last time I checked out Ultimate 3D it didn't integrate with the standard GM window and you had to use its drawing commands for your whole game, which kind of put me off since I'm used to GM's functions and it's a simple 2D game. But the shader extension I'm using now integrates completely and is as easy as toggling the blend mode in GM.

    Limits? Well, for one I don't think 2 shaders can be applied at the same time without some complicated tricks, but that's not too big a deal. As for resource intensive, my machines are pretty crappy (too crappy to let me continue working on SFR with Unity) but the shader demo that I based this test on runs on them at over 300fps! I was not expecting that at all, so I'm pretty happy.
     
  18. Andrew75

    Andrew75

    Technical Artist Member
    2,030
    107
    43
    Project AXSX(Sonic Xtreme) + Misc Projects
    What sort of system are you running Mercury?
     
  19. Mercury

    Mercury

    His Name Is Sonic Tech Member
    1,740
    21
    18
    Location Location
    AeStHete
    Computer 1:

    Code (Text):
    1. Processor: Intel(R) Pentium(R) 4 CPU 2.93GHz
    2. Memory: 504MB RAM
    3. DirectX Version: DirectX 9.0c (4.09.0000.0904)
    4. [Display] Chip type: Intel(R) 82915G/GV/910GL Express Chipset
    5. Display Memory: 128.0 MB
    Computer 2:

    Code (Text):
    1. Processor: Intel(R) Pentium(R) 4 CPU 3.00GHz (2 CPUs)
    2. Memory: 502MB RAM
    3. DirectX Version: DirectX 9.0c (4.09.0000.0904)
    4. [Display] Chip type: Intel(R) 82915G/GV/910GL Express Chipset
    5. Display Memory: 128.0 MB
    Huh. I guess they're both pretty much the same.
     
  20. Andrew75

    Andrew75

    Technical Artist Member
    2,030
    107
    43
    Project AXSX(Sonic Xtreme) + Misc Projects
    Dear God, no.....
    how could this be ?
    Massive talent restricted by such a system.

    perhaps some of us could donate some computer hardware for this guy to work on bigger projects. hint hint.
    I could donate an Nvidia GTX 550 and maybe some memory.