E
E.M.I
Guest
[RESOLVED] Hi! I'm trying to create a day-night cycle for my game. I plan to do this by using a shader to change the color of a transparent sprite that stretches across the whole room. Though for now, I'm only trying to pass in a uniform value that I'll use for the color. My code is:
In the Create event of my weather object:
In the Draw event of my weather object:
In my fragment weather shader (vertex shader is the default):
I've tried changing it inside the shader and it works, so the issue is definitely the uniform vec3 spriteColor not being changed. Am I doing something wrong? Still very new to shaders in GMS2 so maybe it's a dumb mistake. Thanks a lot for the help in advance!
In the Create event of my weather object:
Code:
spriteBlue = 255.0;
Code:
spriteBlue -= 0.1;
shaderColor = shader_get_uniform(shd_weather, "spriteColor");
shader_set_uniform_f(shaderColor, 0, 0, 255.0);
shader_set(shd_weather);
draw_sprite_ext(spr_weather_overlay, -1, x, y, 1, 1, 0, c_white, 0.05);
shader_reset();
Code:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec3 spriteColor;
void main()
{
vec4 originalColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
gl_FragColor = vec4(spriteColor.r, spriteColor.g, spriteColor.b, originalColor.a);
}
Last edited by a moderator: