Jump to content


Photo

Retro Palette Swap Shader - New Palette Tool! Now Supports Tiles!

shader gm:studio

  • Please log in to reply
221 replies to this topic

#101 gadgetmawombo

gadgetmawombo

    GMC Member

  • GMC Member
  • 330 posts
  • Version:Unknown

Posted 17 January 2015 - 11:03 PM

WOW! Unlimited colors now!? I've already been using this amazing shader in my game and I am SO upgrading to this new iteration!


  • 0

Merv%20combo_zpsklyiqgwb.gif

39134.png


#102 Copy X

Copy X

    GMC Member

  • GMC Member
  • 67 posts

Posted 24 January 2015 - 02:11 PM

"I really like the way "color overriding" works now.  Basically you can build dynamic palettes using surfaces as long as you follow the basic rules of palette creation, you can do whatever you want.  And the addition of being able to interpolate between palettes (both sprite and surface based) adds a LOT of power and possibilities."

Can you expand on this? Specifically dynamic palettes, does that mean you can change a palette (or two, or four)while it's in use?

 

Also, this doesn't seem to work on backgrounds, of course I could just be coding it wrong.


Edited by Copy X, 24 January 2015 - 02:13 PM.

  • 0

#103 GamerXP

GamerXP

    GMC Member?

  • GMC Member
  • 443 posts
  • Version:GM:Studio

Posted 24 January 2015 - 03:28 PM

Basically, you just need to create surface that same way you make palette sprites. And then you just draw colors you need on the surface, modifying sprites that use that surface as palette at the same time.

 

It can be made to work with backgrounds. It don't work since it use sprite_get_UVs in shader set script. Just need to make same script for backgrounds


  • 1

#104 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 03 February 2015 - 05:18 PM

@Copy X

 

Background should work just fine.  Make sure the palette is still a sprite or a surface and set the pal swap shader accordingly.  Then in your draw event after setting the shader, draw the bg with draw_background.  This is the code I used and it worked fine:

pal_swap_set(shd_pal_swapper,spr_bg_palette,1,false);
draw_background(bg_test,0,0);
pal_swap_reset();

@ GamerXP

Shouldn't have anything to do with sprite_get_UVs unless9 Copy X wants to use a background as a palette... which, yeah, this doesn't support, and I don't see a good reason to add that support.


Edited by Pixelated_Pope, 03 February 2015 - 05:20 PM.

  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#105 GamerXP

GamerXP

    GMC Member?

  • GMC Member
  • 443 posts
  • Version:GM:Studio

Posted 03 February 2015 - 07:03 PM

Ah, yeah... totally forgot what I used as shader's uniforms. My bad.


  • 1

#106 Copy X

Copy X

    GMC Member

  • GMC Member
  • 67 posts

Posted 03 February 2015 - 09:45 PM

That's fine, I'll switch to using surfaces. :) Much faster anyway! Thanks for your amazing work PP and your help XP. :)

Edit: Oh you mean use a background as a palette? Nah I was just applying the palette changes to backgrounds I mean. I'll try it and see, thank you.


Edited by Copy X, 03 February 2015 - 09:47 PM.

  • 0

#107 Yal

Yal

    Even though the GMC may be gone, our love will prevail eternally

  • Global Moderators
  • 11774 posts
  • Version:GM:Studio

Posted 27 February 2015 - 10:38 PM

Bleh, my first experience with this isn't so great. <___<

############################################################################################ 
FATAL ERROR in Fragment Shader compilation 
ShaderName: shd_pal_swapper 


C:\Users\Rosina\AppData\Local\Temp\gm_ttt_12086\gm_ttt_87095\memory(130,6): error X3511: unable to unroll loop, loop does not appear to terminate in a timely manner (54 iterations), use the [unroll(n)] attribute to force an exact higher number 


############################################################################################

I guess I'll try doing what it suggests and use [unroll].


  • 0

- The above is my personal opinion and in no way representative of Yoyogames or the GMC, except when explicitly stated -

 

Open this spoiler for my games:

Spoiler

Some useful game engines, music and other resources at affordable prices:

My collection of game resources at itch.io

 

New user? Can't draw but want to look unique? You can request a new avatar in this thread!


#108 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 27 February 2015 - 10:41 PM

Have you used other shaders?  Have you tried updating your videocard drivers?  Have you installed the latest version of DirectX?

 

This issue appears to be in the compilation of the shader, which I promise... compiles.  So that means the problem most likely exists on your machine.  Try on a different computer and see if you get the same issue.  But definitely try what I suggested above.

 

