Shaders Making lines in a shader .. need help

Hi all,

I am pretty competent in using GML for GMS but need a little help with crafting one of my tools into fast mode, by that I mean using shaders to draw lines instead of using the standard draw functions.

Ideally I process the lines onto a 4k(4096*4096) texture and also to a surface so that it can be saved off for later.

1) Set a surface
2) Draw my lines with a shader instead of standard draw functions (basically because I think it will be faster...)
3) Surface reset and save/display

So, my question is, is it possible or am I already pushing the limits of what I am trying to achieve.

or

If it is possible, then any help will be greatly appreciated and even rewarded depending on how much hands on help I might get.

Here is a screenshot of my tool I am creating, basically a hair strand maker for textures:

Layer 1.png
 

Bart

WiseBart
It is possible to do that with a shader.

The most straightforward way would be to create a vertex buffer and add the vertices in pairs, one pair for each line (the start and end point).
When submitting the vertex buffer using vertex_submit in the Draw event, you'd then pass pr_linelist as the primitive type.
But this still wouldn't be optimal, since the vertex buffer needs to be rebuilt if anything changes.

A better way might be to use rectangles (2 triangles) that cover the areas of the strands and move the logic to the shader entirely (the fragment shader to be precise).
That way, you only need to create the vertex buffer once with a sufficient number of triangles, freeze it to make it faster to submit and pass in the strands' parameters via uniforms (array uniforms in case of multiple strands).
Triangles in the vertex buffer that are unused can be scaled by 0 so they don't cover a single pixel or moved to a position outside of the drawing region.

Just ideas, yet both should be doable.
 
Top