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

vertex_color opacity issues

L

Linas Sidlauskas

Guest
Hey guys,

I am starting out with Vertex Buffers, I do not fully understand them yet, but I am managing to get things working. My issue is when I set vertex_colour ("vertex_colour(_vb, $000000, 0.1);"), although alpha is constant, when it is rendered in the game, you can see it changing. I would try and use 'vertex_rgb()' function, but I don't really understand how you would set opacity as it seems to take only hex values. Can you guys suggest a good way of setting opacity in this scenario?

My code, which creates triangles around a player. At the bottom you can see opacity being set to 0.1, but the next screenshot shows that every ring around player has differing opacity:
Capture.PNG

In game screenshot, I am trying to have every ring around the player to be of 0.1 opacity, but it is not constant. Solid black lines going off into the distance are part of a different function, but they are both nested in the same event.
screenshot.PNG
 

Bart

WiseBart
From the code that you provided it appears that you're indeed setting colours with an alpha value of 0.1.
So there must be something else that makes the triangles appear differently on screen.
In this case, it seems like a constant amount of gray is added each time you go more outward.
Two things you can check:
  • How are you drawing that vertex buffer? Did you set a blend mode other than bm_normal?
  • What value gets assigned to gl_FragColor in the fragment shader?
 
L

Linas Sidlauskas

Guest
From the code that you provided it appears that you're indeed setting colours with an alpha value of 0.1.
So there must be something else that makes the triangles appear differently on screen.
In this case, it seems like a constant amount of gray is added each time you go more outward.
Two things you can check:
  • How are you drawing that vertex buffer? Did you set a blend mode other than bm_normal?
  • What value gets assigned to gl_FragColor in the fragment shader?
So I created Vertex Format and Vertex Buffer like this:
vertex_format_begin();
vertex_format_add_position();
vertex_format_add_color();
VertexFormat = vertex_format_end();
VBuffer = vertex_create_buffer();

Then within the DRAW event I then started drawing my Vertex using these Vertex Format and Vertex Buffer that I created, which is basically this function that you can see above. I submitted it using no texture and pr_trianglelist for my base type. I didn't change blend mode unless it is something else by default. I looked into it, apparently you have to use gpu_set_mode() to change blend mode, but I am not even sure where I would put that.

I am not using built-in shaders, so I haven't assigned gl_FragColor to any value.
 
L

Linas Sidlauskas

Guest
By the way it works fine when alpha = 1 or 0, but anything in between creates this gradient effect.
 
L

Linas Sidlauskas

Guest
Found my problem. I thought every new ring was created on the outside of the initial rings, but in reality they were overlapping, so since the colour was not solid, you could see the overlaps creating this gradient effect. Could be useful in the future :D...
 
Top