Changeset 524


Ignore:
Timestamp:
Sep 17, 2006 4:14:04 PM (18 years ago)
Author:
qiaow
Message:

Added ZincBlendeVolume? as a subclass of Volume.
Added shader to render zincblende volume.
Modified nanovis.cpp to handle render zincblende volume.

Need transfer protocle to actually pass two cubic volumes to create a ZincBlendeVolume?

Location:
trunk/gui/vizservers/nanovis
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/vizservers/nanovis/Makefile

    r467 r524  
    11OBJ_NANOVIS = nanovis.o Socket.o RenderVertexArray.o Plane.o ConvexPolygon.o Vector4.o Vector3.o Mat4x4.o \
    2                 Texture1D.o Texture3D.o Volume.o Texture2D.o ParticleSystem.o Sphere.o Color.o \
     2                Texture1D.o Texture3D.o Volume.o ZincBlendeVolume.o Texture2D.o ParticleSystem.o Sphere.o Color.o \
    33                PerfQuery.o TransferFunction.o ControlPoint.o ColorGradient.o ColorPaletteWindow.o\
    44                ColorGradientGLUTWindow.o TransferFunctionGLUTWindow.o MainWindow.o Event.o \
     
    1616INSTALL_DIR = /opt/nanovis
    1717
    18 LIB_NANOVIS = -ltcl8.3 -L/opt/render/lib -lGL -lglut -lglui -lGLEW -lCg -lCgGL -pthread -lstdc++
     18LIB_NANOVIS = -ltcl8.4 -L/opt/render/lib -lGL -lglut -lglui -lGLEW -lCg -lCgGL -pthread -lstdc++
    1919LIB_CLIENT = -L/opt/render/lib -lGL -lglut -pthread -lstdc++
    2020INCLUDES = -I../../src2/core -I/opt/render/include -I/autohome/u76/qiaow/Cg/usr/include
     
    108108        gcc $(CFLAG) Volume.cpp
    109109
     110ZincBlendeVolume.o: Volume.o ZincBlendeVolume.cpp ZincBlendeVolume.h $(AUXSRC)
     111        gcc $(CFLAG) ZincBlendeVolume.cpp
     112
    110113VolumeRenderer.o: $(OBJ_VOLUMERENDERER)  VolumeRenderer.h VolumeRenderer.cpp
    111114        gcc $(CFLAG) VolumeRenderer.cpp
  • trunk/gui/vizservers/nanovis/Volume.cpp

    r455 r524  
    3535        data_enabled(true), // default value
    3636        outline_enabled(true), // default value
    37         outline_color(1.,1.,1.) // default value
     37        outline_color(1.,1.,1.), // default value
     38        volume_type(CUBIC)      //by default, is a cubic volume
    3839{
    3940
  • trunk/gui/vizservers/nanovis/Volume.h

    r455 r524  
    3939
    4040
     41
     42enum {CUBIC, ZINCBLENDE};
     43
     44
    4145class Volume{
    4246       
    43 private:
     47
     48public:
     49        int volume_type;        //cubic or zincblende
     50
    4451        vector <CutPlane> plane; //cut planes
    4552        int n_components;
    4653
    4754        Texture3D* tex; //OpenGL texture storing the volume
    48     double vmin;    //minimum (unscaled) value in data
    49     double vmax;    //maximum (unscaled) value in data
     55        double vmin;    //minimum (unscaled) value in data
     56        double vmax;    //maximum (unscaled) value in data
    5057
    5158        float specular; //specular lighting parameter
     
    6067
    6168
    62 public:
     69
    6370        Vector3 location;
    6471
  • trunk/gui/vizservers/nanovis/VolumeRenderer.cpp

    r467 r524  
    4141  m_mvi_vert_std_param = cgGetNamedParameter(m_vert_std_vprog, "modelViewInv");
    4242
    43   //volume rendering shader
     43
     44  //volume rendering shader: one cubic volume
    4445  m_one_volume_fprog = loadProgram(g_context, CG_PROFILE_FP30, CG_SOURCE, "/opt/nanovis/lib/shaders/one_volume.cg");
    4546  m_vol_one_volume_param = cgGetNamedParameter(m_one_volume_fprog, "volume");
     
    5152  m_mv_one_volume_param = cgGetNamedParameter(m_one_volume_fprog, "modelView");
    5253  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
    5375}
    5476
     
    660682void VolumeRenderer::activate_volume_shader(int volume_index, bool slice_mode){
    661683
     684  //vertex shader
    662685  cgGLSetStateMatrixParameter(m_mvp_vert_std_param, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);
    663686  cgGLSetStateMatrixParameter(m_mvi_vert_std_param, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_INVERSE);
     
    665688  cgGLEnableProfile(CG_PROFILE_VP30);
    666689
    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,
    678707                  volume[volume_index]->get_n_slice(),
    679708                  volume[volume_index]->get_opacity_scale(),
    680709                  volume[volume_index]->get_diffuse(),
    681710                  volume[volume_index]->get_specular());
    682   else
    683     cgGLSetParameter4f(m_render_param_one_volume_param,
     711    else
     712      cgGLSetParameter4f(m_render_param_one_volume_param,
    684713                  0.,
    685714                  volume[volume_index]->get_opacity_scale(),
     
    687716                  volume[volume_index]->get_specular());
    688717
    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  }
    691753}
    692754
     
    698760  cgGLDisableTextureParameter(m_vol_one_volume_param);
    699761  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
    701768
    702769void VolumeRenderer::get_near_far_z(Mat4x4 mv, double &zNear, double &zFar)
  • trunk/gui/vizservers/nanovis/VolumeRenderer.h

    r455 r524  
    3232#include "Mat4x4.h"
    3333#include "Volume.h"
     34#include "ZincBlendeVolume.h"
    3435#include "PerfQuery.h"
    3536
     
    4849
    4950  //cg related
    50   CGcontext g_context;          //the Nvidia cg context
     51  CGcontext g_context;  //the Nvidia cg context
     52
     53  //shader parameters for rendering a single cubic volume
    5154  CGprogram m_one_volume_fprog;
    5255  CGparameter m_vol_one_volume_param;
     
    5659  CGparameter m_render_param_one_volume_param;
    5760
     61
     62  //Shader parameters for rendering a single zincblende orbital.
     63  //A simulation contains S, P, D and SS, total of 4 orbitals. A full rendering requires 4 zincblende orbital volumes.
     64  //A zincblende orbital volume is decomposed into two "interlocking" cubic volumes and passed to the shader.
     65  //We render each orbital with its own independent transfer functions then blend the result.
     66  //
     67  //The engine is already capable of rendering multiple volumes and combine them. Thus, we just invoke this shader on
     68  //S, P, D and SS orbitals with different transfor functions. The result is a multi-orbital rendering.
     69  //This is equivalent to rendering 4 unrelated data sets occupying the same space.
     70  CGprogram m_zincblende_volume_fprog;
     71  CGparameter m_zincblende_tf_param;  //four transfer functions
     72  CGparameter m_zincblende_volume_a_param, m_zincblende_volume_b_param; //two cubic volumes (one zincblende orbital)
     73  CGparameter m_zincblende_cell_size_param; //cell size in texture space
     74  CGparameter m_zincblende_mvi_param; //modelview inverse matrix
     75  CGparameter m_zincblende_render_param; //render parameters
     76 
     77 
     78  //standard vertex shader parameters
    5879  CGprogram m_vert_std_vprog;
    5980  CGparameter m_mvp_vert_std_param;
  • trunk/gui/vizservers/nanovis/nanovis.cpp

    r514 r524  
    494494        char **cmapv, **wmapv;
    495495
    496         if (Tcl_SplitList(interp, argv[3], &cmapc, &cmapv) != TCL_OK) {
     496        if (Tcl_SplitList(interp, argv[3], &cmapc, (const char***)&cmapv) != TCL_OK) {
    497497            return TCL_ERROR;
    498498        }
     
    504504        }
    505505
    506         if (Tcl_SplitList(interp, argv[4], &wmapc, &wmapv) != TCL_OK) {
     506        if (Tcl_SplitList(interp, argv[4], &wmapc, (const char***)&wmapv) != TCL_OK) {
    507507            return TCL_ERROR;
    508508        }
     
    608608
    609609    int sign = 1;
    610     char *axisName = argv[1];
     610    char *axisName = (char*)argv[1];
    611611    if (*axisName == '-') {
    612612        sign = -1;
     
    665665
    666666            int axis;
    667             if (GetAxis(interp, argv[3], &axis) != TCL_OK) {
     667            if (GetAxis(interp, (char*)argv[3], &axis) != TCL_OK) {
    668668                return TCL_ERROR;
    669669            }
     
    676676            vector<int>::iterator iter = ivol.begin();
    677677            while (iter != ivol.end()) {
    678                 volume[*iter]->set_label(axis, argv[4]);
     678                volume[*iter]->set_label(axis, (char*)argv[4]);
    679679                ++iter;
    680680            }
     
    864864            }
    865865
    866             TransferFunction *tf = get_transfunc(argv[3]);
     866            TransferFunction *tf = get_transfunc((char*)argv[3]);
    867867            if (tf == NULL) {
    868868                Tcl_AppendResult(interp, "transfer function \"", argv[3],
     
    10801080    int rgbc;
    10811081    char **rgbv;
    1082     if (Tcl_SplitList(interp, str, &rgbc, &rgbv) != TCL_OK) {
     1082    if (Tcl_SplitList(interp, str, &rgbc, (const char***)&rgbv) != TCL_OK) {
    10831083        return TCL_ERROR;
    10841084    }
  • trunk/gui/vizservers/nanovis/shaders/one_volume.cg

    r451 r524  
    1818
    1919
    20 PixelOut main(v2f IN, /* uniform sampler1D tf,*/
     20PixelOut main(v2f IN,
    2121                uniform sampler3D volume,
    2222                uniform sampler1D tf,
Note: See TracChangeset for help on using the changeset viewer.