• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

SOLVED Drawing a Circle with GLSL shader

Sakurah

Member
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
 

Sakurah

Member
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