[Edit] Found this on a Risk of Rain Subreddit:

 

With the update to GameMaker: Studio and the inclusion of shaders, the game's requirements have inadvertently changed. There are various shader models which determine what the graphics card/unit is able to recognize and support. I wrote about this recently[1] , and it seems you have the same issue. I've looked up the specifications of the Radeon X1250, and it seems to only support up to Pixel Shader 2.0b. Based on what I see in the fragment/pixel shader code for the game, you'll probably need at least Pixel Shader 3.0 for it to compile on your computer.

 

Chances are that your video card doesn't support Pixel Shader 3.0 and is thus not capable of compiling the shader?  Maybe?  I honestly am not sure.


Edited by Pixelated_Pope, 27 February 2015 - 10:48 PM.

  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#109 Yal

Yal

    Even though the GMC may be gone, our love will prevail eternally

  • Global Moderators
  • 11774 posts
  • Version:GM:Studio

Posted 27 February 2015 - 10:49 PM

Whoa, that's a fast reply!

 

I've used other shaders before, so I know they work in general... this is the first one with a loop, though. GMS just threw a misc. compile error in my face when I used the [unroll] directive so I guess I can't do that under the version of GLSL ES it uses. I guess I could try getting the latest drivers and DirectX (especially the latter). Brb...


  • 0

- The above is my personal opinion and in no way representative of Yoyogames or the GMC, except when explicitly stated -

 

Open this spoiler for my games:

Spoiler

Some useful game engines, music and other resources at affordable prices:

My collection of game resources at itch.io

 

New user? Can't draw but want to look unique? You can request a new avatar in this thread!


#110 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 27 February 2015 - 10:51 PM

What sort of Video Card do you have?  We can look it up and see what sort of shaders it supports.  

 

Hopefully you can get it working, I think this shader is perfect for your art style.


  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#111 Yal

Yal

    Even though the GMC may be gone, our love will prevail eternally

  • Global Moderators
  • 11774 posts
  • Version:GM:Studio

Posted 27 February 2015 - 11:09 PM

According to the Unit Manager, I have an "ATI RADEON 9600 Series" video card. (My computer is handmade using second-hand parts so I'm not 100% sure what I have stuffed in it xD). I appear to have the latest DirectX and video card driver, as well.

 

Awww, I hoped there was an easy solution to that error... I really want to use this shader! :3

 

Is there any way I could manually unroll that loop if I can cope with a finite amount of colors? I can guarantee I won't need more than 32, and the particular image I was going to use had 19 colors.


  • 0

- The above is my personal opinion and in no way representative of Yoyogames or the GMC, except when explicitly stated -

 

Open this spoiler for my games:

Spoiler

Some useful game engines, music and other resources at affordable prices:

My collection of game resources at itch.io

 

New user? Can't draw but want to look unique? You can request a new avatar in this thread!


#112 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 27 February 2015 - 11:12 PM

There is an old version of the shader in the main post that is not nearly as "awesome" but will get the job done with a limit of 22 colors and it's not quite as easy to use as you have to set up your palettes before hand in a manager.  Here's a link.

 

And, yeah, it looks like your card does not support Shader Model 3.0.  So without a new videocard, you won't be able to use the awesome version of this shader. :(


Edited by Pixelated_Pope, 27 February 2015 - 11:13 PM.

  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#113 Yal

Yal

    Even though the GMC may be gone, our love will prevail eternally

  • Global Moderators
  • 11774 posts
  • Version:GM:Studio

Posted 27 February 2015 - 11:25 PM

Bleh, stuff needs to be more standardized <__<

OK, I'll check out the 22-color version instead. (You should probably link to that in the first post, BTW, in case other people wants it).

 

 

Thanks for the support, BTW! ^___^


  • 0

- The above is my personal opinion and in no way representative of Yoyogames or the GMC, except when explicitly stated -

 

Open this spoiler for my games:

Spoiler

Some useful game engines, music and other resources at affordable prices:

My collection of game resources at itch.io

 

New user? Can't draw but want to look unique? You can request a new avatar in this thread!


#114 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 27 February 2015 - 11:29 PM

It's there... Right under the current download link at the top of the post.

 

No problem.  If you ever do upgrade your computer, moving to the full featured one should be pretty much painless.  Let me know if you have any issues with the limited version.  It's been awhile since I've looked at it, but it should still work.


  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#115 Yal

Yal

    Even though the GMC may be gone, our love will prevail eternally

  • Global Moderators
  • 11774 posts
  • Version:GM:Studio

Posted 27 February 2015 - 11:40 PM

Mmm... I love how the comment in the frag shader reads "read the comments below for instructions" when there are no others following it. Was pretty self-explanatory, though, just copy-paste the lines and increment the numbers xD

 

 

EDIT: OK, scratch that. I gotta decrement instead...

############################################################################################
FATAL ERROR in Fragment Shader compilation
ShaderName: shd_color_swapper_22


C:\Users\Anders\AppData\Local\Temp\gm_ttt_12086\gm_ttt_75912\memory(301,4): error X5200: (Second source param) Invalid register number: 43. Max allowed for this type is 31.


############################################################################################

So now my shader looks like this...

Spoiler
I don't see where we actually set those variables to anything, so I'm kinda confused how this works. And IMO it feels like we could reuse the c# registers (or whatever those things that run out are called) so we only need one at a time, by using the palette graphic in itself as the lookup, except with tons of repeated calls instead of a loop.
 
I guess I'll downsize it to 16 colors for now and hope that's enough to get it to compile, I could probably manage the effect I want by just using two different palettes and two different shaders.

  • 0

- The above is my personal opinion and in no way representative of Yoyogames or the GMC, except when explicitly stated -

 

Open this spoiler for my games:

Spoiler

Some useful game engines, music and other resources at affordable prices:

My collection of game resources at itch.io

 

New user? Can't draw but want to look unique? You can request a new avatar in this thread!


#116 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 27 February 2015 - 11:59 PM

Yeah.  I removed the instructions because it's already been expanded to support as many colors as possible, forgot to remove the top comment, though.  You can't add anything beyond Colour21.  

 

So, even with just the 21 colors, you still get a crash?


  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#117 Yal

Yal

    Even though the GMC may be gone, our love will prevail eternally

  • Global Moderators
  • 11774 posts
  • Version:GM:Studio

Posted 28 February 2015 - 12:03 AM

Yup, seems like whatever I'm at only support 32 registers, and with 21 colors I need 42. I'll try lowering to 16. Aaand...


___________________________________________
############################################################################################
FATAL ERROR in Fragment Shader compilation
ShaderName: shd_color_swapper_22
 
C:\Users\Anders\AppData\Local\Temp\gm_ttt_12086\gm_ttt_63559\memory(205,4): error X5200: (Second source param) Invalid register number: 38. Max allowed for this type is 31.
 
############################################################################################

 

 

OK, a lower overflow thing this time, at least... so if I go down to 12 colors I should be fine.
 
 
Like I ninjaedited in my previous post:
I don't see where we actually set those variables to anything, so I'm kinda confused how this works. And IMO it feels like we could reuse the c# registers (or whatever those things that run out are called) so we only need one at a time, by using the palette graphic in itself as the lookup, except with tons of repeated calls instead of a loop.
 
I guess I'll downsize it to 16 colors for now and hope that's enough to get it to compile, I could probably manage the effect I want by just using two different palettes and two different shaders.

 

 

 

BTW, how come you use 32 in the init call if it only supports 22 colors in the example?

 

 

 

EDIT:

___________________________________________
############################################################################################
FATAL ERROR in Fragment Shader compilation
ShaderName: shd_color_swapper_22
 
C:\Users\Anders\AppData\Local\Temp\gm_ttt_12086\gm_ttt_68443\memory(228,14): error X5608: Compiled shader code uses too many arithmetic instruction slots (74). Max. allowed by the target (ps_2_0) is 64.
 
############################################################################################
 
 
Bleh, not retro enough <____<
Seems like I need to scrap 5 more lines somewhere. How many colors can I cream out of this thing...
 
 
 
EDIT2: Okay, ten colors works fine. OMG IT WORKS *__* I'll adjust the control object to use separate colors for tiles and background somehow.

  • 0

- The above is my personal opinion and in no way representative of Yoyogames or the GMC, except when explicitly stated -

 

Open this spoiler for my games:

Spoiler

Some useful game engines, music and other resources at affordable prices:

My collection of game resources at itch.io

 

New user? Can't draw but want to look unique? You can request a new avatar in this thread!


#118 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 28 February 2015 - 01:09 AM

Glad you got it working...  Sorry you had so much trouble with it, though.  It's a pretty ghetto implementation, but it works.  Hopefully you'll be able to move up to the full featured one at some point in the future.


  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#119 Yal

Yal

    Even though the GMC may be gone, our love will prevail eternally

  • Global Moderators
  • 11774 posts
  • Version:GM:Studio

Posted 28 February 2015 - 01:50 AM

Mmm, it's so delicious-looking *___*

Turns out the screen thing was just my PC running low on RAM... closed tons of Chrome tabs and stuff, and it runs like it did before the shader. And I had some issues with mixing up tile layer depth - on my part - but finally, I got it to flash properly! Oooh, the sonic 2 vibes :3

 

10 colors isn't much, but if I split stuff up into different sprites I should manage. Heck, most of the time I only use 3 or 4 shades per color anyway - the Casino Night Zone background is an edge case. Pretty slick to use this for animated tiles, anyway, motivates me using the built-in background system and stuff x3

 

Now I'm going on a +1 spree as thanks :3


  • 0

- The above is my personal opinion and in no way representative of Yoyogames or the GMC, except when explicitly stated -

 

Open this spoiler for my games:

Spoiler

Some useful game engines, music and other resources at affordable prices:

My collection of game resources at itch.io

 

New user? Can't draw but want to look unique? You can request a new avatar in this thread!


#120 GamerXP

GamerXP

    GMC Member?

  • GMC Member
  • 443 posts
  • Version:GM:Studio

Posted 28 February 2015 - 05:43 AM

It wrote 54 loop iterations in first error message. Did you use 54 palette color? Or it was just uniforms did not properly been sent to the shader I wonder...

 

What about trying using HLSL for shaders? There, an HLSL version of palette swap shader. Just replace current one with this and change its type to HLSL:

VERTEX

struct VS_INPUT { // Input to VS
    float4 Position : POSITION;
    float4 Color    : COLOR0;
    float2 Texcoord : TEXCOORD0;
};

struct VS_OUTPUT { // Output to PS from VS
    float4 Position : SV_POSITION;
    float4 Color    : COLOR0;
    float2 Texcoord : TEXCOORD0;
};

VS_OUTPUT main(VS_INPUT IN)
{
    VS_OUTPUT OUT;
    OUT.Position = mul(gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION], IN.Position);
    OUT.Color = IN.Color;
    OUT.Texcoord = IN.Texcoord;
    return OUT;
}

