• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED Drawing a Circle with GLSL shader

S

Sakurah

Guest
Hello all,

I'm trying to draw a circle within my shader but I'm unable to actually get it to draw as expected. It should just be a red circle nothing special.
Runner_QWA1sYm005.png

Even trying to normalize the coords, still doesn't work for me:

Runner_AEmQJpksOV.png

Any thoughts on the cause for this?

Also, how can I "debug" GLSL shaders, as from what I've seen so far the `v_vTexcoord` is giving me some incorrect values and I'd like to actually see what's being passed on.

Regards,
Sakurah
 
S

Sakurah

Guest
Hey all, it's ya boi Sakurah!

Solution to the above problem;

As far as I understand it, `draw_rectangle` doesn't provide any UV coords and instead practically passes in junk data/NaN which in turn gets what you see on screen.

The solution (obtained from Blokatt) was to pass through the UV coords in the v_vColour varying that basically maps out the x/y coords to be [0-1],[0-1] so it works as expected.

GML:
shader_set(shd_circle);
draw_rectangle_colour(0, 0, 255, 255, 0x000000, 0x0000ff, 0x00ffff, 0x00ff00, 0);
shader_reset();
Ensure ` v_vColour = in_Colour; ` is added to the Vertex shader (so it passes from vertex into fragment shader) and you should be good!

From there the values should be accessible with `v_vColour.xy` so while it's a little awkward, it does appear to work as expected.

This post can be closed.
 
Top