Difference between revisions of "Eye"
From CodeStuff
| Line 3: | Line 3: | ||
<edcode> | <edcode> | ||
| + | |||
function drawEye() { | function drawEye() { | ||
| Line 57: | Line 58: | ||
//ring | //ring | ||
| − | var ri=smoothStep(e,.31,.35)-smoothStep(e,.35,.39); | + | var ri=smoothStep(e,0.31,0.35)-smoothStep(e,0.35,0.39); |
| − | + | ri=1-0.35*ri; | |
mixed=colsca(mixed,ri); | mixed=colsca(mixed,ri); | ||
| Line 77: | Line 78: | ||
} | } | ||
| − | function | + | function skinColor (x,y,b) { |
var rx=2*(x-0.5)*1.33; | var rx=2*(x-0.5)*1.33; | ||
var ry=2*(y-0.5); | var ry=2*(y-0.5); | ||
| Line 108: | Line 109: | ||
skin[2]*= 1- 0.17*pecas; | skin[2]*= 1- 0.17*pecas; | ||
| − | var g = smoothStep(1-b,0.2,0.7) | + | var g = smoothStep(1-b,0.2,0.7); |
g-= smoothStep(1-b,0.8,1)*3; | g-= smoothStep(1-b,0.8,1)*3; | ||
skin[0]+=g*0.1; | skin[0]+=g*0.1; | ||
| Line 135: | Line 136: | ||
var b=e; | var b=e; | ||
var eyeColor = eye(x,y,b); | var eyeColor = eye(x,y,b); | ||
| − | var | + | var skin = skinColor(x,y,b); |
| − | var mixed = mixColors(f,eyeColor, | + | var mixed = mixColors(f,eyeColor,skin); |
| − | red=mixed[0]; | + | var red=mixed[0]; |
| − | green=mixed[1]; | + | var green=mixed[1]; |
| − | blue=mixed[2]; | + | var blue=mixed[2]; |
if (red<0) red=0; | if (red<0) red=0; | ||
if (red>1) red=1; | if (red>1) red=1; | ||
| Line 166: | Line 167: | ||
} | } | ||
| − | for (ty=0;ty<400;ty++) { | + | for (var ty=0;ty<400;ty++) { |
i=0; | i=0; | ||
for (var tx=0;tx<533;tx++) { | for (var tx=0;tx<533;tx++) { | ||
| Line 176: | Line 177: | ||
} | } | ||
| − | function noise2(x,y,a,b) {return noise2d(x*a/256,y*b/256) | + | function noise2(x,y,a,b) {return noise2d(x*a/256,y*b/256);} |
| − | + | drawEye(); | |
| − | + | ||
| − | + | ||
</edcode> | </edcode> | ||
Latest revision as of 07:39, 23 July 2015
If you want to understand how this program works, you will have to spend a good number of hours going through it. This code is here not to show you how something works but rather what is possible. It seems unfathomable, but nevertheless someone wrote it. It has 180 lines of code, each component does something small and understandable. Working together they can achieve an almost magical result.