FRAGMENT

struct PS_INPUT { // Input from VS to PS
    float4 Color    : COLOR0;
    float2 Texcoord : TEXCOORD0;
};

uniform sampler2D palette_texture;
uniform float2 texel_size;
uniform float4 palette_UVs;
uniform float palette_index;

float4 main(PS_INPUT IN): SV_TARGET
{
    float4 source = tex2D( gm_BaseTexture, IN.Texcoord );
    
    [unroll(128)]
    for(float i = palette_UVs.y; i < palette_UVs.w; i+=texel_size.y )
    {
        if (distance(source, tex2D(palette_texture, float2(palette_UVs.x, i))) <= 0.004)
        {
            float palette_V = palette_UVs.x + texel_size.x * palette_index;
            source = tex2D(palette_texture, float2(palette_V, i));
            break;
        }
    }
    
    return source * IN.Color;
} 

If it do not compile - try changing number inside [unroll] atribute. It does not support default GLSL's 255 unroll for some reason, si I placed 128 there for now. Maybe you should try 53 since it fails around that part for you.


Edited by GamerXP, 28 February 2015 - 05:45 AM.

  • 2

#121 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 28 February 2015 - 05:09 PM

GamerXP to the rescue again.  Thanks!  I'll do some testing with this and include this in the download package.


  • 0
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#122 RENGAC

RENGAC

    GMC Member

  • GMC Member
  • 50 posts
  • Version:GM:Studio

Posted 06 March 2015 - 01:42 PM

Wow! This is really cool!


  • 0

bannerCSB2_SMALL.jpg


#123 Yal

Yal

    Even though the GMC may be gone, our love will prevail eternally

  • Global Moderators
  • 11774 posts
  • Version:GM:Studio

Posted 21 March 2015 - 08:27 PM

If it do not compile - try changing number inside [unroll] atribute. It does not support default GLSL's 255 unroll for some reason, si I placed 128 there for now. Maybe you should try 53 since it fails around that part for you. 

Might need to do that. When trying to compile at HLSL9 (I figured that would be more compatible than HLSL11) I got this error below. I will try at 53 next, and it that fails, keep going lower... the GLSL shader works pretty fine for me, but just being able to swap 10 colors per sprite is a bit low for my needs so I'm investigating all my options.

 

Thanks so much for making an awesome shader, anyway :)

