Working Palette Cycling in GM

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

  1. Mercury

    Mercury

    His Name Is Sonic Tech Member
    It's <a href="http://forums.sonicretro.org/index.php?showtopic=22316&hl=palette%20cycling&st=0" target="_blank">no secret</a> 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 <a href="http://dl.dropbox.com/u/5437265/Sonic%20Hacking/PalCycTest.exe" target="_blank">this demo</a> 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
    555
    3
    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 <a href="http://h10025.www1.hp.com/ewfrf/wc/document?docname=c00063244&tmp_task=prodinfoCategory&lc=en&dlc=en&cc=us&lang=en&product=435558&key=null&site=null" target="_blank">this</a>, 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, <a href="http://i294.photobucket.com/albums/mm110/Miles3298/Low-End-Result.png" target="_blank">it gave me an error in the creation event of your object</a>, 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

    Member
    1,672
    518
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy: WW, 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,830
    16
    18
    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
    6
    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,357
    47
    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
    <!--quoteo(post=584880:date=May 7 2011, 09:39 AM:name=LOst)--><div class='quotetop'>QUOTE (LOst @ May 7 2011, 09:39 AM) <a href="index.php?act=findpost&pid=584880">[​IMG]</a></div><div class='quotemain'><!--quotec-->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.<!--QuoteEnd--></div><!--QuoteEEnd-->
    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
    605
    19
    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
    18,668
    614
    93
    Berkshire, England
    Learning Cymraeg
    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
    <!--quoteo(post=584912:date=May 7 2011, 05:02 PM:name=Overbound)--><div class='quotetop'>QUOTE (Overbound @ May 7 2011, 05:02 PM) <a href="index.php?act=findpost&pid=584912">[​IMG]</a></div><div class='quotemain'><!--quotec-->Works great for me Mercury. So glad you got this worked out.<!--QuoteEnd--></div><!--QuoteEEnd-->
    Great! STT won't have to have that static "Game Maker Sonic" look anymore.

    <!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->The water animation created as a result looks more fluid than the original GHZ.<!--QuoteEnd--></div><!--QuoteEEnd-->
    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
    605
    19
    18
    Iowa
    Sonic Time Twisted Creator
    <!--quoteo(post=585036:date=May 8 2011, 05:13 AM:name=Mercury)--><div class='quotetop'>QUOTE (Mercury @ May 8 2011, 05:13 AM) <a href="index.php?act=findpost&pid=585036">[​IMG]</a></div><div class='quotemain'><!--quotec--><!--quoteo(post=584912:date=May 7 2011, 05:02 PM:name=Overbound)--><div class='quotetop'>QUOTE (Overbound @ May 7 2011, 05:02 PM) <a href="index.php?act=findpost&pid=584912">[​IMG]</a></div><div class='quotemain'><!--quotec-->Works great for me Mercury. So glad you got this worked out.<!--QuoteEnd--></div><!--QuoteEEnd-->
    Great! STT won't have to have that static "Game Maker Sonic" look anymore.

    <!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->The water animation created as a result looks more fluid than the original GHZ.<!--QuoteEnd--></div><!--QuoteEEnd-->
    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.
    <!--QuoteEnd--></div><!--QuoteEEnd-->

    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,005
    88
    28
    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
    <!--quoteo(post=585246:date=May 9 2011, 04:38 AM:name=Andrew75)--><div class='quotetop'>QUOTE (Andrew75 @ May 9 2011, 04:38 AM) <a href="index.php?act=findpost&pid=585246">[​IMG]</a></div><div class='quotemain'><!--quotec-->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.<!--QuoteEnd--></div><!--QuoteEEnd-->
    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.

    <!--quoteo(post=585181:date=May 8 2011, 10:45 PM:name=Overbound)--><div class='quotetop'>QUOTE (Overbound @ May 8 2011, 10:45 PM) <a href="index.php?act=findpost&pid=585181">[​IMG]</a></div><div class='quotemain'><!--quotec-->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?<!--QuoteEnd--></div><!--QuoteEEnd-->
    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,005
    88
    28
    Project AXSX(Sonic Xtreme) + Misc Projects
    What sort of system are you running Mercury?
     
  19. Mercury

    Mercury

    His Name Is Sonic Tech Member
    <!--quoteo(post=585309:date=May 9 2011, 04:36 PM:name=Andrew75)--><div class='quotetop'>QUOTE (Andrew75 @ May 9 2011, 04:36 PM) <a href="index.php?act=findpost&pid=585309">[​IMG]</a></div><div class='quotemain'><!--quotec-->What sort of system are you running Mercury?<!--QuoteEnd--></div><!--QuoteEEnd-->

    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,005
    88
    28
    Project AXSX(Sonic Xtreme) + Misc Projects
    <!--quoteo(post=585420:date=May 10 2011, 04:49 AM:name=Mercury)--><div class='quotetop'>QUOTE (Mercury @ May 10 2011, 04:49 AM) <a href="index.php?act=findpost&pid=585420">[​IMG]</a></div><div class='quotemain'><!--quotec--><!--quoteo(post=585309:date=May 9 2011, 04:36 PM:name=Andrew75)--><div class='quotetop'>QUOTE (Andrew75 @ May 9 2011, 04:36 PM) <a href="index.php?act=findpost&pid=585309">[​IMG]</a></div><div class='quotemain'><!--quotec-->What sort of system are you running Mercury?<!--QuoteEnd--></div><!--QuoteEEnd-->

    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.
    <!--QuoteEnd--></div><!--QuoteEEnd-->

    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.