• 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!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Discussion [Suggestion] Passing buffers to shaders as Uniforms

mMcFab

Member
Maybe we need a suggestion prefix or board or something? I'd submit this on the bug form, but it feels dirty without being able to explicitly state it's a suggestion. I'd twitter it, but that feels weird too. Maybe some kind of suggestion board that can be voted on to boost big wants? Anyway, moving on to the actual suggestion:

So, the suggestion. This suggestion is not about vertex buffers, but about passing regular buffers to a shader as a uniform. Since we've moved onto GMS2 and the updates to rendering due to DX11, I though maybe now would be the time to suggest.

I think it would be really neat if we were able to pass buffersbuffer addresses to a shader in a similar way to how we can with arrays. E.g., a function such as:
Code:
shader_set_uniform_f_buffer(uniformID, buffer (or buffer ptr))
Okay, but WHY?
Well, the primary reason, simply put, is this:

Extensions
You see, although I can't pass/return an array to/from a DLL extension, I can pass a buffer by pointer to an extension, which could be filled with information such as a heaping pile of matrices that I want to do math on/with that is simply too slow to do in GML. When all is said and done, I can rewrite the buffer contents and that's sorted. However, in order to pass all this information to a shader, I then have to convert it into a big old array - which can get really slow, particularly with large amounts of info being updated every step (this happens when I build animation matrices from quaternions, for example). Passing the buffer directly would hopefully cut out this seemingly unnecessary middleman.

Just to note, I would still be happy even if we were only allowed to pass fixed size buffers filled with float32's, since that's all I really need anyway.


So, I have no idea if it's possible, but I do know I would find it super useful. I did try to see if it was already possible, but saw no evidence of it either.
 
Top