___________________________________________
############################################################################################
FATAL ERROR in Fragment Shader compilation
ShaderName: shd_color_swapper_hlsl

C:\Users\Rosina\AppData\Local\Temp\gm_ttt_7405\gm_ttt_77962\memory(29,20): error X5426: Shader uses texture addressing operations in a dependency chain that is too complex for the target shader model (ps_2_0) to handle.

############################################################################################

EDIT: Compiled fine at HLSL11 at 32 colors ::lmao::

EDIT2: Scratch that, I'm getting a ton of Shader did not compile correctly. Crap. debug readouts....


  • 0

- The above is my personal opinion and in no way representative of Yoyogames or the GMC, except when explicitly stated -

 

Open this spoiler for my games:

Spoiler

Some useful game engines, music and other resources at affordable prices:

My collection of game resources at itch.io

 

New user? Can't draw but want to look unique? You can request a new avatar in this thread!


#124 GamerXP

GamerXP

    GMC Member?

  • GMC Member
  • 443 posts
  • Version:GM:Studio

Posted 22 March 2015 - 05:53 AM

I read some forums about this error... looks like they say you can read texture only 5 times with PS2.0. Totally not enough for palette swap shader. Well,if you convert all your sprites to indexes images first, and then use simplier palette swap shader - it will be fine. But since you can't replace original sprites on the texture page - it will totally break possibility of using vertex batches. But still,,, converting to indexes still require to read palette in the shader, and you will probably get same error message as before... you probably need to replace colors one-by-one then. So, basically:

1. Create a surface with the sprite you need.

2. Use shader to replace color on that surface to index (Like 1st color in a palette will have color (0,0,0), 2nd - (1,0,0), etc)

3. Create a new sprite from that surface, and replace original sprite with it.

4. Draw this sprite with a palette, where that index value will be offset in palette image, so you won't need any loops at all.

 

Do you want such an annoying workaround?


  • 0

#125 Yal

Yal

    Even though the GMC may be gone, our love will prevail eternally

  • Global Moderators
  • 11774 posts
  • Version:GM:Studio

Posted 22 March 2015 - 07:16 PM

Do you want such an annoying workaround?

 

No thanks, please... I think I'll cope with 10 colors somehow. (Using multiple sprites for each object seems like an easier workaround method).


  • 0

- The above is my personal opinion and in no way representative of Yoyogames or the GMC, except when explicitly stated -

 

Open this spoiler for my games:

Spoiler

Some useful game engines, music and other resources at affordable prices:

My collection of game resources at itch.io

 

New user? Can't draw but want to look unique? You can request a new avatar in this thread!


#126 Fra÷t

Fra÷t

    GMC Member

  • GMC Member
  • 55 posts
  • Version:GM:Studio

Posted 24 March 2015 - 05:14 PM

Hey. I downloaded your shader a while ago but recently decide to use it in my game so I opened the project to see how it is used. I noticed it requires A LOT of processing power. My MacBook's fan start to get noisy (compared to how silent it is) and she gets way too hot.


  • 0

#127 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 24 March 2015 - 05:22 PM

Did you grab the latest version?  If you downloaded it several months ago, performance has been VASTLY improved.  There should be little to no real impact on performance since shaders are so fast (and most of the work I used to be doing with data structures outside of the shader itself has been eliminated).  Make sure you are on the latest version and let me know if it's the latest version that is giving you performance issues.  I also haven't done much testing on macs, so that may be a different issue, but I can run the test app at over 300fps on my mid-range laptop.  I mean, it's a shader so it IS utilizing your video card.  Do you notice this performance hit with other shaders you've tried?  


  • 0
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#128 Fra÷t

Fra÷t

    GMC Member

  • GMC Member
  • 55 posts
  • Version:GM:Studio

Posted 30 March 2015 - 03:06 AM

I think I did download the latest version. I will double-check though.


  • 0

#129 Fra÷t

Fra÷t

    GMC Member

  • GMC Member
  • 55 posts
  • Version:GM:Studio

Posted 30 March 2015 - 03:58 AM

Yup, it was the latest version. My computer gets as hot as 17 suns.

Take a look at the screen scrop: https://www.dropbox....de/bad.png?dl=0

bad.png?dl=0


  • 0

#130 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 30 March 2015 - 04:30 AM

OOOOOOH.  Ha.  Sorry, I'm an idiot.  Yes, of course that will happen.  Did you notice the FPS counter at the top?  The room speed for the demo project is 9999.  So it is literally going as fast as your computer will let it.  So, yeah... very intense.

 

