Hi,
I’m making a GPU particle system with the transform feedback buffer. I have combined the particles’ position and time into a single array, so each particle has four-elements (floats).
For my test data, I’m using one particle. The particle’s initial position is [6, 3, 2], and its initial time is -1, leading to a position_time vertex buffer containing: [6.0,3.0,2.0,-1.0].
I can read back the data, and see that the VBO contains this data.
After applying one step iteration, the particle’s position is:
[6.0,6.0,6.0,6.0]. The shader is just for testing, so it’s very simple:
#version 130
in vec4 position_time_in;
out vec4 position_time_out;
void main() {
position_time_out.xyzw = position_time_in.wwww;
}
After one pass with the shader the target VBO contains: [6.0,6.0,6.0,6.0], which is clearly not right.
The key lies in “position_time_in”'s swizzle:
Using swizzle “.wwww” -> [6.0,6.0,6.0,6.0]
Using swizzle “.xyzw” -> [6.0,3.0,2.0,-1.0]
Using swizzle “.wzyx” -> [-1.0,2.0,3.0,6.0]
As you can see, when all “w”'s are specified, the first component is used, instead of the last. I’ve also tried the .rgba components instead, with the same result.
I was hoping to use something of this form for debugging, but for some weird reason it’s not. Any ideas, anyone?
Thanks!
-G