Closed Pat-Lafon closed 3 years ago
I'm not sure I follow the proposed syntax. Where does ID.x
come from? What I was imagining was something closer to [uint []] gl_GlobalInvocationID
, which essentially "declares" the magic variable as something that can be used. Of course, this should probably be in or checked against a library somewhere, but the goal here should be to eliminate magic variables wherever possible, at least as I understand this goal.
After we talked I basically when with your syntax though the qualifiers go first so [[] int] gl_VertexID
. Currently a bunch of these variables are "allowed" and there is a function in the shared file to check for them. As it is currently we are only checking that the variable is spelt correctly and that the type is what we expect. This doesn't really connect to whatever code someone wrote in their main function. That's a little sad but probably ok for the moment. The type syntax for the "magic functions" is probably going to be a bit odd but doing something similar to those constant values should be a quick change.
Closed by #21
Currently shaders have a bunch of magic values like
gl_GlobalInvocationID.x
which in the examples are set to some index value. Instead you should write an index parameter like[[ID.x] uint] index
which probably needs to insert code likeuint index = gl_GlobalInvocationID.x;
into the void main function of the shader. This also might be the time to start thinking about magic functions likedistance
,normalize
, andclamp
as shown in the boids example.