So currently, I have a deal where I edit an array in Lua, and then I need to update it in the shader. I generally only change one element of the array, yet I have to resend the entire array just to change the one index.
I'm not that great with GLSL but I've always heard that sending externs/uniforms to shaders didn't have that much overhead. If you're only sending this one array, and this array isn't huge, would it even be worth it to try and optimize that? The only thing I can think of is to:
1: Have a separate, smaller array that you use as an override for values in your shader when you only need to change one value.
2: Split your array into a butt-ton of externs.
3: Depending on what you're using your shader for, do multiple passes with your shader per every 10 or so array values so you don't have to send them all.
All of those suggestions are trash by the way, and would probably result in more slowdown than if you just sent the array every time it changed. I mean I send vec4's to my array multiple times a second without slowdown, and after looking into it I can't find anything about updating a single value of an array like that.
Thanks for the help. What I'll do is I'll continue resending the entire array 60 times per second or whatever (ugh). It's not that slow, but it's still just gross conceptually.
Love2d really needs to add some kind of support for that.
AxisAngles wrote:Thanks for the help. What I'll do is I'll continue resending the entire array 60 times per second or whatever (ugh). It's not that slow, but it's still just gross conceptually.
Love2d really needs to add some kind of support for that.
Regardless of whether Löve creates an API to do this or not, OpenGL still requries that the whole Uniform be loaded to the GPU every time it is changed so there is no performance benefit if you reuse the same lua table every frame.