GameMaker Can't Draw Circles With Shader Running

mar_cuz

Member
Hi Guys,

I have an issue where game maker can't draw circles when I'm running a shader. it is a simple colour shader.

VSH shader code
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_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;
}
FSH shader code
Code:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec3 newColour;

void main()
{
    vec4 colour = texture2D( gm_BaseTexture, v_vTexcoord );
    colour.rgb *= newColour;
    gl_FragColor = v_vColour * colour;
}
without the shader running, the circles are drawn perfectly fine, but when I add the shader the circles are not drawn. Also, I changed the circle to a rectangle and the rectangle was drawn. is this normal?

please help.
 
is anything drawn when trying to draw the circles?
Y
Also, your shader seems to make the v_vColour redundant, since they both do the same thing, except v_vColour also has an alpha component. You have the option of premultipyling the values of v_vColour.rgb with colour.rgb in GML.
 

mar_cuz

Member
is anything drawn when trying to draw the circles?
Y
Also, your shader seems to make the v_vColour redundant, since they both do the same thing, except v_vColour also has an alpha component. You have the option of premultipyling the values of v_vColour.rgb with colour.rgb in GML.
Nothing is drawn when trying to draw the circles. And when I turn off the shader, and that is the only change, the circles are drawn
 
I think you can report this as a bug. I tested this like so:

Used a copy of your shader code.

Test-objects create event:
Code:
rx = 100;
ry = 50;
shader = shd_primitive_coloured;
u_newColour = shader_get_uniform(shader, "newColour");
newColour[0] = 1;
newColour[1] = 0.5;
newColour[2] = 0.2;

Test-objects draw gui event:
Code:
shader_set(shader);
shader_set_uniform_f_array(u_newColour, newColour);
draw_ellipse(x - rx, y - ry, x + rx, y + ry, false);
draw_ellipse_colour(x - rx, y + ry, x + rx, y + 3*ry, c_aqua, c_white, false);
draw_rectangle(x + rx, y - ry, x + 3*rx, y + ry, false);
draw_rectangle_colour(x + rx, y + ry, x + 3*rx, y + 3*ry, c_red, c_yellow, c_lime, c_aqua, false);
shader_reset();

Tested both in GM:S 1.4 and GMS 2.


This is the result in GM:S 1.4:
draw_elipse_shader_bug_gms1.jpg

And this is the result in GMS 2:
draw_elipse_shader_bug_gms2.jpg
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
I'm pretty sure this is NOT a bug. The draw_*shape* functions are pretty much deprecated at this point as they use a completely different draw pipeline to the rest of the draw functions which is why they are not resolution dependent and why they "break" custom shaders. They only really exist for beginners to use to quickly make buttons and do basic stuff... By all means, file a bug report, if only to suggest that the manual gets updated to include a message saying that these functions won't work with shaders. I would also say that if you are using these functions for anything, then you should maybe consider an alternative.
 
Top