Try this demo:

https://www.dropbox.... 60fps.exe?dl=0

I've limited the room speed to 60, so it should be a much better indication of the impact you can actually expect on your system.

 

Hopefully it doesn't heat your computer up quite as bad.


  • 0
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#131 Fra÷t

Fra÷t

    GMC Member

  • GMC Member
  • 55 posts
  • Version:GM:Studio

Posted 30 March 2015 - 08:13 PM

The FPS remains good, at 60. But my Mac gets hot. I'll download that demo of yours.


  • 0

#132 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 30 March 2015 - 08:32 PM

If that doesn't work, I don't know what to tell you.  It shouldn't be terribly processor intensive.  Here's what it does to me: 

 

http://gyazo.com/8cf...a9e1ede5c7256bb

 

It just sort of bounces between 3 and 6 percent of my CPU.  What sort of specs does your machine have?


  • 0
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#133 Fra÷t

Fra÷t

    GMC Member

  • GMC Member
  • 55 posts
  • Version:GM:Studio

Posted 31 March 2015 - 08:45 PM

My MacBook has a 2.4 GHz Core 2 Duo. It's not the fastest one, but that shader shouldn't have that much impact. I think I'd use this shader when I have a more powerful machine. It's a shame, I need a powerful computer to achieve this simple effect.


  • 0

#134 GamerXP

GamerXP

    GMC Member?

  • GMC Member
  • 443 posts
  • Version:GM:Studio

Posted 31 March 2015 - 08:49 PM

Actually, I think it's weird it takes so much CPU time. You know, shader is executed on GPU, so it should not be visible in the task manager. Better say what GPU you have.


  • 0

#135 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 31 March 2015 - 10:53 PM

Macbook?  Running Windows?  I think there are other issues at play here.  

 

As GamerXP says, shaders run almost exclusively on the GPU.  The only thing my system does is pass a few variables to the shader and in some "extreme" cases builds a custom palette in a surface.  All pretty basic stuff.  You are the first to say anything about performance issues, so I'm inclined to assume it's something on your machine.  I just don't know what else we can do to troubleshoot this.  


  • 0
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#136 Fra÷t

Fra÷t

    GMC Member

  • GMC Member
  • 55 posts
  • Version:GM:Studio

Posted 02 April 2015 - 09:30 PM

I can run Mirror's Edge at 45 - 50 FPS and my MacBook gets hot, soothing hot, warm... not as intense as many suns; I can run Portal 2 at medium at steady 40 fps at the same temperature and many other 3D games. I don't get why this shader makes it boil.

 

I think I'll have to buy a new computer but I don't really like Windows machines unless I am playing, coding or composing music, for all the other activities there's Mac. Sigh... a small factor PC should come in handy for these shaders, although I'd like my game to run even on not very powerful machines.


Edited by Fra÷t, 02 April 2015 - 09:34 PM.

  • 0

#137 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 02 April 2015 - 10:19 PM

Again.  I encourage you to try a completely different, low end laptop.  It REALLY shouldn't be processor intensive AT ALL.  Like 0 processor impact beyond what any game maker game would normally take.  The only increased "requirement" is that the computer needs a shader model 3.0 compatible video card for the effect (and there really isn't much we can do about that).  

 

I just pulled my old laptop out of hibernation to try it.  This computer is 4 years old, and wasn't even top of the line when I bought it.  

 

Unlimited Frame Rate: yeah, 20% of my CPU.  Didn't "heat up" but, man... I was getting like 1500 FPS!!  So, yeah, of course it was pegging one of my cores.

Limited to 60FPS: Completely negligible CPU impact.  Like... .3% CPU usage.  I am 99% sure this is an isolated, low occurrence issue with your pc and few others like yours.

 

In fact.  I'm going to go see if I can get my buddies over at /r/gamemaker to test it out and get a bit of a sampling of different computers and see how many of them run into a similar problem.


  • 0
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#138 Fra÷t

Fra÷t

    GMC Member

  • GMC Member
  • 55 posts
  • Version:GM:Studio

Posted 03 April 2015 - 04:52 PM

Thank you for your time.


  • 0

#139 VegaBiggs

VegaBiggs

    GMC Member

  • New Member
  • 14 posts
  • Version:GM:Studio

Posted 05 April 2015 - 02:06 PM

Pixelated_Pope, you are the most awsome person in the world ! Thank you.
  • 0

#140 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 05 April 2015 - 05:47 PM

