• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Shaders lose transparency when I use game_reset

P

PepticPaladin

Guest
I made a shader for my character so I could swap its palette, and it works fine when I first run the game, but when I use game_restart, the transparent background turns black.

Run from Gamemaker:
before.PNG

game_restart:
after.PNG

Shader fragment code:
Code:
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;

// get palette as texture
uniform sampler2D Palette;

// color offset index
uniform float Offset;



void main()
{
    vec4 ref = texture2D(gm_BaseTexture, v_vTexcoord);
    vec2 uv_coord = vec2(ref.r, Offset);
    vec4 new_color = texture2D(Palette,uv_coord);   
    gl_FragColor = new_color; 
}
Player draw event:
Code:
shader_set(p_shPaletteSwap);
texture_set_stage(paletteSwapSampler,tex_palette);
shader_set_uniform_f(v_offset,v_normal);
draw_self();
shader_reset();
room_restart works fine.
I'm not sure what's happening.
 

Bart

WiseBart
Does anything change if you add
Code:
gl_FragColor.a = 1.0;
to the fragment shader?

Or are there perhaps any gpu state changes that aren't executed when you restart the game?
 
Top