Jump to content
  • Advertisement
Sign in to follow this  

OpenGL on GL_FEEDBACK alternatives

This topic is 4497 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Let me explain what I _want_ to do: I use a vertex shader to do GPU skinning, and potentially complex skinning. I woule like to save the values that the vertex shader produces without first taking the data into system memory, at first GL_FEEDBACK looked good but: 1) the data gets copeid to main memory (i.e. from card to system) 2) the openGL spec does not say what happens with GL_FEEDBACK in conjuction with shaders, it also states that not all the data is put into the system memory anyways (naley other texture co-oridnates) so, does anyone know of an extenstion or core function that does the following: set up one's vertex shader, but when one calls glWhateverToRender, the output from the vertex shader is then streamed to a VBO (rather than getting fed into the rasterizer). the main advantage for me to do this is that if my vertex shader is too long, I can break it into steps and also, if one does mutli-pass rendering this can let you save the skinning values. Best Regards

Share this post

Link to post
Share on other sites
Don't use GL_FEEDBACK. It's archaic and probably runs in software.

What you are looking for is render to vertex buffer (R2VB).
You need to have EXT_pixel_buffer_object and only NV has this at the moment. There is no way to do it on ATI.
Of course, if you have EXT_pixel_buffer_object then surely you have VBO which is in GL 1.5

The spec for EXT_pixel_buffer_object has an example.
Basically, you create a PBO and bind it.
glReadPixel (which copies backbuffer directly to PBO)
Bind PBO as a VBO and render.

You can use a FBO. Render to the FBO instead of the back buffer and copy to the PBO.

Share this post

Link to post
Share on other sites
Aces! thanks a bunch!

Edit: taking a gander at it, I 've found some issues:
1) the approach of writing a custom vertex shader/fragment shader to draw to the framebuffer and then fetching the values from the framebuffer I had though of before, but I was not aware of the PBO which lets all the stuff stay on the card, so that is OK, but, then the data is not exactly what the vertex shader outputs, rather it is what the fragment shader makes from the vertex shader input, but this means that I am bascily limited to reading in at most 4 floats (if the card supports rendering to floats) which is (just) one vec4... hmm... I suppose MRT's can help me there along with FBO's.. but still I was hoping for a more direct way to get the output from the vertex shader, sniff.

[Edited by - kRogue on April 21, 2006 3:03:54 AM]

Share this post

Link to post
Share on other sites
If you create a RGBA, 32 bit float buffer, and you want to output vertex+normal, I think you have to do something like

if(pixel is even)
gl_FragColor=vec4(vertexX, vertexY, vertexZ, junk);
gl_FragColor=vec4(normalX, normalY, normalZ, junk);

and your VBO code becomes
glVertexPointer(3, GL_FLOAT, 32, 0);
glNormalPointer(GL_FLOAT, 32, 16);

and in principal, you should be able to add any additional data. Let me know how it goes.

Share this post

Link to post
Share on other sites
err, not really.. you have to make your fragment shader and vertex shader work together to output several things.. one way:

MultipleRendering targets: an FBO for each field you want to use, easy to do but kind of wasteful.

Multiple passes: except for vertex position, most of skinning is simple, normal, tangents and bitangents get multiplies by two matrices at most (one skinning matrix and modelview or one skinning and movelViewInverseTranspose), so you run through the "render to buffer" one time for each piece of data you want to "save". the framgemnt I would render to would depend on what I am writing to.. so lets say I want normals and positions:

vertex shader for vertices:
varing inputs are whateverDatatoSkin and an index(i.e an integer that says what index we are caclulating)..

output of vertex shader for veritices
glPosition (place to draw to on screen) and
vertexValue (vec3 value saved)

then basicly we would do:
glPosition=CaclulationVertex(index); where CaclulationVertex transform an index
to a pixel to draw to, so bascily something like: CaclulationVertex(index)=TansformToGL(vec2(( 2*index)%Xresolution, (2*index)/(Xresolution) ))

and then in the fragment shader:


then for the normals I'd make another vertex shader, but it would have:
vec2(( 2*index)%Xresolution+1, (2*index)/(Xresolution)))

and the fragment shader would be the same...

then afterwards the vertex data would be on the even pixels and the normal data would be on the odd

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!