How to create a checker board with DynamicTexture

Hi there,

so I got a few nice things going with VVVV but I still have some basic problems regarding spreads. I am pretty experienced in textual programming but there are many things where I just don’t know how to create it in VVVV.

So for a start, just as an exercise, I wanted to create a checkerboard texture using DynamicTexture. How would I do that? Feeding the texture with a linear spread with 0s and 1s? Creating a two-dimensional spread with cross? Does _cross_even return something that is similar to a two dimensional Array?

There are a few other question that may follow, but for now I just want a simple solution for this problem.

Cheers,
Tapete

hi,
i just did it with 2 I (Spreads), a GetSpread (Spreads) and a GetSlice (Spreads).
i first created the even and the uneven row and simply selected them afterwards with getslice and a binsize of the column count. i can give you the patch if you want to…

if the column count is an odd number its just filling black and white in the texture and let vvvvs spread modulo repeat it:

odd_checker.v4p (5.8 kB)

@Elias: Can you upload the patch? I tried to do it your way but I don’t quite understand how to use GetSpread and GetSlice to choose between the two ISpreads. BTW: What is the difference between GetSlice with a bin size of 3 and GetSpread with a count of 3?

@tonfilm: thanks, i tried it your way too, but i didn’t know about the filter-node!

Okay, so my next question would be: How do I draw a circle in a texture?
First thought would be to use CircularSpread. But how do I convert the X and the Y to one value again to connect it to the DynamicTexture?!

you could use the circularspread outputs to build your indicies

you’ll get gaps / overpopulation though as your spreadcount needs to exactly match the amount of pixels whilst having the same dispersion as them.
anyway, you’ll instantly see what i mean when you do:

circularspread x,y
A=x+ywidth
setslice(input=select(0,width
height), value=1, index=A)

p.s. i’m having trouble thinking of a situation where you might ever want to do that.

other (more stable but performance intensive) method is:

use points2vector to find the radius of a point B from point A
set point A to be center of your circle
input all the pixel positions as point B
then you’ll have a spread of all the disances of B from A

for a circle, you want to draw a locus around A, such that the radii are equal.
so compare the radius’ that come out of points2vector against a constant radius using the ‘= (Value)’ node. Use the ‘Epsilon’ to give thickness to your circle’s line. By default this will be 0, so you’ll need to increase it.

You’d be best looking at GDI renderer help patches if you want to draw circles in that way.

But i think you’re just trying to learn spread maths?

sorry for the extremely untidy patch

circle.v4p (11.8 kB)

Do you actually have to use DynamicTexture for some reason or could you just use a renderer to render a texture instead?

Thanks sugokuGENKI, I tried to program the other solution you described. But it doesn’t work. Seems like the Index Values are wrong. Could you take a look at this patch?

There is no particular reason why I need to use DynamicTexture. I think it’s just a good excercise because I have some other problems related to my misunderstanding of spreads.

I think the next good excercise would be a “game of life” texture. ;)

circletest.v4p (9.0 kB)

If you patch game of life I’ll promise to tidy up and release my general binary cellular automata plugin and effect :)

I found out myself how to do it. The problem was that i had to convert the values to integers first. I think I’m finally getting it. ;)

circle.v4p (14.8 kB)

@beyon: i remember that long ago someone did patch conway’s game of life. you should; there is also the shader version of @mrbenefit.

so it should be no problem to share your general binary cellular automata plugin and effect :)
i’m really curios about that…

@kalle
I will share, just need to spend some time with the plug-in mostly, probably port it to a dynamic V2 one. Having some problem with a possible help patch not working in beta >=24 though: http://vvvv.org/forum/queue-and-buffer-combined-with-texture-plugin-dont-work

Actually you just made me remember that my shader is based on that of mrbenefit just that I made a generic version with death/birth rule inputs.

@dietapete:
sorry for the late replay, here’s my solution.

checker_board_dyn_tex.v4p (5.9 kB)

@elias: no need for the getslice at the end.
your i+getspread combo is enough. nice way doing this!

The I + GetSpread is indeed very nice - I learned something :)

So it basically comes down to 2 nodes now! The idea with the offset is quite nice! Thanks.