Ignore:
Timestamp:
Apr 27, 2006, 12:52:42 PM (18 years ago)
Author:
qiaow
Message:

More interface functions for manipulating cutplanes. Now multiple volumes with multiple cutplanes working!!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/vizservers/nanovis/shaders/one_volume.cg

    r415 r416  
    1818
    1919
    20 //#define PHONG_SHADING
    21 
    2220PixelOut main(v2f IN, /* uniform sampler1D tf,*/
    2321                uniform sampler3D volume,
     
    3028  PixelOut OUT;
    3129  float4 tex_coord = mul(modelViewInv, IN.TexCoord);
    32        
    33 //if(renderParameters.y==1){ //1 component
     30  float4 sample = tex3D(volume, tex_coord.xyz);
    3431
    35     float4 sample = tex3D(volume, tex_coord.xyz);
     32  //sample the transfer function texture
     33  float4 color = tex1D(tf, sample.x);
    3634
    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
    4242
    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);
    4647
    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);
    4851
    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);
    5355
    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);
    5659
    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  }
    6163
    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;
    8465  //debug
    8566  //OUT.Color = float4(tex_coord, 1);
Note: See TracChangeset for help on using the changeset viewer.