SCM Repository
[diderot] Annotation of /trunk/test/vr.diderot
Annotation of /trunk/test/vr.diderot
Parent Directory
|
Revision Log
Revision 3064 -
(view)
(download)
1 : |
jhr |
36 |
// vr.diderot
|
2 : |
|
|
//
|
3 : |
|
|
// volume rendering example in Diderot
|
4 : |
|
|
//
|
5 : |
|
|
|
6 : |
jhr |
38 |
input string dataFile; // name of dataset
|
7 : |
|
|
input real stepSz; // size of steps
|
8 : |
jhr |
39 |
input vec<3> light;
|
9 : |
|
|
input int wid = 640;
|
10 : |
|
|
input int ht = 480;
|
11 : |
jhr |
36 |
|
12 : |
jhr |
2636 |
image[3] img = image (dataFile);
|
13 : |
jhr |
36 |
|
14 : |
jhr |
3064 |
field#1(3)[3] F = bspln3 ⊛ img;
|
15 : |
jhr |
39 |
|
16 : |
jhr |
511 |
strand RayCast (int row, int col)
|
17 : |
jhr |
38 |
{
|
18 : |
jhr |
39 |
vec<3> dir = (real(row), real(col), 0.0);
|
19 : |
|
|
vec<3> pos = (0.0, 0.0, 0.0);
|
20 : |
|
|
real t = 0.0;
|
21 : |
|
|
real[4] color = (0.0, 0.0, 0.0, 0.0);
|
22 : |
jhr |
38 |
|
23 : |
|
|
update
|
24 : |
|
|
{
|
25 : |
jhr |
39 |
vec<3> pt = pos + t*dir;
|
26 : |
|
|
t = t + stepSz;
|
27 : |
jhr |
3064 |
vec<3> g = (D F)(pt);
|
28 : |
|
|
color = over(color, phong(light, g, txf(F(pt))));
|
29 : |
jhr |
39 |
if (color[3] >= 0.999)
|
30 : |
|
|
stabilize;
|
31 : |
jhr |
38 |
}
|
32 : |
|
|
|
33 : |
|
|
}
|
34 : |
jhr |
40 |
|
35 : |
|
|
initially
|
36 : |
|
|
[ RayCast(r, c) | r in 0 .. ht-1, c in 0 .. wid-1 ];
|