https://www.qb64.org/forum/index.php?topic=2102.15@bplus, awesome plasma, like the 3D shader effect a lot. Does the pattern repeat after a while, or it is completley random/fractaloid? I don't know a lot about this kind of math.
Hi Dajan,
I hope you don't mind my answering here in thread where I've been working on this effect. I confess I don't quite get the math yet either.
The program I translated and modified looked like this (plasmajvsh.bas from SmallBASIC code library,
http://smallbasic.github.io/pages/samples.html'Plasma generator
'This program creates a plasma surface, which looks oily or silky.
r=rnd:g=rnd:b=rnd
for n=1 to 5
r1=r:g1=g:b1=b
repeat:r=rnd:until abs(r-r1)>.3
repeat:g=rnd:until abs(g-g1)>.3
repeat:b=rnd:until abs(g-g1)>.3
for m=0 to 17:m1=17-m
f1=(m*r)/18:f2=(m*g)/18:f3=(m*b)/18:c << rgbf(f1,f2,f3)
next
for m=0 to 17:m1=17-m
f1=(m+m1*r)/18:f2=(m+m1*g)/18:f3=(m+m1*b)/18:c << rgbf(f1,f2,f3)
next
for m=0 to 17:m1=17-m
f1=(m1+m*r)/18:f2=(m1+m*g)/18:f3=(m1+m*b)/18:c << rgbf(f1,f2,f3)
next
for m=0 to 17:m1=17-m
f1=(m1*r)/18:f2=(m1*g)/18:f3=(m1*b)/18:c << rgbf(f1,f2,f3)
next
next
for n=1 to 6
p << [rnd*xmax,rnd*ymax]
f << rnd*.1
next n
for y=0 to ymax-1 step 2
for x=0 to xmax-1 step 2
d=0
for n=0 to 5
k=sqr((x-p(n)(0))^2+(y-p(n)(1))^2)
d =d+(sin(k*f(n))+1)/2
next n:d=d*60
rect x,y step 2,2 color c(d) filled
next x
next y
The first part generates a color palette c(), the 2nd block generates 6 random points and the 3rd block draws a screen full of plasma colors based on distances from the 6 points.
When that program was made it did not go nearly as fast as it can now days with 64 bit processing so I had idea to show moving plasma by moving those 6 points around the screen:
'points structure
...
'new points startup
p
(n
).x
= RND * xmax: p
(n
).y
= RND * ymax: p
(n
).dx
= RND * 2 - 1: p
(n
).dy
= RND * 2 - 1...
'move points
p(i).x = p(i).x + p(i).dx
IF p
(i
).x
> xmax
OR p
(i
).x
< 0 THEN p
(i
).dx
= -p
(i
).dx
p(i).y = p(i).y + p(i).dy
IF p
(i
).y
> ymax
OR p
(i
).y
< 0 THEN p
(i
).dy
= -p
(i
).dy
The "shader" effect comes from the palette generation. Since the points are moving around on screen it is possible to repeat a pattern, that probablility is unlikely, how unlikely? Ask STxAxTIC it's crazy big math! ;-))
Notice "ectoplasm" the first post in this thread works on the same principle and I did half baked repeating method to move it around a bit.
But last night was the inspired real plasma effect!