6 |
input string dataFile; // name of dataset |
input string dataFile; // name of dataset |
7 |
input real stepSz; // size of steps |
input real stepSz; // size of steps |
8 |
input vec3 lightDir; |
input vec3 lightDir; |
9 |
input vec3 lightCol; |
input vec3 lightRGB; |
10 |
input vec3 eye; // location of eye point |
input vec3 eye; // location of eye point |
11 |
input vec3 orig; // location of pixel (0,0) |
input vec3 orig; // location of pixel (0,0) |
12 |
input vec3 cVec; // vector between pixels horizontally |
input vec3 cVec; // vector between pixels horizontally |
13 |
input vec3 rVec; // vector between pixels vertically |
input vec3 rVec; // vector between pixels vertically |
14 |
input real pka; |
input real ka; |
15 |
input real pkd; |
input real kd; |
16 |
input real pks; |
input real ks; |
17 |
input real psh; |
input real sh; |
18 |
|
|
19 |
image(3)[] img = load (dataFile); |
image(3)[] img = load (dataFile); |
20 |
|
|
43 |
//// D : field -> field |
//// D : field -> field |
44 |
vec3 grad = (D F)@pos; |
vec3 grad = (D F)@pos; |
45 |
vec3 norm = grad/|grad|; |
vec3 norm = grad/|grad|; |
46 |
vec3 half = (lightDir - dir)/|lightDir - dir|; |
vec3 halfDir = (lightDir - dir)/|lightDir - dir|; |
47 |
vec4 matRGBA = txf@[val]; |
vec4 matRGBA = txf@[val]; |
48 |
vec3 matRGB = [matRGBA[0],matRGBA[1],matRGBA[2]]; |
vec3 matRGB = [matRGBA[0],matRGBA[1],matRGBA[2]]; |
49 |
//// dot : vec3 x vec3 -> real |
//// dot : vec3 x vec3 -> real |
55 |
//// + : vec3 x vec3 -> vec3 |
//// + : vec3 x vec3 -> vec3 |
56 |
//// pow : real x real -> real |
//// pow : real x real -> real |
57 |
vec3 pntRGB = (ka + kd*ldotn)*modulate(matRGB,lightRGB) + ks*pow(hdotn,psh)*lightRGB; |
vec3 pntRGB = (ka + kd*ldotn)*modulate(matRGB,lightRGB) + ks*pow(hdotn,psh)*lightRGB; |
58 |
rayRGB = rayRGB + rayTranps*matRGBA[3]*pntRGB; |
rayRGB = rayRGB + rayTransp*matRGBA[3]*pntRGB; |
59 |
//// * : real x real -> real |
//// * : real x real -> real |
60 |
//// - : real x real -> real |
//// - : real x real -> real |
61 |
rayTransp = rayTranps*(1.0 - matRGBA[3]); |
rayTransp = rayTransp*(1.0 - matRGBA[3]); |
62 |
} |
} |
63 |
//// > : real x real -> bool |
//// > : real x real -> bool |
64 |
//// < : real x real -> bool |
//// < : real x real -> bool |