I am combining two shaders to create one that can draw a repeating textured vertex buffer with a colour fade. It seems that it's currently not drawing anything.
Shader:
Use:
Doing this causes the shape drawn to be invisible. Not using the shader or using other shaders works as always.
I'm no good at shaders so I'm sure someone can spot something I'm messing up.
Shader:
Code:
//
// Simple passthrough vertex shader
//
attribute vec3 in_Position;
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_Textcoord0;
attribute vec4 in_Textcoord1;
varying vec2 v_vTexcoord;
varying vec4 v_vRepeat;
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_Textcoord0;
v_vRepeat = in_Textcoord1;
}
Code:
//
// Simple passthrough fragment shader
//
uniform vec4 f_colour;
varying vec2 v_vTexcoord;
varying vec4 v_vRepeat;
varying vec4 v_vColour;
void main()
{
vec2 UV = v_vTexcoord - floor( v_vTexcoord / v_vRepeat.xy - v_vRepeat.zw ) * v_vRepeat.xy;
vec4 col = texture2D( gm_BaseTexture, UV );
col.rgb = mix(col.rgb, f_colour.rgb, f_colour.a);
gl_FragColor = v_vColour * col;
}
Code:
//create
FadeColour = shader_get_uniform(sh_repeat_textures_fade, "f_colour");
Code:
//just before drawin the shape
Colour = c_white;
fade_amount = 1; //these can be anything and it's still invisible
shader_set(sh_repeat_textures_fade);
shader_set_uniform_f(FadeColour, color_get_red(Colour)/225, color_get_green(Colour)/225, color_get_blue(Colour)/225, fade_amount); // 1,1,1 for white
//then I submit the vertex buffer and reset the shader
I'm no good at shaders so I'm sure someone can spot something I'm messing up.
Last edited: