i want to write a shader that scans an incoming texture for it's colour values, and uses these colour values as coordinates to draw a new texture.
i am a total beginner in this area, and in the last weeks i looked into the subject and am slowly starting to understand the concepts of glsl.
as far as i understand it to reach my goal i have to do this "construction process" of the texture in a vertex program.
however, while fragment programs are quite easy to understand, and there are a lot of nice introductions to the matter, vertex programs are not.
there is a wonderful simple introduction here on this site for shaders in general, and fragment programs in specific, but unfortunately there is no comparable introduction to working with vertices.
i couldn't find any example code that comes close to what i want to achieve.
this is how i think it should work:
- set up some uniform sampler2drect (map texture)
- set up some varying kind of array or new "result" texture (with the dimesions of the range of max. colour values)
// this is the most difficult part for me to understand, as i don't really understand the types of arrays/buffers/etc and how they are set up/accessed/written to
- set all cells in "result" to 0 as default
- read the incoming "map" texture
- iterate through each of the cells of the "map" texture and read out the colour values
- set each cell that occurs in this lookup process to 1 in the "result" array // i know colours have to be vec4 - this is only a simplification
- pass the "result" coordinates to the fragment processor to use as texture coordinates
- read the data the "result" array is holding at the current position
- paint the current cell according to this data
can anyone please give me some advice on this matter, or point me to some comparable glsl code that i could modify?