Pages: 1
  Print  
Author Topic: Palette Unlimited Shader doesn't work in LGM(Suggestion)  (Read 10208 times)
Offline (Unknown gender) Shadowblitz16
Posted on: January 29, 2016, 10:23:47 pm
Member
Joined: Jan 2016
Posts: 6

View Profile
Can someone update this extension for LGM
its a palette Shader for gms and is really nice
it currently throws errors
« Last Edit: January 29, 2016, 10:35:24 pm by Shadowblitz16 » Logged
Offline (Unknown gender) TheExDeus
Reply #1 Posted on: February 01, 2016, 06:02:26 am

Developer
Joined: Apr 2008
Posts: 1860

View Profile
I ported it, but you will need the newest ENIGMA (which can only be got trough Git). Things that needed to be changed or fixed:
1) We don't have argument_count variable in scripts, and there is no easy way to support it.
2) We don't support argument array (argument[0] instead of normally used argument0) or at least I don't think we do. It didn't trow an error, but it seemed to return wrong values.
3) I added sprite_get_uvs() which we didn't have. (https://github.com/enigma-dev/enigma-dev/commit/1924f0f1a1fb119837cb6bc5dc3d416a3d5d13ed)
4) I fixed texture_get_texel_width and texture_get_texel_height which didn't return texel size but instead texture size in pixels. (https://github.com/enigma-dev/enigma-dev/commit/81980dcf3782bb3e0ee66514ef000ee6f1a52d35)
5) I replaced window_set_title with room_current because of a conflict right now. We try to fix it here: https://github.com/enigma-dev/enigma-dev/issues/163
6) When drawing points and lines in surfaces we have 1 pixel offset compared to GM, so I had to change a few lines in the example.
7) We do texture binding in shaders differently than GM. GM gets "stage" id trough shader_get_sampler_index, but in our case it gets the uniform variable index (it's the same as using shader_get_uniform). Instead we allow any stage to be set to any sampler, so it is possible to have one code work with several shaders. So in GM code is like this:
Code: (edl) [Select]
Pal_Texture = shader_get_sampler_index(shr_shader, "samplerID");
texture_set_stage(Pal_Texture, tex);
But in ENIGMA it must be this:
Code: (edl) [Select]
Pal_Texture = shader_get_sampler_index(shr_shader, "samplerID");
texture_set_stage(1, tex); //Bind to stage 1
shader_set_uniform_i(Pal_Texture, 1); //Use stage 1 in shader

You can download the EGM file here: https://www.dropbox.com/s/ubsjocf3wzrg33s/Palette%20Swap%20Unlimited.project.egm?dl=0
Every example in there works - basic swapping, gradual swapping (linear interpolation), outline, full fade, desaturate and even tiles. Shaders didn't need to be changed in any way (although I slightly did change one of them to be more like GL3).

Of course this example will only work in GL3 graphics system.
Logged
Offline (Unknown gender) Shadowblitz16
Reply #2 Posted on: February 01, 2016, 02:41:35 pm
Member
Joined: Jan 2016
Posts: 6

View Profile
:D thanks so much!
Logged
Pages: 1
  Print