Changeset 524 for trunk/gui/vizservers/nanovis/VolumeRenderer.cpp
- Timestamp:
- Sep 17, 2006, 4:14:04 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/vizservers/nanovis/VolumeRenderer.cpp
r467 r524 41 41 m_mvi_vert_std_param = cgGetNamedParameter(m_vert_std_vprog, "modelViewInv"); 42 42 43 //volume rendering shader 43 44 //volume rendering shader: one cubic volume 44 45 m_one_volume_fprog = loadProgram(g_context, CG_PROFILE_FP30, CG_SOURCE, "/opt/nanovis/lib/shaders/one_volume.cg"); 45 46 m_vol_one_volume_param = cgGetNamedParameter(m_one_volume_fprog, "volume"); … … 51 52 m_mv_one_volume_param = cgGetNamedParameter(m_one_volume_fprog, "modelView"); 52 53 m_render_param_one_volume_param = cgGetNamedParameter(m_one_volume_fprog, "renderParameters"); 54 55 56 57 //volume rendering shader: one zincblende orbital volume. 58 //This shader renders one orbital of the simulation. 59 //A sim has S, P, D, SS orbitals. thus a full rendering requires 4 zincblende orbital volumes. 60 //A zincblende orbital volume is decomposed into 2 "interlocking" cubic 4-component volumes and passed to the shader. 61 //We render each orbital with a independent transfer functions then blend the result. 62 // 63 //The engine is already capable of rendering multiple volumes and combine them. Thus, we just invoke this shader on 64 //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 53 75 } 54 76 … … 660 682 void VolumeRenderer::activate_volume_shader(int volume_index, bool slice_mode){ 661 683 684 //vertex shader 662 685 cgGLSetStateMatrixParameter(m_mvp_vert_std_param, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY); 663 686 cgGLSetStateMatrixParameter(m_mvi_vert_std_param, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_INVERSE); … … 665 688 cgGLEnableProfile(CG_PROFILE_VP30); 666 689 667 cgGLSetStateMatrixParameter(m_mvi_one_volume_param, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_INVERSE); 668 cgGLSetStateMatrixParameter(m_mv_one_volume_param, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY); 669 cgGLSetTextureParameter(m_vol_one_volume_param, volume[volume_index]->id); 670 cgGLSetTextureParameter(m_tf_one_volume_param, tf[volume_index]->id); 671 //cgGLSetTextureParameter(m_tf_cut_one_volume_param, tf_cut[volume_index]->id); 672 cgGLEnableTextureParameter(m_vol_one_volume_param); 673 cgGLEnableTextureParameter(m_tf_one_volume_param); 674 //cgGLEnableTextureParameter(m_tf_cut_one_volume_param); 675 676 if(!slice_mode) 677 cgGLSetParameter4f(m_render_param_one_volume_param, 690 691 if (volume[volume_index]->volume_type == CUBIC) 692 { 693 //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, 678 707 volume[volume_index]->get_n_slice(), 679 708 volume[volume_index]->get_opacity_scale(), 680 709 volume[volume_index]->get_diffuse(), 681 710 volume[volume_index]->get_specular()); 682 else683 cgGLSetParameter4f(m_render_param_one_volume_param,711 else 712 cgGLSetParameter4f(m_render_param_one_volume_param, 684 713 0., 685 714 volume[volume_index]->get_opacity_scale(), … … 687 716 volume[volume_index]->get_specular()); 688 717 689 cgGLBindProgram(m_one_volume_fprog); 690 cgGLEnableProfile(CG_PROFILE_FP30); 718 cgGLBindProgram(m_one_volume_fprog); 719 cgGLEnableProfile(CG_PROFILE_FP30); 720 } 721 722 else if (volume[volume_index]->volume_type == ZINCBLENDE) 723 { 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 } 691 753 } 692 754 … … 698 760 cgGLDisableTextureParameter(m_vol_one_volume_param); 699 761 cgGLDisableTextureParameter(m_tf_one_volume_param); 700 } 762 763 cgGLDisableTextureParameter(m_zincblende_volume_a_param); 764 cgGLDisableTextureParameter(m_zincblende_volume_b_param); 765 cgGLDisableTextureParameter(m_zincblende_tf_param); 766 } 767 701 768 702 769 void VolumeRenderer::get_near_far_z(Mat4x4 mv, double &zNear, double &zFar)
Note: See TracChangeset
for help on using the changeset viewer.