J
James Newnorth
Guest
Hi, I'm trying to use 2 textures in a shader, and it keeps rendering the same base texture even when I'm adressing the secondary texture.
This is in my Draw-event:
This is in my vsh:
This is in my fsh:
This is in my Draw-event:
Code:
shader_set(sh_terrain);
var _uniform_id = shader_get_sampler_index(sh_terrain, "u_terrain_texture");
var _texture_id = sprite_get_texture(spr_terrain, 0);
texture_set_stage(_uniform_id, _texture_id);
draw_sprite_ext(spr_terrain_mask, 0, self.x, self.y, 4, 4, 0, c_white, 1);
shader_reset();
Code:
//
// 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_texture_coordinate;
varying vec4 v_vColour;
void main() {
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * vec4(in_Position.x, in_Position.y, in_Position.z, 1.0);
v_texture_coordinate = in_TextureCoord;
v_vColour = in_Colour;
}
Code:
varying vec2 v_texture_coordinate;
varying vec4 v_vColour;
uniform sampler2D u_terrain_texture;
void main() {
gl_FragColor = texture2D(u_terrain_texture, v_texture_coordinate);
}