Sign in to follow this  
Lord_Vader

GLSL question

Recommended Posts

Lord_Vader    125
Hello,I have a question about GLSL. Suppose that I have a model and somehow I change its geometry every frame via a shader. Is there any way to do collision detection?Otherwise can I somehow transfer information about the new vertex position to my application? thanks...

Share this post


Link to post
Share on other sites
polymorphed    272
If I understand your question correctly: You want to be able to examine how the vertex shader transformed each individual vertex.

My answer:
I'm assuming that you have made some form of skeletal system that runs on the vertex shader, and that you want the transformed vertices back to the CPU after they have been modified on the GPU, so that you can do collisions.

It's possible, but very unfeasible. You would need to use MRTs and write the vertex position as pixels in a texture, and then read from the texture on the CPU.

You should know how your vertex shader is going to transform your vertices in the first place, so that you don't have to "read back" the vertices.

I hope this helps.

Share this post


Link to post
Share on other sites
Darragh    308
Quote:
Original post by Lord_Vader
Hello,I have a question about GLSL.
Suppose that I have a model and somehow I change its geometry every frame via a shader. Is there any way to do collision detection?


It's not possible to do collision detection using geometry and shaders, since you have no information about other geometry. However it is possible do a form of collision detection using rendered imagery. I don't know much about this myself and personally I wouldn't recommend it; do a google on 'image based collision detection' if you are interested in looking into this.

Quote:
Original post by Lord_VaderOtherwise can I somehow transfer information about the new vertex position to my application?
thanks...


No way of doing this unfortunately. The rendering pipeline does not emit back vertices once they have been transformed / dealt with.

Edit: polymorphed suggested a way of doing this by rendering vertices as pixels; but as he said it's highly unfeasible to say the least. The initial statement that you cannot read back vertices however, is still true.

Share this post


Link to post
Share on other sites
Lord_Vader    125
Thanks for your help.

I have implemented a spherical version of the Roam(not exactly) algorithm and I want to use the noise functions of the GPU to create land(to free the CPU) but in order to work this properly I must transfer some information back to my application(I make the mesh approximation in the GPU but I want to create the land on the GPU). Can you suggest any ideas?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this