Changeset 416 for trunk/gui/vizservers/nanovis/shaders/one_volume.cg
- Timestamp:
- Apr 27, 2006, 12:52:42 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/vizservers/nanovis/shaders/one_volume.cg
r415 r416 18 18 19 19 20 //#define PHONG_SHADING21 22 20 PixelOut main(v2f IN, /* uniform sampler1D tf,*/ 23 21 uniform sampler3D volume, … … 30 28 PixelOut OUT; 31 29 float4 tex_coord = mul(modelViewInv, IN.TexCoord); 32 33 //if(renderParameters.y==1){ //1 component 30 float4 sample = tex3D(volume, tex_coord.xyz); 34 31 35 float4 sample = tex3D(volume, tex_coord.xyz); 32 //sample the transfer function texture 33 float4 color = tex1D(tf, sample.x); 36 34 37 #ifdef PHONG_SHADING 38 //lighting parameters 39 float3 normal; 40 if(length(sample.yzw)>0.0) 41 normal = normalize(sample.yzw); 35 if(renderParameters.x < 0.5) 36 { //If single slice render, only flat shading, completely opaque. 37 color.w = 1; 38 //color.w = renderParameters.y*color.w/renderParameters.x; 39 } 40 else 41 { //regular volume rendering, we do PHONG SHADING 42 42 43 float3 light_vector = normalize(IN.Light); 44 float3 eye_vector = normalize(IN.EyeVector); 45 float3 half_vector = normalize(eye_vector+light_vector); 43 //lighting parameters 44 float3 normal; 45 if(length(sample.yzw)>0.0) 46 normal = normalize(sample.yzw); 46 47 47 #endif 48 float3 light_vector = normalize(IN.Light); 49 float3 eye_vector = normalize(IN.EyeVector); 50 float3 half_vector = normalize(eye_vector+light_vector); 48 51 49 //sample the transfer function texture 50 float4 color = tex1D(tf, sample.x); 51 //color.w = renderParameters.y*color.w/renderParameters.x; 52 //color.w = 0.5; 52 //lighting computation 53 float normal_dot_light = max(dot(normal, light_vector), 0); 54 float normal_dot_half = max(dot(normal, half_vector), 0); 53 55 54 //float4 color = float4(sample.x, 0, 0, 1); 55 56 float ambient = 0.1; 57 float diffuse = normal_dot_light * renderParameters.z; 58 float specular = pow(normal_dot_half, renderParameters.w)*(1-ambient-diffuse); 56 59 57 #ifdef PHONG_SHADING 58 //lighting computation 59 float normal_dot_light = max(dot(normal, light_vector), 0); 60 float normal_dot_half = max(dot(normal, half_vector), 0); 60 float lighting = ambient + diffuse + specular; 61 color.xyz = color.xyz * lighting; 62 } 61 63 62 float ambient = 0.1; 63 float diffuse = normal_dot_light * renderParameters.z; 64 float specular = pow(normal_dot_half, renderParameters.w)*(1-ambient-diffuse); 65 66 float lighting = ambient + diffuse + specular; 67 color.xyz = color.xyz * lighting; 68 69 //debug 70 //color.xyz = normal.xyz; //display normals 71 #endif 72 73 OUT.Color = color; 74 // } 75 76 /* 77 else if(renderParameters.y==0){ 78 //3 component 79 float3 sample = tex3D(volume, tex_coord.xyz).xyz; 80 OUT.Color = float4(3*sample, 2*length(sample)/renderParameters.x); 81 } 82 */ 83 64 OUT.Color = color; 84 65 //debug 85 66 //OUT.Color = float4(tex_coord, 1);
Note: See TracChangeset
for help on using the changeset viewer.