Iterate through second texture in [jit.gl.pix]?
Is it possible to iterate over a second texture in [jit.gl.pix]?
I want to get the vector magnitude between of each cell from a streaming texture [in 1] and each cell in a static texture [in 2].
For each [cell] of [in 1]:
- I need to iterate over all the cells of [in 2]
- Calculate the vector magnitude between [in 1]'s cell and each cell in [in 2], finding the combination with the smallest magnitude
- Place the nearest match in the [cell] of the output texture.
Then repeat for each [cell] of [in 1]. Essentially I'm trying to make a [jit.charmap] on the GPU working with floats and in 3 (or even 4) dimensions simultaneously.
I have been trying to work out a similar thing. You can sample another matrix but you need to create the same rule for every pixel. There is no array access or history in Gen.
This seems then just to be a limitation within [jit.gl.pix], as you can access [data] and [buffer] structures within [gen~]. Understandable they're different beasts; but it'd be nice to a little more information about how to use all the objects within [jit.gl.pix]. I always get disappointed when I get the little popup to learn about the object, click the little (i) to go to the reference page, only for it to tell me the same information.
So, might the only way this might be done on the GPU is if I start trying to learn how to code my own shaders in [jit.gl.slab]? I didn't want to have to go this deep so quickly :S
Or is it not even possible to do this in raw GLSL?
I've just had a quick read through Andrew Benson's GLSL article , and it has a sentence that pops out at me - but I'm unsure if I understand correctly.
https://cycling74.com/tutorials/your-first-shader
"This is then run for each pixel of the output texture in a massively parallel way. Because of the architecture of the graphics card, you only have access to the single framebuffer output pixel within your program."
I'm not sure what a "single framebuffer output pixel" is. Does this refer to the topic of referencing textures in a non-sequential fashion as I've questioned in my topic?
if you want to access texture history with jit.gl.pix, simply send the output to a jit.gl.slab/texture, and then send that slab/texture output to an input in your jit.gl.pix:
Thanks Rob.
Actually - I was having more an issue with looping and accessing specific parts of a second texture. Both of these problems were resolved by using [codebox]/[loop] and [sample]/[nearest] respectively.
I think the words I quoted from Andrew were confusing me.
Chris.
Hi Chris,
I am not sure if this message will reach you at all, but let's try! :)
I am trying to do something quite similar to what you explain in this post, i.e. iterate over two matrices.
Someone suggested to do it in jit.gen to be more efficient than with java or js. I am trying to understand this could be achieved in the codebox, but so far got no success, and debugging is not very easy in there.
What I would need is something like: for(i=0; i
I am really struggling to achieve even a basic forloop to fill the output matrix with a simple increment of i, as in (0 1 2 3 4 ... n).
Any suggestion on how you approached your solution?
Every help would be highly welcome!
Thanks a lot!