View Full Version : Transform Feedback with LINE_STRIP
09-04-2007, 06:51 AM
I'd like to do the following:
Provide a geometry shader with a seed point (vertex location). The geometry shader creates a line strip, which I would like to feedback to a buffer.
How do I set up transform feedback to accept the line strip, and how do I set the linestrip into a varying variable?!
So in the shader I'd guess something like
vec4 linestrip for each vertex location?
And for the feedback my first guess would be:
But what to do with glGetVaryingLocationNV?
Hopefully someone can help me out...
09-04-2007, 07:49 AM
This should tell you everything you need to know:
Note that you cannot use GL_LINE_STRIP in the begin feedback function - instead you use GL_LINES. You can still render a line strip though.
You'll probably want something like this to initialize things:
int locations =
glTransformFeedbackVaryingsNV(shader, 1, locations, GL_SEPARATE_ATTRIBS_NV);Then, you'll want to bind a VBO to feedback location 0 to capture the data:
glBindBufferBaseNV(GL_TRANSFORM_FEEDBACK_BUFFER_NV , 0, destination_vbo);
09-04-2007, 12:31 PM
Thank you for the quick reply.
I have seen the spec, but some things remain unclear. For instance I want the line strip to consist of, for instance, 20 segments, which implies that we need to return 19 vertices. How to put this in a varying variable in the geometry shader?
09-04-2007, 12:44 PM
Originally posted by ropel:
Thank you for the quick reply.
I have seen the spec, but some things remain unclear. For instance I want the line strip to consist of, for instance, 20 segments, which implies that we need to return 19 vertices. How to put this in a varying variable in the geometry shader? If I understand correctly, you are wanting to emit n line segments from the GS as a line strip. This means that you will need to emit n+1 vertices.
If this is the case, you simply do something like the following in the GS:
gl_Position = vertex 0 position
gl_Position = vertex 1 position
gl_Position = vertex n position
}Of course, you could also use a for loop to emit them, and store the positions as a constant array.
09-04-2007, 01:12 PM
Ah yes.. I see. I was wondering if we needed a seperate variable for each vertex emitted. That would have been very inflexible and redundant.
I'll be trying this first thing in the morning!
I appreciate your clear and fast response.
09-05-2007, 04:46 AM
So I have got things going, thanks to the good comments. But it really is extremely slow!
Currently I feedback around 1.600.000 primitives, which takes more than half a minute.
I am comparing results with a direct approach, where I render line segments every frame, with an off-line approach where I first render the line segments to a VBO using transform feedback.
On average I only gain 5 FPS, whereas I have to wait very long for the line segments to generate.
Is this correct? Are there any other solutions?
(For instance generating the line segments CPU side?)
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.