Using GLSL to realize intensive computations?

Hi there,

I’ve to do some intensive computations in some vertices of some shapes but I just need to get the results back to an array to avoid recalculations and the attributes of these vertices remain constants, I mean, I just will read their positions, normals, etc, but I’ll not change any of these values.

The question is can I use GLSL to realize the calculations and get back the results to an array?

If yes, can someone please give me a hint?

Thank you.

PD: I think it can be done using a vertex shader.

You have several ways to perform GPGPU with GLSL:

  1. Bake your vertex data into a texture(s). Run a compute fragment shader on a quad using it, output to MRT.
  2. Enable Transform Feedback, disable the rasterizer and catch the vertex/geometry shader outputs into the destination VBO(s).

Hi DmitryM,

I think the choice is the second

  1. Enable Transform Feedback, disable the rasterizer and catch the vertex/geometry shader outputs into the destination VBO(s).

I haven’t use VBO yet so I don’t know if it’s suitable for what I want.

In fact the result I want to get back from the GLSL vertex shader is the distance from each vertex of my shapes (mostly rectangles or any planar spline) to one point (out of the plane).

Can I use VBO’s to store all the distances returned by the vertex shader?

Thank you once again.

Yes, you can easily output these distances as long as their number are constant per vertex (1 in your case, I guess).

Learn VBO, then GLSL and then TF.
Post any questions afterwards.

You can also use geometry shaders if you have to output variable number of results per vertex/primitive.

In fact the result I want to get back from the GLSL vertex shader is the distance from each vertex of my shapes (mostly rectangles or any planar spline) to one point (out of the plane).

If that’s all you’re interested in, you can just compute it when rendering. This is not a slow calculation for a GPU.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.