Hello,
I have found a shader "sh_fade" to change the color of a sprite with a fade. Currently, this shader make a fade with white color but i dont find where i can change the color for an other color (white to blue for example)
Can you help me?
Here
Thanks!
I have found a shader "sh_fade" to change the color of a sprite with a fade. Currently, this shader make a fade with white color but i dont find where i can change the color for an other color (white to blue for example)
Can you help me?
Here
Code:
Vertex:
//
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}
Fragment:
uniform vec4 f_colour;
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 col = texture2D( gm_BaseTexture, v_vTexcoord );
col.rgb = mix(col.rgb, f_colour.rgb, f_colour.a);
gl_FragColor = v_vColour * col;
}
Code:
Create Event:
fade = 1;
fade_colour = shader_get_uniform(sh_fade, "f_colour");
Step event:
if fade > 0 { fade -= 0.07; }
Draw Event:
shader_set(sh_fade);
shader_set_uniform_f(fade_colour, 1, 1, 1, fade); // 1,1,1 for white
draw_self();
shader_reset();