1 | /* |
---|
2 | * ====================================================================== |
---|
3 | * AUTHOR: Wei Qiao <qiaow@purdue.edu> |
---|
4 | * Purdue Rendering and Perceptualization Lab (PURPL) |
---|
5 | * |
---|
6 | * Copyright (c) 2004-2006 Purdue Research Foundation |
---|
7 | * |
---|
8 | * See the file "license.terms" for information on usage and |
---|
9 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
10 | * ====================================================================== |
---|
11 | */ |
---|
12 | #include "common.cg" |
---|
13 | |
---|
14 | /* |
---|
15 | * render one volume |
---|
16 | */ |
---|
17 | PixelOut main(v2f IN, /* uniform sampler1D tf,*/ |
---|
18 | uniform sampler3D volume, |
---|
19 | uniform sampler1D tf, |
---|
20 | uniform float4x4 modelViewInv, |
---|
21 | uniform float4 renderParameters) |
---|
22 | { |
---|
23 | |
---|
24 | PixelOut OUT; |
---|
25 | float4 tex_coord = mul(modelViewInv, IN.TexCoord); |
---|
26 | |
---|
27 | if(renderParameters.y==1){ |
---|
28 | //1 component |
---|
29 | float sample = tex3D(volume, tex_coord.xyz); |
---|
30 | |
---|
31 | if (sample.x < 0.) { |
---|
32 | OUT.Color = float4(0.0, 0.0, 0.0, 0.0); |
---|
33 | } |
---|
34 | else{ |
---|
35 | //shades of red //more opaque |
---|
36 | OUT.Color = tex1D(tf, sample); |
---|
37 | OUT.Color.w = 10*OUT.Color.w/renderParameters.x; |
---|
38 | |
---|
39 | //OUT.Color = float4(sample, 0, 0, 7*sample/renderParameters.x); |
---|
40 | |
---|
41 | //if(sample<0.6 && sample>0.4){ |
---|
42 | //OUT.Color = float4(0, 0, 1, 10*sample/renderParameters.x); |
---|
43 | //} |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | else if(renderParameters.y==0){ |
---|
48 | |
---|
49 | //3 component |
---|
50 | float3 sample = tex3D(volume, tex_coord.xyz).xyz; |
---|
51 | |
---|
52 | OUT.Color = float4(3*sample, 2*length(sample)/renderParameters.x); |
---|
53 | } |
---|
54 | |
---|
55 | //debug |
---|
56 | //OUT.Color = float4(tex_coord, 1); |
---|
57 | |
---|
58 | return OUT; |
---|
59 | } |
---|