トランスフォーム フィードバックを使用する GLSL プログラムを頂点シェーダー + ジオメトリ シェーダーとリンクしようとしています。ここで指定された変数のいずれかが見つからないため、プログラムはリンク エラーを返します。
ConstStr captureVars[] = {"tf.pos", "tf.speed", "tf.timeLived"};
glTransformFeedbackVaryings(prog, tl::size(captureVars), captureVars, GL_INTERLEAVED_ATTRIBS);
これらの変数は、ジオメトリ シェーダーの out インターフェイス ブロック内にあります。
out TransformFeedback {
vec3 pos;
vec3 speed;
float timeLived;
} tf;
これは私が得るエラーメッセージです:
Geometry info
-------------
0(16) : warning C7050: "tf.speed" might be used before being initialized
Link info
---------
error: Varying (named tf.pos) specified but not present in the program object.
Vertex Shader:
0| #version 330
1|
2| layout(location = 0) in vec3 a_pos;
3| layout(location = 1) in vec3 a_speed;
4| layout(location = 2) in float a_timeLived;
5|
6| out VertexData {
7| vec3 pos;
8| vec3 speed;
9| float timeLived;
10| } output;
11|
12| void main()
13| {
14| output.pos = a_pos;
15| output.speed = a_speed;
16| output.timeLived = a_timeLived;
17| }
18|
Geometry Shader:
0| #version 330
1|
2| layout (points) in;
3| layout (points, max_vertices = 1) out;
4|
5| in VertexData {
6| vec3 pos;
7| vec3 speed;
8| float timeLived;
9| } input[];
10|
11| out TransformFeedback {
12| vec3 pos;
13| vec3 speed;
14| float timeLived;
15| } tf;
16|
17| uniform float u_dt;
18| uniform float u_damping;
19| uniform float u_gravity;
20| uniform float u_lifeTime;
21|
22| void main()
23| {
24| tf.timeLived = input[0].timeLived + u_dt;
25| if(tf.timeLived < u_lifeTime) {
26| tf.pos = input[0].pos + tf.speed * u_dt;
27| tf.speed = input[0].speed + u_gravity * u_dt;
28| tf.speed *= 1.0 - u_damping * u_dt;
29| EmitVertex();
30| EndPrimitive();
31| }
32| }
33|
ご覧のとおり、ジオメトリ シェーダーは警告付きでコンパイルされます (これは私には意味がありません)。その後、プログラムはリンクに失敗します。
インターフェイス ブロックを使用せず、代わりに「tf_」で記述された変数を使用してみましたが、そのように機能しました。したがって、インターフェイス ブロック変数を指定する必要がある方法に関するものである必要があります。