LoL.  Thanks, VegaBiggs.  Hopefully you can make something awesome using this!

 

@Fraöt

 

It's a small survey, but here are some performance stats from volunteers on reddit.com/r/gamemaker.

 

https://docs.google....dit?usp=sharing

 

As you can see, those using the UNCAPPED demo saw a significant impact on their CPU, as expected.  But when running it capped at 60FPS, there was no performance issues what-so-ever.  I'm not convinced you were actually running the 60FPS locked demo.  If the window title bar has a number other than 59/60, you are running the wrong version, and yes, CPU impact is going to be stupid bad.  But you would never use this like that in an actual project, as there is no reason to run your game faster than 60fps (or 144 in extreme situations if you want to support 144hz monitors).   


  • 0
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#141 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 06 April 2015 - 04:03 PM

New Update!!

 

Change Log for existing users (4-6-2015):
Tile support is now in!  Use pal_swap_set_tiles(), preferably in the step event, to swap the range of tiles with the given palette.  You can do this for as many tile ranges as you need to swap.  Tile ranges should be depth ranges that only include tiles, with no objects moving around in the layers in between.  So if you have a series of "background" tile layers and a series of "forground" tile layers, you would need to handle both of those as two separate calls with pal_swap_set_tiles, even if they all use the same palette.  I know this has been an oft request featured, so I'm happy to finally have a solution.

 

 

A new tool is now available for creating your palettes. 
Download Link

 

 

You no longer need to pass the shader name as an argument for pal_swap_set().  You can choose to not update that particular script and everything will still work fine, but I would recommend it if you don't have TOO many pal_swap_set() calls in your project.  Now in pal_swap_init() I store a global variable of the shader index that is used in all future calls to the shader.

 

 

Finally, I have packaged everything up and thrown it up on the marketplace for a few bucks.  You are free to download it from this thread and use it in your project (commercial or private) with no credit required.  But, if you like what I do, and want to help support continued development, consider purchasing from the marketplace.  
YoYo Marketplace Link

 

Thanks for giving the Retro Palette Swapper a shot, and I hope you make something awesome with it!


  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#142 GamerXP

GamerXP

    GMC Member?

  • GMC Member
  • 443 posts
  • Version:GM:Studio

Posted 06 April 2015 - 04:16 PM

Tch... wanted to make a "Palette Control" marketplace asset myself, containing similiar shader as well. Looks like you did it first. Well, I planned on including not only palette swap shaders, but also dithering, indexing and such stufff as well, but still...

 

PS. That editor looks useful. I think I want something like this later for ingame palette editing.


  • 0

#143 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 06 April 2015 - 07:20 PM

Hey, man. Free market! Make your market place asset. Not like there is anything I can do about it. Hell, my marketplace app has YOUR code in it, so you have every right to demand I take mine down as long as it contains your code. So don't feel bad about posting a similar asset.

Also, if you would like the source for my editor, I'm happy to share it. Nothing too complicated in there, really.
  • 0
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#144 Carnivac

Carnivac

    The Hunter

  • GMC Member
  • 3300 posts
  • Version:GM:Studio

Posted 07 April 2015 - 11:52 AM

eh what?  It's been a while since I looked at this topic cos things were going fine with the last version I had but it's changed a lot since then?  Even does does tiles now?  I'm gonna have to download and have a look.


  • 0

#145 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 07 April 2015 - 03:50 PM

eh what?  It's been a while since I looked at this topic cos things were going fine with the last version I had but it's changed a lot since then?  Even does does tiles now?  I'm gonna have to download and have a look.

 

Well... technically it's always been capable of doing tiles, using this method:

http://gmc.yoyogames...opic=659935&hl=

I just didn't know that work around worked, and there is now a script and two objects that automate the process for ease of use.

 

But, yeah, definitely take a look, especially at the palette builder tool.  I'd be interested to see if you have any feedback on it.


  • 1
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#146 Carnivac

Carnivac

    The Hunter

  • GMC Member
  • 3300 posts
  • Version:GM:Studio

Posted 07 April 2015 - 05:03 PM

Tried the new demo.  Seems cool.  Slows down a bit with the tiles (28fps) but that could be the size of the demo room?  I mean does it change colours of all tiles in room including those not yet in view?  

 

I had a go of the palette builder too and it's neat but I'm much faster with my own palette index methods.  It's cool for those who haven't as much experience with graphics programs though.  Very well made. :)

 

Hm, looking at the main swapper shader, it sure seems a lot shorter than the old one. :P


  • 0

