This problem bothered me for days…
I have two textures which we could name it ‘Tex1’ and ‘Tex2’ respectively. The two textures have different resolution.
Each texel in Tex1 contains a ‘data’ field and an ‘Index’ field(which will be used next).
Now I want to traversal every texel in Tex1 in GPU to retrieve the ‘data’ and ‘Index’. Then write ‘data’ into specific postion of Tex2 according to the ‘Index’ retrieved before.
For a simple example, we retrieved ‘0.1’ and ‘1’ for ‘data’ and ‘Index’ from Tex1 respectively, then I want to write ‘0.1’ into the '1’st texel in Tex2.
How could I achieve that via vertex and fragment shaders.
I’ve read a paper which use each texel in Tex1 as a vertex in vertex shader(some ‘texture to vertex arrays’ technique I never heared), retrieve data and index, send data to the ‘right’ place according to the index. Then use a fragment shader to write the data received into framebuffer. The frame buffer have the same resolution of Tex2.
The paper didn’t tell the details. And I’m so confused about how to “send data to the right place according to the index” in a vertex shader?
Any suggestions about this requirement?