I have a question concerning compute shaders:
I want to output two textures from a compute shader. One to feed into the shader again with a framedelay and another one to render as the final output. Is it possible to output two textures from a compute shader in vvvv anyway (like in Unity for example) or do I need to add them to a TextureArray? And if so how do I add textures to a TextureArray in vvvv’s HLSL?
And a completely other question: How can I slow down a compute shader in vvvv? For example call it only every fifth frame?
When you do RWBuffer you can not only write to it with a shader you can directly read from it.
Basically your Output[x] already accessible and you can call it as any other variable. Generally you would want to have also an reset witch would assign some initial value to the output…
More over you can build a chain of shaders each of them would read “Output” and add something to it… And then you can disable and enable them or control amount on effect…
About timing I can’t really add much, it’s not compute shader related if you can provide some timing for effect and evolve it based on that great, if not, then you have to find way how to do that… or hack a way around…
Ah okay I understand that!Thanks for the good example. :) What I’m still not managing to do is to render the 1D Buffer output as two 3DTextures or Volumes.
So what I exactly want to do is:
Running a simualtion in a compute shader on a 3DTexture
Outputing two 3D Textures
Using one of the 3D Textures to put it into a framedelay(3DTexture) and feed it to the Compute Shader again
Using the other 3D Texture as the final Output. And turn it into an SDF and render it with Raymarching or use Marching Cubes to mesh it. But this part is already working. Just struggling to get the two 3DTextures out of the Compute Shader.
I’ll setup a little patch now to showcase my problem better if that helps.
Okay I’ll try that. I’m doing an example patch right now, and upload it if I can’t make it work now anyway. I’m just racking my brain at the moment on the line of code to pack back the 1D Buffer into the 3D Texture.
So the the way to get to 1D was:
uint idx = tid.x + tid.y * R.x + tid.z * (R.y * R.x);
Thank you, that really helped me out a lot! Think I got it working now in an example patch. Just have an “implication of vector type” error in the 1D to 3D shader, but it seems to work though.
I’ll try to implement it in the shader I actually want to use now, but that should work now.