I am trying to port parts of a GLSL project to TD, where struct’s are stored in a buffer. It looks something like this:
struct MyStruct {
vec3 a;
vec3 b;
vec3 c;
};
layout(std430, binding = 0) buffer MyBuffer {
MyStruct data\[\];
};
….
data\[index\] = *another struct* ;
Is this possible with GLSL POPs (or TOP)?
I know for GLSL POP buffers are automatically created per input/output attribute, but is it possible to store and swap whole struct’s directly?
I want to do this for performance, as I believe this is more efficient than working with multiple buffers (one buffer per attribute vs one per struct)?
Hello @lion.toe,
This is currently not possible, however array attributes are supported so in the example above you can create a vec3[3].
Admittedly this might be a contrived example, but array attributes allow you to declare more data per element in a single buffer which you can then interpret how you see fit (admittedly not ideal if you want to mix ints and floats)
In any case, logging this for consideration internally.
1 Like
Thank you @vincentDev !
Yes I do need to store vec3‘s and int‘s together, so for now I will try to cast the int‘s to floats and go with an array buffer.
Would be psyched if you consider adding it in the future!
1 Like
You’re welcome, also in case you’re not familiar with them you can use
floatBitsToUint() and uintBitsToFloat() to store and decode floats as UInts