Cyclic cellular automata: my first DX11.TextureFX

Ahoj guys! Following the description I found here: I started dealing with this code. So far I did just the “Von Neumann” thing, and it works pretty well:

but I have some question:

  1. why I must hit the bang to let it start? it should start on opening the patch

  2. I used here a FrameDelay (DX11.Texture 2D) because need to apply the process again and again… there is a better way to implement this, inside the code I guess? I mean, how can I access to the previous texture output?

  3. I declare two constant array ( "int NNeigh(8) " and "float CoordNeigh(288) ") inside the main function (float4 pVonNeumann). There is a better place to put them?

Automata01.rar (3.3 kB)

well it’s pretty obvious in this case that u need to intialize the loop, since having nothing on the screen not gonna give u any result.
Don’t think u can simulate frame delay inside tfx yet.

sorry don’t understand, please be patient with me:
-in order to initialize the loop you should bang the “start” pin right?
-it isn’t the OnOpen (vvvv) supposed to do that when I open the patch?

It works if a put a FrameDelay (Value) after the OnOpen, I got it, but we got a bug here, or it is supposed to go this way?

just a guess u might need also to do this after framedelay texture is initialized e.g. second frame after patch started

1.) can be done by a texture switch to avoid the noise calculation in the CA code

2.) there was a semantic to allow access to the last texture in tfx but i think it never really worked, its correct how you did it

3.) this is the biggest performance drop in your shader, you should only calculate the neighbor offset once in tha vvvv patch and pass the values as buffer to the shader. this saves 288 divisions per pixel, which is 75.497.472 for a 512x512 texture… this was taking more performance as the whole cellular automata algorithm itself.

there was also a unnecessary texture coordinate conversion, if you use POINT mode for the sampler its more efficient and you don’t need the offset to the pixel center.

see patch:

cellular (10.5 kB)

hey cool!!! many many thanks, now I’ll play with this new info

BTW about 1) there’s something wrong with “calculation in the CA code” (about the performances)? Also I need to noise to be in the selected “Range” in order to process correctly the texture (I mean, if I have 6 states every pixel of the noise must be in one of this states)

about 3), there is no way to let the shader do a set of operation ONLY ONE TIME, right? Some kind of special function declaration perhaps?

there is nothing wrong with it only that it makes to code more complicated. and the noise does not have to be in one of the stages since
will quantize the values, so it does not matter whats the actual value as long as its between 0-0.99.

not that i know of… but i don’t know all the details about DX11.