Last active
March 5, 2016 02:36
-
-
Save JohnnyonFlame/4333be72436e29611769 to your computer and use it in GitHub Desktop.
Software water rendering in EVALDRAW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
() | |
{ | |
sleep(33); | |
cls(0); | |
Double p[3] = {-128, 0, 32}; | |
proj = (xres/2) / tan(rad(70/2)); | |
ang = 0; | |
for (i=0; i<yres/2 + 100; i++) | |
{ | |
setcol(180*(i/100), 200*(i/170), 200); | |
moveto(0, i); | |
lineto(xres, i); | |
} | |
for (col=-xres/2; col < xres/2; col+=2) | |
{ | |
px = p[0]; | |
py = p[1]; | |
ly = yres/2; | |
a = atan2(proj, col); | |
c = cos(a); | |
s = sin(a); | |
px += c*8; | |
py += s*8; | |
for(i=0; i<100; i++) | |
{ | |
px += c/2; | |
py += s/2; | |
dis = d(p[0], p[1], px, py); | |
nf = numframes/50; | |
seax = px / 4; | |
seay = py / 4; | |
h1 = noise(seax+nf, seay+nf); | |
h2 = noise(-seay+nf, seax+nf); | |
//h = pow(2.7182818, h1-h2)*32; | |
h = sqrt(h1*h1 + h2*h2)*32; | |
h += noise(px-nf, py-nf)*4; | |
sh = (proj * (p[2]+(h/2))) / dis; | |
if (ly>sh) | |
{ | |
setcol(10, 40, min(100-dis/20, 100)); | |
moveto(col+(xres/2), ly + (yres/2)); | |
lineto(col+(xres/2), sh + (yres/2)); | |
moveto(col+(xres/2)+1, ly + (yres/2)); | |
lineto(col+(xres/2)+1, sh + (yres/2)); | |
fade = 2*max(0, (180 - abs(col) + (16-h*8))/130); | |
r = 80+ dis/3; | |
g = 12+ dis/7; | |
r = r+r*max(0, fade); | |
g = g*max(0, fade); | |
setcol(r, g, 110); | |
setpix(col+xres/2, sh+yres/2); | |
setpix(col+xres/2-3, sh+yres/2); | |
setpix(col+xres/2, sh+yres/2+3); | |
setpix(col+xres/2-3, sh+yres/2+3); | |
ly = sh; | |
} | |
} | |
} | |
refresh(); | |
} | |
d(x1, y1, x2, y2) | |
{ | |
dx = (x2-x1); | |
dy = (y2-y1); | |
return dx*dx + dy*dy; | |
} | |
rad(a) | |
{ | |
return a * pi / 180; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment