Ignore:
Timestamp:
Feb 20, 2007 4:15:00 PM (17 years ago)
Author:
vrinside
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/vizservers/nanovis/VolumeRenderer.cpp

    r524 r580  
    3030}
    3131
    32 
    33 VolumeRenderer::~VolumeRenderer(){}
     32VolumeRenderer::~VolumeRenderer()
     33{
     34    delete m_zincBlendeShader;
     35    delete m_regularVolumeShader;
     36    delete m_volQDVolumeShader;
     37}
    3438
    3539//initialize the volume shaders
     
    4347
    4448  //volume rendering shader: one cubic volume
    45   m_one_volume_fprog = loadProgram(g_context, CG_PROFILE_FP30, CG_SOURCE, "/opt/nanovis/lib/shaders/one_volume.cg");
    46   m_vol_one_volume_param = cgGetNamedParameter(m_one_volume_fprog, "volume");
    47   //cgGLSetTextureParameter(m_vol_one_volume_param, _vol->id);
    48   m_tf_one_volume_param = cgGetNamedParameter(m_one_volume_fprog, "tf");
    49   //m_tf_cut_one_volume_param = cgGetNamedParameter(m_one_volume_fprog, "tf_cutplane");
    50   //cgGLSetTextureParameter(m_tf_one_volume_param, _tf->id);
    51   m_mvi_one_volume_param = cgGetNamedParameter(m_one_volume_fprog, "modelViewInv");
    52   m_mv_one_volume_param = cgGetNamedParameter(m_one_volume_fprog, "modelView");
    53   m_render_param_one_volume_param = cgGetNamedParameter(m_one_volume_fprog, "renderParameters");
    54 
    55 
     49  m_regularVolumeShader = new NvRegularVolumeShader();
    5650
    5751  //volume rendering shader: one zincblende orbital volume.
     
    6357  //The engine is already capable of rendering multiple volumes and combine them. Thus, we just invoke this shader on
    6458  //S, P, D and SS orbitals with different transfor functions. The result is a multi-orbital rendering.
    65   m_zincblende_volume_fprog = loadProgram(g_context, CG_PROFILE_FP30, CG_SOURCE,
    66                                         "/opt/nanovis/lib/shaders/zincblende_volume.cg");
    67 
    68   m_zincblende_tf_param = cgGetNamedParameter(m_zincblende_volume_fprog, "tf");
    69   m_zincblende_volume_a_param = cgGetNamedParameter(m_zincblende_volume_fprog, "volumeA");
    70   m_zincblende_volume_b_param = cgGetNamedParameter(m_zincblende_volume_fprog, "volumeB");
    71   m_zincblende_cell_size_param = cgGetNamedParameter(m_zincblende_volume_fprog, "cellSize");
    72   m_zincblende_mvi_param = cgGetNamedParameter(m_zincblende_volume_fprog, "modelViewInv");
    73   m_zincblende_render_param = cgGetNamedParameter(m_zincblende_volume_fprog, "renderParameters");
    74 
     59  m_zincBlendeShader = new NvZincBlendeVolumeShader();
     60
     61  m_volQDVolumeShader = new NvVolQDVolumeShader();
    7562}
    7663
     
    125112
    126113
    127 void VolumeRenderer::render_all(){
     114void VolumeRenderer::render_all()
     115{
    128116  int total_rendered_slices = 0;
    129117
     
    239227
    240228    ConvexPolygon static_poly;
    241     for(int i=0; i<volume[volume_index]->get_cutplane_count(); i++){
     229    for(int i=0; i<volume[volume_index]->get_cutplane_count(); i++)
     230    {
    242231      if(!volume[volume_index]->cutplane_is_enabled(i))
    243232        continue;
     
    692681  {
    693682    //regular cubic volume
    694     //
    695 
    696     cgGLSetStateMatrixParameter(m_mvi_one_volume_param, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_INVERSE);
    697     cgGLSetStateMatrixParameter(m_mv_one_volume_param, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY);
    698     cgGLSetTextureParameter(m_vol_one_volume_param, volume[volume_index]->id);
    699     cgGLSetTextureParameter(m_tf_one_volume_param, tf[volume_index]->id);
    700     //cgGLSetTextureParameter(m_tf_cut_one_volume_param, tf_cut[volume_index]->id);
    701     cgGLEnableTextureParameter(m_vol_one_volume_param);
    702     cgGLEnableTextureParameter(m_tf_one_volume_param);
    703     //cgGLEnableTextureParameter(m_tf_cut_one_volume_param);
    704 
    705     if(!slice_mode)
    706       cgGLSetParameter4f(m_render_param_one_volume_param,
    707                   volume[volume_index]->get_n_slice(),
    708                   volume[volume_index]->get_opacity_scale(),
    709                   volume[volume_index]->get_diffuse(),
    710                   volume[volume_index]->get_specular());
    711     else
    712       cgGLSetParameter4f(m_render_param_one_volume_param,
    713                   0.,
    714                   volume[volume_index]->get_opacity_scale(),
    715                   volume[volume_index]->get_diffuse(),
    716                   volume[volume_index]->get_specular());
    717 
    718     cgGLBindProgram(m_one_volume_fprog);
    719     cgGLEnableProfile(CG_PROFILE_FP30);
     683    m_regularVolumeShader->bind(tf[volume_index]->id, volume[volume_index], slice_mode);
    720684  }
    721685
    722686  else if (volume[volume_index]->volume_type == ZINCBLENDE)
    723687  {
    724     //zinc blende volume
    725     ZincBlendeVolume* vol = (ZincBlendeVolume*) volume[volume_index];
    726 
    727     cgGLSetStateMatrixParameter(m_zincblende_mvi_param, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_INVERSE);
    728     cgGLSetTextureParameter(m_zincblende_tf_param, tf[volume_index]->id);
    729     cgGLSetParameter4f(m_zincblende_cell_size_param, vol->cell_size.x, vol->cell_size.y, vol->cell_size.z, 0.);
    730 
    731     cgGLSetTextureParameter(m_zincblende_volume_a_param, vol->zincblende_tex[0]->id);
    732     cgGLSetTextureParameter(m_zincblende_volume_b_param, vol->zincblende_tex[1]->id);
    733     cgGLEnableTextureParameter(m_zincblende_volume_a_param);
    734     cgGLEnableTextureParameter(m_zincblende_volume_b_param);
    735 
    736     if(!slice_mode)
    737       cgGLSetParameter4f(m_zincblende_render_param,
    738                   vol->get_n_slice(),
    739                   vol->get_opacity_scale(),
    740                   vol->get_diffuse(),
    741                   vol->get_specular());
    742     else
    743       cgGLSetParameter4f(m_zincblende_render_param,
    744                   0.,
    745                   vol->get_opacity_scale(),
    746                   vol->get_diffuse(),
    747                   vol->get_specular());
    748 
    749     cgGLBindProgram(m_zincblende_volume_fprog);
    750     cgGLEnableProfile(CG_PROFILE_FP30);
    751 
    752   }
    753 }
    754 
    755 
    756 void VolumeRenderer::deactivate_volume_shader(){
     688    m_zincBlendeShader->bind(tf[volume_index]->id, volume[volume_index], slice_mode);
     689  }
     690  else if (volume[volume_index]->volume_type == VOLQD)
     691  {
     692    m_volQDVolumeShader->bind(tf[volume_index]->id, volume[volume_index], slice_mode);
     693  }
     694}
     695
     696
     697void VolumeRenderer::deactivate_volume_shader()
     698{
    757699  cgGLDisableProfile(CG_PROFILE_VP30);
    758   cgGLDisableProfile(CG_PROFILE_FP30);
    759 
    760   cgGLDisableTextureParameter(m_vol_one_volume_param);
    761   cgGLDisableTextureParameter(m_tf_one_volume_param);
    762 
    763   cgGLDisableTextureParameter(m_zincblende_volume_a_param);
    764   cgGLDisableTextureParameter(m_zincblende_volume_b_param);
    765   cgGLDisableTextureParameter(m_zincblende_tf_param);
     700
     701  m_regularVolumeShader->unbind();
     702  m_zincBlendeShader->unbind();
    766703}
    767704
Note: See TracChangeset for help on using the changeset viewer.