Okay let's see. I have a room with one object in it, and the object is supposed to draw the view. For some reason it shows up on the layer list garbled, like this.
https://imgur.com/a/NG4p9WQ
Not sure if it is related.
My shader uses two uniforms which I get like this in the object's creation code:
dungeon_alpha = shader_get_uniform(shd_dungeon, "dungeon_alpha")
dungeon_uv = shader_get_uniform(shd_dungeon, "dungeon_uv")
So in the object's draw function I draw a bunch of pseudo-3d tiles, like for a first-person retro dungeon. I was using draw_sprite_pos, and I switched to using vertex buffers thinking that draw_sprite_pos would not work with shaders.
This is how I call it with draw_sprite_pos:
shader_set( shd_dungeon );
shader_set_uniform_f(dungeon_uv,argument0.uv_left, argument0.uv_right)
shader_set_uniform_f(dungeon_alpha,argument1)
draw_sprite_pos(argument0.sprite_index,0, argument0.x1,argument0.y1,argument0.x2,argument0.y2,argument0.x3,argument0.y3,argument0.x4,argument0.y4,argument1)
shader_reset()
And this is how I do it with shaders:
argument0.x1 = argument1
argument0.y1 = argument2
argument0.x2 = argument3
argument0.y2 = argument4
argument0.x3 = argument5
argument0.y3 = argument6
argument0.x4 = argument7
argument0.y4 = argument8
argument0.vbuff = vertex_create_buffer();
vertex_begin(argument0.vbuff, argument0.format);
// triangle 1
vertex_position(argument0.vbuff, argument0.x1,argument0.y1);
vertex_texcoord(argument0.vbuff, argument0.uv_left, argument0.uv_top);
vertex_color(argument0.vbuff, c_white, 1);
vertex_position(argument0.vbuff, argument0.x2,argument0.y2);
vertex_texcoord(argument0.vbuff, argument0.uv_right, argument0.uv_top);
vertex_color(argument0.vbuff, c_white, 1);
vertex_position(argument0.vbuff, argument0.x4,argument0.y4);
vertex_texcoord(argument0.vbuff, argument0.uv_left, argument0.uv_bottom);
vertex_color(argument0.vbuff, c_white, 1);
// triangle 2
vertex_position(argument0.vbuff, argument0.x2,argument0.y2);
vertex_texcoord(argument0.vbuff, argument0.uv_right, argument0.uv_top);
vertex_color(argument0.vbuff, c_white, 1);
vertex_position(argument0.vbuff, argument0.x3,argument0.y3);
vertex_texcoord(argument0.vbuff, argument0.uv_right, argument0.uv_bottom);
vertex_color(argument0.vbuff, c_white, 1);
vertex_position(argument0.vbuff,argument0.x4,argument0.y4);
vertex_texcoord(argument0.vbuff, argument0.uv_left, argument0.uv_bottom);
vertex_color(argument0.vbuff, c_white, 1);
vertex_end(argument0.vbuff)
shader_set( shd_dungeon );
shader_set_uniform_f(dungeon_uv,argument0.uv_left, argument0.uv_right)
shader_set_uniform_f(dungeon_alpha,argument1)
vertex_submit(argument0.vbuff, pr_trianglelist, argument0.tex);
shader_reset()
The graphics show up the same for both of these methods -- they show up as if I wasn't using a shader.
Here's my shader. Just to try to get it working I am just returning c_white for now. It doesn't do it. It just acts like it is not using the shader at all.
// vertex shader =============================================================
attribute vec2 in_Position;
attribute vec2 in_TextureCoord;
attribute vec4 in_Colour;
varying vec2 v_vTexcoord;
void main() {
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, 0.0, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_vTexcoord = in_TextureCoord;
}
// fragment shader =============================================================
varying vec2 v_vTexcoord;
//varying vec4 v_vColour;
uniform vec2 dungeon_alpha;
uniform vec2 dungeon_uv;
void main() {
float r = (v_vTexcoord.x - dungeon_uv[0]) / (dungeon_uv[1] - dungeon_uv[0]);
float dim = dungeon_alpha;//mix(dungeon_alphas[0],dungeon_alphas[1],r);
gl_FragColor = vec4(1.0,1.0,1.0,1.0); // texture2D( gm_BaseTexture, v_vTexcoord )*0.25; // commented out just to see if shader is even being called - it is not
}
Any ideas?