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

Multiple attributes

R

renex

Guest
I've been trying to get a custom vertex format working in GLSL ES for about three days and i'm not getting anywhere because only the standard input attributes are getting mapped at all.

How do I use multiple in_Positions?

Code:
vertex_format_add_position_3d()
vertex_format_add_position_3d()
vertex_format_add_colour()
vertex_format_add_colour()
vertex_format_add_textcoord()
Code:
attribute vec3 in_Position0;
attribute vec3 in_Position1;
attribute vec4 in_Colour0;
attribute vec4 in_Colour1;
attribute vec2 in_TextureCoord;
 
R

renex

Guest
Oh. That makes sense.

I tried a variation of that earlier, but I don't know the syntax for the custom attributes on the glsl es shader. I tried using in_Position1, in_Position2 but none of these seem to correctly receive the values. They're all zero.

I'm currently packing the extra coordinates on the normal channel and that's kind of working but later on when I implement the other extra data i'm going to run out of space.
 
K

kbaccki

Guest
Just ran into this issue myself... Based on this somewhat recent post https://forum.yoyogames.com/index.p...-es-shader-attribute-constants.669/#post-5437 and along the same lines as co-opting the normal vector, the following seems to work if you don't need too many color attributes:

vertex_format_begin();
vertex_format_add_position_3d();
vertex_format_add_colour(); // <<== will bind to in_Colour0
vertex_format_add_custom(vertex_type_float3, vertex_usage_colour); // <<== will bind to in_Colour1
etc.


attribute vec3 in_Position; // (x,y,z)
attribute vec4 in_Colour0; // (r,g,b,a)
attribute vec3 in_Colour1; // custom vec3 attribute


Note: vertex_usage_colour is just for binding purposes -- I'm passing a vec3 there, not a color vector.

Totally custom (non-fixed) bindings would be nice though... unless I'm missing something...
 
R

renex

Guest
Passing the extra colors like that solves my problem for now, but it would be nice to know how to pass extra positions into GLSL ES.

@Mike can you shed some light into the situation here?


Note: vertex_usage_colour is just for binding purposes -- I'm passing a vec3 there, not a color vector.
OH WAIT I GET IT

I'm testing that now

---

actually that works, lol.

I'll be using that from now on but wow, that's a very messy way to do things. Thank you.


vertex_format_add_custom(vertex_type_float3,vertex_usage_position)
vertex_format_add_custom(vertex_type_float3,vertex_usage_colour)
vertex_format_add_colour()
vertex_format_add_colour()
vertex_format_add_custom(vertex_type_float2,vertex_usage_textcoord)

attribute vec3 in_Position;
attribute vec3 in_Colour0; //position2
attribute vec4 in_Colour1;
attribute vec4 in_Colour2;
attribute vec2 in_TextureCoord;
 
Last edited:
K

kbaccki

Guest
Just a quick follow up... tried the same with just a single float, and it didn't work. I guess packing floats is reasonable given the nature of the workaround. Didn't look too much at the mapping/binding code on the GM side, but if you're curious: in the GM console find the "/o" switch (e.g. /o=C:\Users\Anyone\AppData\Local\gm_ttt_22652\gm_ttt_99853) and load the <proj>.win file from there into an editor that can handle binary... like emacs, or maybe sublime or some other pro windows editors that I don't use.
 
Top