# イルカ本 Chapter 4 続き glDrawArraysInstanced P80のコードだと回転速度が早すぎる。 num_cubes = 24 i = gl_InstanceID + time_factor rad = 1000 * i 1000を1.0〜2.0程度にするとそれなりにいい感じになる。 別のところで、rotation matrixを組み立てるサンプルコードは間違っている。 mat4 xrot = mat4( 1.0, 0.0, 0.0, 0.0, 0.0, cos(rad), -sin(rad), 0.0, 0.0, sin(rad), cos(rad), 0.0, 0.0, 0.0, 0.0, 1.0); -sinとsinが逆。 mat4は次のように初期化する。 x0, y0, z0, w0, // 1st column, NOT ROW x1, y1, z1, w1, // 2nd column, NOT ROW x2, y2, z2, w2, // 3rd column, NOT ROW x3, y3, z3, w3, // 4th column, NOT ROW なぜかtranslation matrixの方は正しい。