• 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!

Shaders Not really shaders (more primitives) [QUESTION]

xDGameStudios

GameMaker Staff
GameMaker Dev.
QUESTION::

how does:
Code:
draw_vertex_texture_color()
work when using "pr_trianglestrip"
does just the last triangle gets coloured with the color/alpha from the vertex?

why do I ask this?

CONTEXT::

Code:
draw_primitive_begin_texture(pr_trianglestrip, s_texture);
draw_vertex_texture(x1, y1, 0, 0);
draw_vertex_texture(x1, y2, 0, m);
draw_vertex_texture(x2, y1, m, 0);
draw_vertex_texture(x2, y2, m, m);
draw_vertex_texture(x3, y1, 1 - m, 0);
draw_vertex_texture(x3, y2, 1 - m, m);
draw_vertex_texture(x4, y1, 1, 0);
draw_vertex_texture(x4, y2, 1, m);
draw_vertex_texture(x4, y3, 1, 1 - m);
draw_vertex_texture(x3, y2, 1 - m, m);
draw_vertex_texture(x3, y3, 1 - m, 1 - m);
draw_vertex_texture(x2, y2, m, m);
draw_vertex_texture(x2, y3, m, 1 - m);
draw_vertex_texture(x1, y2, 0, m);
draw_vertex_texture(x1, y3, 0, 1 - m);
draw_vertex_texture(x1, y4, 0, 1);
draw_vertex_texture(x2, y3, m, 1 - m);
draw_vertex_texture(x2, y4, m, 1);
draw_vertex_texture(x3, y3, 1 - m, 1 - m);
draw_vertex_texture(x3, y4, 1 - m, 1);
draw_vertex_texture(x4, y3, 1, 1 - m);
draw_vertex_texture(x4, y4, 1, 1);
draw_primitive_end();
this primitive code will make it so one can draw a 9patch with primitives... the frame+background... what if I want to draw the background in another alpha?! or color? what would I have to change?!
 

Tthecreator

Your Creator!
No, let's say you have a single triangle. Then every corner will get a certain color. In between those colors there is interpolation, so for example: blue will slowly turn into red as you go from 1 point to another.
If you want an entire triangle to be a color, you will have to set all 3 corners to that color.
 

xDGameStudios

GameMaker Staff
GameMaker Dev.
No, let's say you have a single triangle. Then every corner will get a certain color. In between those colors there is interpolation, so for example: blue will slowly turn into red as you go from 1 point to another.
If you want an entire triangle to be a color, you will have to set all 3 corners to that color.
Okay ;) thank you for you help... well not really happy :) (will not be as easy as I thought) but thank you never the less!!
what do you suggest? doing the draw in to passes?! first the frame then the background?!
or should I even be using another primitive type for this?
 

Tthecreator

Your Creator!
I wouldn't do the drawing in many passes, but what parts do you actually want to color in? Just have the frame and background a different color?
Then maybe yes, draw these 3 in different primitives.
 

xDGameStudios

GameMaker Staff
GameMaker Dev.
I wouldn't do the drawing in many passes, but what parts do you actually want to color in? Just have the frame and background a different color?
Then maybe yes, draw these 3 in different primitives.
Well I wanted to select one color/alpha the the frame, and one color/alpha to the background.. the color and alpha will not be changing during the draw.... is a fixed alpha/color to the frame and a fixed alpha/color to the background
 

xDGameStudios

GameMaker Staff
GameMaker Dev.
if you use different textures, or non connecting textures then yes. Otherwise it doesn't really matter
the 9path uses a single sprite a single image index... so a single texture so... I don't think I need more then one primitive draw.

Now the really important question I should have started with....
it is less performant to draw overlapping triangles... it is not possible (to my knowledge) to draw a frame (ONLY) using "pr_trianglestrip" without overlapping.. so should I use pt_trianglelist? this way there will be no overlapping triangles... but there will be more vertices... does that interfere (much) with the performance?!
 

Tthecreator

Your Creator!
It's certainly possible. What I do in these cases is just draw the shape I need on a real sheet of paper, mark all the points and try to find a connection is such a way that we can create a pr_trianglestrip. In 99% of all closed shapes it's possible but requires some puzzling around.
 
Top