ジョイントの変換行列を含む mat4[] へのインデックスを保持するために int[] 属性を必要とする骨格アニメーション用のシェーダーを作成しています。私の問題は、int[] を格納する VBO を作成できないことです。GL30.glVertexAttribIPointer() を使用してみましたが、私のコンピューターは Opengl 3.0 をサポートしていません。したがって、すべての値を浮動小数点数に変換する glVertexAttribPointer() を使用する必要があります。シェーダーがアクセスできる VBO に int[] を格納する最良の方法は何ですか?
1 に答える
There are two problems with what you're trying to do.
The first problem is that you're trying to pass integers. Use floats; there's nothing wrong with using a float as an index into an array. If you pass GL_FALSE
for the normalized
parameter of glVertexAttribPointer
, you will get what are effectively integers. You can pass each index as a GL_UNSIGNED_BYTE
.
The second problem is that you're trying to pass an array. Stop doing that; you want a vec4
, not an array. The XYZW represent the four indices that you use with the matrices.
What if a vertex needs more than 4 matrices? Stop doing that too; that's how everyone else does skinning. The way this works is, when you're building your vertex data, if a vertex is affected by more than 4 matrices, you only take the 4 with the largest weights (readjusting the weights accordingly).