#147 GamerXP

GamerXP

    GMC Member?

  • GMC Member
  • 443 posts
  • Version:GM:Studio

Posted 07 April 2015 - 05:27 PM

It should not slow down things I think. If culling it turned on at least. GPU should drop vertexes outside of view automatically. Also, shaders are not executed for pixels outside of the view anyway.

 

But yeah, this palette swap shader sure if faster, than original one, but using actual indexing is still much faster. But using indexing with GM is pretty though cause you need to make some complex workarounds to still be able to support texture pages for performance.


  • 0

#148 Carnivac

Carnivac

    The Hunter

  • GMC Member
  • 3300 posts
  • Version:GM:Studio

Posted 08 April 2015 - 02:54 PM

Hm, I'm finding the newer swapper quite confusing to replace the old one with particularly in regards to the overrides.  I may just stick with the older one for now as it does a lot of what I wanted.   Going to try again though.


Edited by Carnivac, 08 April 2015 - 03:18 PM.

  • 0

#149 Pixelated_Pope

Pixelated_Pope

    GMC Member

  • GMC Member
  • 338 posts

Posted 08 April 2015 - 03:55 PM

Hey, no pressure to move to the new one if you don't get anything out of it.  Stick with what works for your project.

 

Although, I guess I should take some time to explain custom palettes here, as they are insanely powerful, but can be a bit confusing.

 

This is Link from Link to the Past with his palette sprite and his silly pink hair.  

 

cyCWsBZ.png

 

Although in my Zelda project, you'll usually see him like this with blonde hair.  He's using Palette 1 here.

 

iB2jqiU.png

 

And of course, later in the game, he would look like this, using palette 7,8, or 9 depending on his sword.

 

001BNJ2.png

 

But what if I wanted to change the color of his outline without modifying my palette sprite?

 

First, I would create a surface.

 

kxTM3Vh.png

 

On that surface I would use

pal_swap_draw_palette(spr_link_pal,0,0,0)

 to draw link's base palette to the left column of the new surface.  Just like a normal palette sprite should look.

 

eItUtpj.png

 

I would then use this again, to draw his current palette.  

pal_swap_draw_palette(spr_link_pal,current_palette,1,0).  

AAoj47x.png

 

Now, to change the outline, I would simply draw over the color on the surface.  I want to change the color in the 0 position, so I would do this.

draw_set_color(c_red)
draw_point(1,0);

To get this:

 

CzURbX9.png

 

But I'm not using the palette yet.  So now, in my code where I draw link, I have a flag that says "Hey, I'm overriding a color!  Use the override surface instead of the palette sprite, and use palette 1 instead of whatever his current palette actually is"!

 

That code might look something like this:

if(pal_override)
    pal_swap_set(override_surface,1,true);
else
    pal_swap_set(spr_link_pal,current_palette,false);
draw_self();
pal_swap_reset();

And this would be the result:

 

CVjKPbz.png

 

I could do anything when drawing that second palette to the surface, including drawing it to the surface using ANOTHER shader such as grayscale, sepia, or infrared.  

 

If I wanted to "fade" from my current palette to the custom palette, I would make the custom palette surface 3 pixels wide, duplicate the current palette into column 2 and 3, and then gradually change the palette value from 1 to 2.  This is what it would look like half way between 1 and 2:

 

eXCpS9O.png

 

Hopefully that makes at least a little sense.  Essentially you stop using your original palette sprite all together, but use columns from it to build a new palette sprite on the fly on a surface.  Then use that surface to palette swap with rather than your original sprite.  Does that help at all?  Or did I just confuse everyone more?


  • 2
 

D3svqFp.pngen_generic_rgb_wo_60.png

  Currently in a "beta" state.  Working on the new graphic overhaul right now!
 

#150 Yal

Yal

    Even though the GMC may be gone, our love will prevail eternally

  • Global Moderators
  • 11774 posts
  • Version:GM:Studio

Posted 09 April 2015 - 03:06 PM

I've got the unlimited palette swap version to compile on my laptop, so it's confirmed that the issues I was experiencing before was because of outdated equipment. :3


  • 0

- The above is my personal opinion and in no way representative of Yoyogames or the GMC, except when explicitly stated -

 

Open this spoiler for my games:

Spoiler

Some useful game engines, music and other resources at affordable prices:

My collection of game resources at itch.io

 

New user? Can't draw but want to look unique? You can request a new avatar in this thread!






Also tagged with one or more of these keywords: shader, gm:studio