Is this possible with vertex programs and/or texture shaders?

I figure those two things are the only way to do this. I’m no egg spert on how/when things happen in the OpenGL pipeline though and I’m kind of suspicious that this isn’t possible at all ( in hardware anyway ) Here’s the outline of the algorithm I want to do.

  1. Calculate the distance from the vertex to a point.

  2. If the distance is less than 600 scale the distance from [0, 600] -> [0, 1].

  3. Use the new distance as a texture coordinate on a 1D texture and look up the texel at that coordinate.

  4. Set the vertex color to that texel’s color.

Is this possible? I want to make the 1D texture simply the ROY G BV spectrum and what I imagine this looking like an ifrared image which will give you a good idea of relative distance betweem the point and the rest of the geometry in the scene.

[This message has been edited by grady (edited 02-01-2002).]

  1. You can do this in a vertex program

  2. You can also do this

  3. You can make the distance a texture coordinate in the vertex program. The texel color value will be available to you in the register combiner stage.

  4. Are you sure you want to do this? Why not just map the polygon with your already indexed texture? The filtering will be better anyway.

In general, the pipeline goes from large scale to small scale. I.e. vertices to pixels. You generally can’t go backwards as you would have to to slap a texture color onto a vertex color.

– Zeno

[This message has been edited by Zeno (edited 02-01-2002).]

Originally posted by Zeno:
4. Are you sure you want to do this? Why not just map the polygon with your already indexed texture? The filtering will be better anyway.

Joy. I did some experiements and that looks like it will work well. I didn’t know how the 1D texture would act on the poly it was applied to, but it looks good, thanks for the help.