Changeset 378 for trunk/gui/vizservers


Ignore:
Timestamp:
Mar 27, 2006, 6:56:57 AM (18 years ago)
Author:
mmc
Message:

Fixed loading of SQUALID-2D data.

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

Legend:

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

    r274 r378  
    2222
    2323
    24 ParticleSystem::ParticleSystem(int w, int h, CGcontext context, NVISid volume){
     24ParticleSystem::ParticleSystem(int w, int h, CGcontext context, NVISid volume, float scale_x,
     25                float scale_y, float scale_z){
     26
     27  fprintf(stderr, "%f, %f, %f\n", scale_x, scale_y, scale_z);
    2528
    2629  psys_width = w;
     
    3033  reborn = true;
    3134  flip = true;
    32   max_life = 30;
     35  max_life = 100;
    3336
    3437  data = (Particle*) malloc(w*h*sizeof(Particle));
     
    6669  m_vel_tex_param = cgGetNamedParameter(m_pos_fprog, "vel_tex");
    6770  m_pos_tex_param = cgGetNamedParameter(m_pos_fprog, "pos_tex");
     71  m_scale_param = cgGetNamedParameter(m_pos_fprog, "scale");
    6872  cgGLSetTextureParameter(m_vel_tex_param, volume);
     73  cgGLSetParameter3f(m_scale_param, scale_x, scale_y, scale_z);
    6974
    7075  fprintf(stderr, "init_psys\n");
     
    131136
    132137     cgGLBindProgram(m_pos_fprog);
    133      cgGLSetParameter1f(m_pos_timestep_param, 0.1);
     138     cgGLSetParameter1f(m_pos_timestep_param, 0.05);
    134139     cgGLEnableTextureParameter(m_vel_tex_param);
    135140     cgGLSetTextureParameter(m_pos_tex_param, psys_tex[0]);
     
    159164
    160165     cgGLBindProgram(m_pos_fprog);
    161      cgGLSetParameter1f(m_pos_timestep_param, 0.1);
     166     cgGLSetParameter1f(m_pos_timestep_param, 0.05);
    162167     cgGLEnableTextureParameter(m_vel_tex_param);
    163168     cgGLSetTextureParameter(m_pos_tex_param, psys_tex[1]);
     
    200205  glDisable(GL_BLEND);
    201206
    202   glPointSize(0.5);
    203   glColor4f(.8,.8,.8,1.);
     207  //glPointSize(0.5);
     208  glPointSize(1.5);
     209  glColor4f(.1,.0,.3,1.);
    204210
    205211  m_vertex_array->SetPointer(0);
  • trunk/gui/vizservers/nanovis/ParticleSystem.h

    r274 r378  
    3434
    3535  Particle(){};
    36   Particle(float _x, float _y, float _z, float _life):
     36  Particle(float _x, float _y, float _z, float _life) :
    3737   x(_x), y(_y), z(_z), aux(_life){}
    3838};
     
    5656  CGcontext m_g_context;
    5757  CGprogram m_pos_fprog;
    58   CGparameter m_vel_tex_param, m_pos_tex_param;
     58  CGparameter m_vel_tex_param, m_pos_tex_param, m_scale_param;
    5959  CGparameter m_pos_timestep_param, m_pos_spherePos_param;
    6060
     
    6363  int psys_height;
    6464
    65   ParticleSystem(int w, int h, CGcontext context, NVISid vector_field);
     65  ParticleSystem(int w, int h, CGcontext context, NVISid vector_field,
     66                  float scalex, float scaley, float scalez);
    6667  ~ParticleSystem();
    6768  void initialize(Particle* data);
  • trunk/gui/vizservers/nanovis/nanovis.cpp

    r377 r378  
    2323#include "RpFieldPrism3D.h"
    2424
     25// forward declarations
     26void init_particles();
     27void makePatterns();
     28void get_slice_vectors();
     29
    2530ParticleSystem* psys;
    2631float psys_x=0.4, psys_y=0, psys_z=0;
     
    116121void load_volume(int index, int width, int height, int depth, int n_component, float* data);
    117122
    118 
    119 //load a vector field from file
    120 void init_vector_field(){
    121 
    122   FILE* fp = fopen("./data/tornado_64x64x64.raw", "rb");
    123   assert(fp!=0);
    124 
    125   float* data = new float[64*64*64*3];
    126   for(int j=0; j<64*64*64*3; j++){
    127        fread(data + j, 4, 1, fp);
    128        //fprintf(stderr, "%f ", data[3*j+i]);
    129   }
    130   fclose(fp);
    131 
    132   //normalize data
    133   float _max = FLT_MIN;
    134   float _min = FLT_MAX;
    135 
    136   for(int j=0; j<64*64*64; j++){
    137     float mag = sqrt(data[j*3]*data[j*3] + data[j*3+1]*data[j*3+1] + data[j*3+2]*data[j*3+2]);
    138     if(mag > _max)
    139       _max = mag;
    140     if(mag < _min)
    141       _min = mag;
    142   }
    143 
    144   fprintf(stderr, "max=%f, min=%f\n", _max, _min);
    145 
    146   float scale = _max - _min;
    147  
    148   for(int j=0; j<64*64*64*3; j++){
    149     data[j]=data[j]/scale;
     123/* Load a 3D vector field from a dx-format file
     124 */
     125void
     126load_vector_file(int index, char *fname) {
     127    int dummy, nx, ny, nz, nxy, npts;
     128    double x0, y0, z0, dx, dy, dz, ddx, ddy, ddz;
     129    char line[128], type[128], *start;
     130    std::ifstream fin(fname);
     131
     132    do {
     133        fin.getline(line,sizeof(line)-1);
     134        for (start=&line[0]; *start == ' ' || *start == '\t'; start++)
     135            ;  // skip leading blanks
     136
     137        if (*start != '#') {  // skip comment lines
     138            if (sscanf(start, "object %d class gridpositions counts %d %d %d", &dummy, &nx, &ny, &nz) == 4) {
     139                // found grid size
     140            }
     141            else if (sscanf(start, "origin %lg %lg %lg", &x0, &y0, &z0) == 3) {
     142                // found origin
     143            }
     144            else if (sscanf(start, "delta %lg %lg %lg", &ddx, &ddy, &ddz) == 3) {
     145                // found one of the delta lines
     146                if (ddx != 0.0) { dx = ddx; }
     147                else if (ddy != 0.0) { dy = ddy; }
     148                else if (ddz != 0.0) { dz = ddz; }
     149            }
     150            else if (sscanf(start, "object %d class array type %s shape 3 rank 1 items %d data follows", &dummy, type, &npts) == 3) {
     151                if (npts != nx*ny*nz) {
     152                    std::cerr << "inconsistent data: expected " << nx*ny*nz << " points but found " << npts << " points" << std::endl;
     153                    return;
     154                }
     155                break;
     156            }
     157        }
     158    } while (!fin.eof());
     159
     160    // read data points
     161    if (!fin.eof()) {
     162        Rappture::Mesh1D xgrid(x0, x0+nx*dx, nx);
     163        Rappture::Mesh1D ygrid(y0, y0+ny*dy, ny);
     164        Rappture::Mesh1D zgrid(z0, z0+nz*dz, nz);
     165        Rappture::FieldRect3D xfield(xgrid, ygrid, zgrid);
     166        Rappture::FieldRect3D yfield(xgrid, ygrid, zgrid);
     167        Rappture::FieldRect3D zfield(xgrid, ygrid, zgrid);
     168
     169        double vx, vy, vz;
     170        int nread = 0;
     171        for (int ix=0; ix < nx; ix++) {
     172            for (int iy=0; iy < ny; iy++) {
     173                for (int iz=0; iz < nz; iz++) {
     174                    if (fin.eof() || nread > npts) {
     175                        break;
     176                    }
     177                    fin.getline(line,sizeof(line)-1);
     178                    if (sscanf(line, "%lg %lg %lg", &vx, &vy, &vz) == 3) {
     179                        int nindex = iz*nx*ny + iy*nx + ix;
     180                        xfield.define(nindex, vx);
     181                        yfield.define(nindex, vy);
     182                        zfield.define(nindex, vz);
     183                        nread++;
     184                    }
     185                }
     186            }
     187        }
     188
     189        // make sure that we read all of the expected points
     190        if (nread != nx*ny*nz) {
     191            std::cerr << "inconsistent data: expected " << nx*ny*nz << " points but found " << nread << " points" << std::endl;
     192            return;
     193        }
     194
     195        // figure out a good mesh spacing
     196        int nsample = 30;
     197        dx = xfield.rangeMax(Rappture::xaxis) - xfield.rangeMin(Rappture::xaxis);
     198        dy = xfield.rangeMax(Rappture::yaxis) - xfield.rangeMin(Rappture::yaxis);
     199        dz = xfield.rangeMax(Rappture::zaxis) - xfield.rangeMin(Rappture::zaxis);
     200        double dmin = pow((dx*dy*dz)/(nsample*nsample*nsample), 0.333);
     201
     202        nx = (int)ceil(dx/dmin);
     203        ny = (int)ceil(dy/dmin);
     204        nz = (int)ceil(dz/dmin);
    150205
    151206#ifndef NV40
    152     //cut negative values
    153     if(data[j]<0)
    154       data[j]=0;
     207        nx = pow(2.0, ceil(log10((double)nx)/log10(2.0)));  // must be an even power of 2
     208        ny = pow(2.0, ceil(log10((double)ny)/log10(2.0)));
     209        nz = pow(2.0, ceil(log10((double)nz)/log10(2.0)));
    155210#endif
    156   }
    157 
    158   /*
    159   for(int j=0; j<64*64*64; j++)
    160     fprintf(stderr, "[%f, %f, %f]\t", data[j*3], data[j*3+1], data[j*3+2]);
    161   */
    162 
    163   //load the vector field as a volume
    164   load_volume(0, 64, 64, 64, 3, data);
    165   n_volumes++;
    166   delete[] data;
    167 
    168   fprintf(stderr, "init_vector_field\n");
    169 }
     211
     212        float *data = new float[3*nx*ny*nz];
     213
     214        std::cout << "generating " << nx << "x" << ny << "x" << nz << " = " << nx*ny*nz << " points" << std::endl;
     215
     216        // generate the uniformly sampled data that we need for a volume
     217        double vmin = 0.0;
     218        double vmax = 0.0;
     219        int ngen = 0;
     220        for (int iz=0; iz < nz; iz++) {
     221            double zval = z0 + iz*dmin;
     222            for (int iy=0; iy < ny; iy++) {
     223                double yval = y0 + iy*dmin;
     224                for (int ix=0; ix < nx; ix++) {
     225                    double xval = x0 + ix*dmin;
     226
     227                    vx = xfield.value(xval,yval,zval);
     228                    vy = yfield.value(xval,yval,zval);
     229                    vz = zfield.value(xval,yval,zval);
     230                    //vx = 1;
     231                    //vy = 1;
     232                    vz = 0;
     233                    double vm = sqrt(vx*vx + vy*vy + vz*vz);
     234
     235                    if (vm < vmin) { vmin = vm; }
     236                    if (vm > vmax) { vmax = vm; }
     237
     238                    data[ngen++] = vx;
     239                    data[ngen++] = vy;
     240                    data[ngen++] = vz;
     241                }
     242            }
     243        }
     244
     245        ngen = 0;
     246        for (ngen=0; ngen < npts; ngen++) {
     247            data[ngen] = (data[ngen]/(2.0*vmax) + 0.5);
     248        }
     249
     250        load_volume(index, nx, ny, nz, 3, data);
     251        delete [] data;
     252    } else {
     253        std::cerr << "WARNING: data not found in file " << fname << std::endl;
     254    }
     255}
     256
    170257
    171258/* Load a 3D volume from a dx-format file
     
    270357            double dval;
    271358            int nread = 0;
    272             while (!fin.eof() && nread < npts) {
    273                 if (!(fin >> dval).fail()) {
    274                     field.define(nread++, dval);
     359            for (int ix=0; ix < nx; ix++) {
     360                for (int iy=0; iy < ny; iy++) {
     361                    for (int iz=0; iz < nz; iz++) {
     362                        if (fin.eof() || nread > npts) {
     363                            break;
     364                        }
     365                        fin.getline(line,sizeof(line)-1);
     366                        if (sscanf(line, "%lg", &dval) == 1) {
     367                            int nindex = iz*nx*ny + iy*nx + ix;
     368                            field.define(nindex, dval);
     369                            nread++;
     370                        }
     371                    }
    275372                }
    276373            }
     
    532629    m_mvi_vert_std_param = cgGetNamedParameter(m_vert_std_vprog, "modelViewInv");
    533630
     631/*
    534632    m_pos_fprog = loadProgram(g_context, CG_PROFILE_FP30, CG_SOURCE, "./shaders/update_pos.cg");
    535633    m_pos_timestep_param  = cgGetNamedParameter(m_pos_fprog, "timestep");
     
    537635    m_pos_tex_param = cgGetNamedParameter(m_pos_fprog, "pos_tex");
    538636    cgGLSetTextureParameter(m_vel_tex_param, volume[0]->id);
     637*/
     638 
    539639
    540640    m_render_vel_fprog = loadProgram(g_context, CG_PROFILE_FP30, CG_SOURCE, "./shaders/render_vel.cg");
     
    602702      int index = i + psys->psys_height*j;
    603703      bool particle = rand() % 256 > 100;
     704      particle = true;
    604705      if(particle)
    605706      {
    606         data[4*index] = psys_x;
    607         data[4*index+1]= i/float(psys->psys_width);
    608         data[4*index+2]= j/float(psys->psys_height);
    609         data[4*index+3]= 30;   
     707        //assign any location (x,y,z) in range [0,1]
     708        data[4*index] = 0.5;
     709        data[4*index+1]= j/float(psys->psys_height);
     710        data[4*index+2]= lic_slice_z; //lic_slice_z; //i/float(psys->psys_width);
     711        data[4*index+3]= 30; //shorter life span, quicker iterations   
    610712      }
    611713      else
     
    627729
    628730
    629 void makePatterns();
    630 void get_slice_vectors();
    631731
    632732
     
    680780   //load_volume_file(0, "./data/test2.dx");
    681781
     782   load_vector_file(0, "./data/J-wire-vec.dx");
     783   load_volume_file(1, "./data/mu-wire-3d.dx");
     784
    682785   init_fbo();  //frame buffer objects
    683786   init_cg();   //init cg shaders
     
    686789   switch_shader(cur_shader);
    687790
    688    //psys = new ParticleSystem(NMESH, NMESH, g_context, volume[0]->id);
    689    //init_particles();  //fill initial particles
    690 
    691    //get_slice_vectors();
     791   /*
     792   psys = new ParticleSystem(NMESH, NMESH, g_context, volume[0]->id,
     793                   1./volume[0]->aspect_ratio_width,
     794                   1./volume[0]->aspect_ratio_height,
     795                   1./volume[0]->aspect_ratio_depth);
     796   */
     797   psys = new ParticleSystem(NMESH, NMESH, g_context, volume[0]->id, 0.25, 1., 1.);
     798
     799   init_particles();    //fill initial particles
     800
     801   get_slice_vectors();
    692802}
    693803
     
    10851195   cgGLEnableProfile(CG_PROFILE_FP30);
    10861196   glBegin(GL_QUADS);
    1087     glTexCoord3f(0., 0., slice_z); glVertex2f(0.,         0.);
    1088     glTexCoord3f(1., 0., slice_z); glVertex2f((float)NMESH,     0.);
    1089     glTexCoord3f(1., 1., slice_z); glVertex2f((float)NMESH, (float)NMESH);
    1090     glTexCoord3f(0., 1., slice_z); glVertex2f((float)0.,    (float)NMESH);
     1197    glTexCoord3f(0., 0., lic_slice_z); glVertex2f(0.,         0.);
     1198    glTexCoord3f(1., 0., lic_slice_z); glVertex2f((float)NMESH,     0.);
     1199    glTexCoord3f(1., 1., lic_slice_z); glVertex2f((float)NMESH, (float)NMESH);
     1200    glTexCoord3f(0., 1., lic_slice_z); glVertex2f((float)0.,    (float)NMESH);
    10911201
    10921202    /*
     
    12221332
    12231333
    1224 void activate_one_volume_shader(int n_actual_slices){
     1334void activate_one_volume_shader(int volume_index, int n_actual_slices){
    12251335
    12261336  cgGLSetStateMatrixParameter(m_mvp_vert_std_param, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);
     
    12301340
    12311341  cgGLSetStateMatrixParameter(m_mvi_one_volume_param, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_INVERSE);
     1342  cgGLSetTextureParameter(m_vol_one_volume_param, volume[volume_index]->id);
    12321343  cgGLEnableTextureParameter(m_vol_one_volume_param);
    1233   cgGLSetParameter4f(m_render_param_one_volume_param, n_actual_slices, 0., 0., 0.);
     1344
     1345  //hack!
     1346  //if parameter.y == 0 : volume :0
     1347  //if parameter.y == 1 : volume :1
     1348  if(volume_index==0)
     1349    cgGLSetParameter4f(m_render_param_one_volume_param, n_actual_slices, 0., 0., 0.);
     1350  else if(volume_index==1)
     1351    cgGLSetParameter4f(m_render_param_one_volume_param, n_actual_slices, 1., 0., 0.);
    12341352  cgGLBindProgram(m_one_volume_fprog);
    12351353  cgGLEnableProfile(CG_PROFILE_FP30);
     
    12411359  cgGLDisableProfile(CG_PROFILE_FP30);
    12421360
    1243   cgGLDisableTextureParameter(m_vel_tex_param);
    1244   cgGLDisableTextureParameter(m_pos_tex_param);
     1361  cgGLEnableTextureParameter(m_vol_one_volume_param);
     1362  //cgGLDisableTextureParameter(m_vel_tex_param);
     1363  //cgGLDisableTextureParameter(m_pos_tex_param);
    12451364}
    12461365
     
    13641483    */
    13651484   
    1366     activate_one_volume_shader(n_actual_slices);
     1485    activate_one_volume_shader(volume_index, n_actual_slices);
    13671486    glPopMatrix();
    13681487
     
    15001619#endif
    15011620
     1621void draw_axis(){
     1622
     1623  glDisable(GL_TEXTURE_2D);
     1624  glEnable(GL_DEPTH_TEST);
     1625
     1626  //red x
     1627  glColor3f(1,0,0);
     1628  glBegin(GL_LINES);
     1629    glVertex3f(0,0,0);
     1630    glVertex3f(1.5,0,0);
     1631  glEnd();
     1632
     1633
     1634  //blue y
     1635  glColor3f(0,0,1);
     1636  glBegin(GL_LINES);
     1637    glVertex3f(0,0,0);
     1638    glVertex3f(0,1.5,0);
     1639  glEnd();
     1640
     1641
     1642  //green z
     1643  glColor3f(0,1,0);
     1644  glBegin(GL_LINES);
     1645    glVertex3f(0,0,0);
     1646    glVertex3f(0,0,1.5);
     1647  glEnd();
     1648
     1649  glEnable(GL_TEXTURE_2D);
     1650  glDisable(GL_DEPTH_TEST);
     1651}
     1652
     1653
    15021654
    15031655/*----------------------------------------------------*/
     
    15111663
    15121664   //convolve
    1513    //lic();
     1665   lic();
    15141666
    15151667   /*
     
    15271679   
    15281680   //advect particles
    1529    //psys->advect();
     1681   psys->advect();
    15301682
    15311683   final_fbo_capture();
     
    15471699   glMatrixMode(GL_MODELVIEW);
    15481700   glLoadIdentity();
    1549    //glTranslatef(live_obj_x, live_obj_y, live_obj_z);
    1550    glTranslatef(0, 0, live_obj_z);
     1701   glTranslatef(live_obj_x, live_obj_y, live_obj_z);
    15511702
    15521703   glRotated(live_rot_x, 1., 0., 0.);
     
    15541705   glRotated(live_rot_z, 0., 0., 1.);
    15551706
    1556    /*
     1707   
     1708   glPushMatrix();
     1709
     1710   glScaled(volume[0]->aspect_ratio_width,
     1711          volume[0]->aspect_ratio_height,
     1712          volume[0]->aspect_ratio_depth);
     1713
     1714   
    15571715   //draw line integral convolution quad
    15581716   glBegin(GL_QUADS);
    1559    glTexCoord2f(0, 0); glVertex3f(0, 0, slice_z);
    1560    glTexCoord2f(1, 0); glVertex3f(1, 0, slice_z);
    1561    glTexCoord2f(1, 1); glVertex3f(1, 1, slice_z);
    1562    glTexCoord2f(0, 1); glVertex3f(0, 1, slice_z);
     1717   glTexCoord2f(0, 0); glVertex3f(0, 0, lic_slice_z);
     1718   glTexCoord2f(1, 0); glVertex3f(1, 0, lic_slice_z);
     1719   glTexCoord2f(1, 1); glVertex3f(1, 1, lic_slice_z);
     1720   glTexCoord2f(0, 1); glVertex3f(0, 1, lic_slice_z);
    15631721   glEnd();
    1564    */
     1722   
     1723   glPopMatrix();
     1724   
    15651725
    15661726   //soft_display_verts();
    1567    //psys->display_vertices();
    1568 
    1569    //render multiple volumes
     1727   
     1728   glPushMatrix();
     1729
     1730   glScaled(volume[0]->aspect_ratio_width,
     1731          volume[0]->aspect_ratio_height,
     1732          volume[0]->aspect_ratio_depth);
     1733
     1734   psys->display_vertices();
     1735
     1736   glPopMatrix();
     1737
     1738   //render volume :0
    15701739   //volume[0]->location =Vector3(0.,0.,0.);
    15711740   //render_volume(0, 256);
    15721741
    1573    //render another but shifted using the same texture
    1574    volume[0]->location =Vector3(-0.5,-0.5,-0.5);
     1742   //render volume :1
     1743   volume[1]->location =Vector3(0., 0., 0.);
     1744   render_volume(1, 256);
    15751745
    15761746   perf->enable();
    1577    render_volume(0, 256);
    15781747   perf->disable();
    15791748   fprintf(stderr, "pixels: %d\n", perf->get_pixel_count());
    15801749   perf->reset();
     1750
     1751   draw_axis();
    15811752
    15821753   glDisable(GL_DEPTH_TEST);
     
    16521823                break;
    16531824        case '+':
    1654                 slice_z+=0.1;
     1825                lic_slice_z+=0.05;
    16551826                get_slice_vectors();
    16561827                break;
    16571828        case '-':
    1658                 slice_z-=0.1;
     1829                lic_slice_z-=0.05;
    16591830                get_slice_vectors();
    16601831                break;
     
    16671838        case '3':
    16681839                psys_x-=0.1;
     1840                break;
     1841        case 'w': //zoom out
     1842                live_obj_z-=0.1;
     1843                break;
     1844        case 's': //zoom in
     1845                live_obj_z+=0.1;
     1846                break;
     1847        case 'a': //left
     1848                live_obj_x-=0.1;
     1849                break;
     1850        case 'd': //right
     1851                live_obj_x+=0.1;
     1852                break;
     1853        case 'i':
     1854                init_particles();
    16691855                break;
    16701856        default:
  • trunk/gui/vizservers/nanovis/nanovis.h

    r377 r378  
    8787float live_rot_z = 0.;
    8888
    89 float live_obj_x = -0.5;        //object translation location from the origin
    90 float live_obj_y = -0.5;
     89float live_obj_x = -0.0;        //object translation location from the origin
     90float live_obj_y = -0.0;
    9191float live_obj_z = -2.5;
    9292
     
    9595bool right_down = false;
    9696
    97 float slice_x=0, slice_y=0, slice_z=0.3;        //image based flow visualization slice location
     97float lic_slice_x=0, lic_slice_y=0, lic_slice_z=0.3;//image based flow visualization slice location
    9898
    9999int win_width = NPIX;                   //size of the render window
  • trunk/gui/vizservers/nanovis/shaders/one_volume.cg

    r377 r378  
    2525  float4 tex_coord = mul(modelViewInv, IN.TexCoord);
    2626       
    27 #if 0
    28   //1 component
    29   float sample = tex3D(volume, tex_coord.xyz);
     27  if(renderParameters.y==1){
     28    //1 component
     29    float sample = tex3D(volume, tex_coord.xyz);
    3030
    31   if (sample.x < 0.) {
     31    if (sample.x < 0.) {
    3232      OUT.Color = float4(0.0, 0.0, 0.0, 0.0);
    33   } else {
    34       OUT.Color = float4(sample, sample, sample, sample/renderParameters.x);
     33    }
     34    else{
     35      //shades of red //more opaque
     36      OUT.Color = float4(sample, 0, 0, 7*sample/renderParameters.x);
     37
     38      if(sample<0.6 && sample>0.4){
     39        OUT.Color = float4(0, 0, 1, 10*sample/renderParameters.x);
     40      }
     41    }
    3542  }
    36 #endif
    3743
     44  else if(renderParameters.y==0){
    3845
    39 #if 1
    40   //3 component
    41   float3 sample = tex3D(volume, tex_coord.xyz).xyz;
    42   OUT.Color = float4(3*sample, 2*length(sample)/renderParameters.x);
    43 #endif
     46    //3 component
     47    float3 sample = tex3D(volume, tex_coord.xyz).xyz;
     48   
     49    OUT.Color = float4(3*sample, 2*length(sample)/renderParameters.x);
     50  }
    4451
    4552//debug
  • trunk/gui/vizservers/nanovis/shaders/render_vel.cg

    r226 r378  
    2727    ret.y = plane_normal.y * vel.y;
    2828    ret.z = plane_normal.z * vel.z;
    29 
    30     return float4(ret, 1);
     29   
     30    float3 tmp = ret*2.0 - float3(1,1,1);
     31    return float4(tmp, 1);
    3132}
  • trunk/gui/vizservers/nanovis/shaders/update_pos.cg

    r226 r378  
    1818            uniform samplerRECT pos_tex,
    1919            uniform sampler3D vel_tex,
    20             uniform float timestep
     20            uniform float timestep,
     21            uniform float3 scale
    2122            ) : COLOR
    2223{
     
    2829
    2930    float4 vel = float4(tex3D(vel_tex, pos.xyz).xyz, 0);
     31
     32    //reconstruct negative value
     33    vel = (vel - float4(0.5,0.5,0.5,0.))*2.;
     34    vel.x *= scale.x;
     35    vel.y *= scale.y;
     36    vel.z *= scale.z;
    3037    ret = pos + vel*timestep;
    31 
     38    //ret = pos;
    3239
    3340/*
     41    //not drawing if the particle is out of bound
    3442    if(ret.x<0 || ret.x>1 || ret.y<0 || ret.y>1 || ret.z<0 || ret.z>1 || time==0)
    3543      ret = float4(1,0,0,0);
    3644    else
    37       ret.w = time-1;
     45      ret.w = 1;
    3846*/
    3947
    40     ret.w = 1.0;
     48    ret.w = 1.;
    4149    return ret;
    4250}
Note: See TracChangeset for help on using the changeset viewer.