PDA

View Full Version : Render To Vertex Array (R2VA)



Fugitive
09-15-2009, 10:46 AM
Hi guys,

I am reading up on how to implement a Render-To-Vertex-Array program, but given how fast OpenGL has changed, and the myriad of extensions, I am utterly confused.

I have managed to get Render-To-Texture via FBO working. Now, if I understand correctly, in order to read back the texture as vertices I have the option of using a PBO (which requires a copy on the GPU), or to 'cast' the FBO to a vertex array (http://delivery.acm.org/10.1145/1200000/...FTOKEN=18544134 (http://delivery.acm.org/10.1145/1200000/1198779/p162-kruger.pdf?key1=1198779&key2=9076492521&coll=GUIDE &dl=GUIDE&CFID=51702604&CFTOKEN=18544134)).

I am under the impression the latter is a more modern approach (according to this http://hacksoflife.blogspot.com/2006/10/vbos-pbos-and-fbos.html FBOs almost make PBOs obsolete). The darn thing is that I have no clue how to go about doing this 'cast' from FBO to VBO. After several days of fruitless searching, Google has not been my friend, and so I ask for help here.

Kind regards,
Fugi
p.s: I know I can use the texture in the Vertex Shader as a 'displacement map' but my texture contains lots of 'empty space', i.e, no vertices.

Alfonse Reinheart
09-15-2009, 11:29 AM
Transform feedback is the more modern approach. You run a vertex shader, and instead of rendering, it writes the outputs to a buffer object.


The darn thing is that I have no clue how to go about doing this 'cast' from FBO to VBO.

I don't know what they're talking about either. There is no conversion operation from FBOs to buffer objects. The closest thing you might get to this is using a texture buffer as a render target. Texture buffers are 1D textures (but can be much wider than regular 1D textures) that have their storage in a buffer object. You can render to them, then bind the buffer as a VBO for rendering later.

However, the hardware that supports texture buffers also supports transform feedback, so you should probably just use that. It's less complicated.


I know I can use the texture in the Vertex Shader as a 'displacement map' but my texture contains lots of 'empty space', i.e, no vertices.

Then you need to re-think your R2VA strategy.

Eosie
09-15-2009, 12:30 PM
By casting a FBO to a VBO, they probably mean copying pixels to a PBO using glReadPixels.

DmitryM
09-15-2009, 01:00 PM
As Alfonse mentioned, Transform feedback is what you need. However, I still can't make it work on ATI.
I've done some research on skinning methods (which is generally a subtask of general R2VA) that might be useful:
http://code.google.com/p/kri/wiki/Skinning

Ilian Dinev
09-15-2009, 02:42 PM
I had read nVidia docs (or maybe just someone mention here) that with the FBO+PBO G80+ are avoiding the copy, and internally do casting.
Still, my GF7600 could easily generate/transform 4 million vec3s and then PBO-copy to a VBO and then use that VBO to draw 1 million lines onscreen for <5ms (when the lines were generally <6px in length)

Fugitive
09-15-2009, 05:02 PM
Thanks guys,

I am unable to find any up-to-date examples of the Transform Feedback being used for cross-GPU (ATI and NVidia) development. The examples I've been able to find use the Nvidia extension.

Any quick pointers on where I can find good info?


By casting a FBO to a VBO, they probably mean copying pixels to a PBO using glReadPixels.

Thats what I thought, but no, they specifically mention these two techniques as seperate.

Alfonse Reinheart
09-15-2009, 05:39 PM
Any quick pointers on where I can find good info?

The use of Transform feedback should be the same on any platform. If it's not working, it's likely because ATI hasn't bothered to implement it properly.

Fugitive
09-15-2009, 11:23 PM
So if I use the "NV" extension, it should work on both GPUs by default?

martinsm
09-16-2009, 09:48 AM
Don't use NV extension.
Use EXT_transform_feedback. It is based on NV extension, but is supported also by ATI, and it is also in GL3 core.

DmitryM
09-16-2009, 10:25 AM
It's hard to use such technology without a single working example... I wish there was any...

Fugitive
09-16-2009, 10:29 AM
Don't use NV extension.
Use EXT_transform_feedback.

Thanks, I just discovered that.

With the latest opengl making Transform Feedback core, Im guessing we dont even have to use 'EXT' anymore.

Still, I agree with Dmitry that its a pity there arent any clean-and-simple examples of the transform-feedback around.

The closest I got to something decent is this:
http://cvit.iiit.ac.in/index.php?page=resources

Its simple and quite straight-forward, even if it uses the NV extension.

Fugi

DmitryM
09-23-2009, 09:00 AM
I have extremely good news, Fugitive:

TF works on Catalyst 9.9 at least in GL-3.0 context!
Discovered it just recently.