I\'m trying to implement a point cloud where the different points shall vary in size based on an uncertainty value associated with them. Let\'s say, if this value is zero, t
You can pass a texture1D with the values for each point.Then use texelFetch() to retrieve the values.You can use an atomic counter (if using OpenGL 4.2) , or gl_vertexID to do this.Also take a look at this question and this one, the accepted answer also suggest additional solutions like UBOs. Though if your point cloud is pretty big then Buffer Textures is what you need.
Let's take the Buffer textures approach:
In the vertex shader you access those values via texelFetch sampling .As I said,you can use gl_VertexID to sample by current vertex,(something like this):
uniform samplerBuffer pointsBuffer;
void main() { float destSize = texelFetch(pointsBuffer, gl_VertexID).x; ... }
Now, you probably want to interpolate the point size from the default to the target size based on some amount.Yes timer input which ranges between 0 and 1 can do the job.Use mix() built-in method to interpolate the point size from the default the destination.For more fun pass sin() or cos() based time :)
As you have mentioned OpenGL superbible , it has a chapter that explains how texture buffers work.Read it again.What you are trying to do is not a rocket science but not a beginner level either.So be patient -which is always good tip when working with OpenGL.
First of all...thanks for your answer. I've worked things out using just a vertex shader. I guess this was the solution I was hoping to get. Maybe folks with the same problem can benefit from this:
Part of my vertex shader looks like this:
...
" float standardPointSize = 100.0;"
" float timeScale = standardPointSize / my_loopDuration;"
" float currentTime = mod(my_time, my_loopDuration);"
" float offset = currentTime * timeScale * in_uncertainty;"
" if(currentTime < my_loopDuration / 4)"
" {"
" gl_PointSize = standardPointSize - 4 * offset;"
" }"
" else if(currentTime >= my_loopDuration / 4 && currentTime < my_loopDuration / 2)"
" {"
" gl_PointSize = standardPointSize - standardPointSize * in_uncertainty + 4 * offset - 1 * in_uncertainty * standardPointSize;"
" }"
" else if(currentTime >= my_loopDuration / 2 && currentTime < 3 * my_loopDuration / 4)"
" {"
" gl_PointSize = standardPointSize + 4 * offset - 2 * in_uncertainty * standardPointSize;"
" }"
" else if(currentTime >= 3 * my_loopDuration / 4 && currentTime <= my_loopDuration)"
" {"
" gl_PointSize = standardPointSize + standardPointSize * in_uncertainty - 4 * offset + 3 * in_uncertainty * standardPointSize;"
" }"
...
my_time and my_loopDuration are uniform variables. The first one is set with glutGet(GLUT_ELASED_TIME) and the second one is an arbitrary number.