Changeset 378 for trunk/gui/vizservers
- Timestamp:
- Mar 27, 2006, 6:56:57 AM (18 years ago)
- Location:
- trunk/gui/vizservers/nanovis
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/vizservers/nanovis/ParticleSystem.cpp
r274 r378 22 22 23 23 24 ParticleSystem::ParticleSystem(int w, int h, CGcontext context, NVISid volume){ 24 ParticleSystem::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); 25 28 26 29 psys_width = w; … … 30 33 reborn = true; 31 34 flip = true; 32 max_life = 30;35 max_life = 100; 33 36 34 37 data = (Particle*) malloc(w*h*sizeof(Particle)); … … 66 69 m_vel_tex_param = cgGetNamedParameter(m_pos_fprog, "vel_tex"); 67 70 m_pos_tex_param = cgGetNamedParameter(m_pos_fprog, "pos_tex"); 71 m_scale_param = cgGetNamedParameter(m_pos_fprog, "scale"); 68 72 cgGLSetTextureParameter(m_vel_tex_param, volume); 73 cgGLSetParameter3f(m_scale_param, scale_x, scale_y, scale_z); 69 74 70 75 fprintf(stderr, "init_psys\n"); … … 131 136 132 137 cgGLBindProgram(m_pos_fprog); 133 cgGLSetParameter1f(m_pos_timestep_param, 0. 1);138 cgGLSetParameter1f(m_pos_timestep_param, 0.05); 134 139 cgGLEnableTextureParameter(m_vel_tex_param); 135 140 cgGLSetTextureParameter(m_pos_tex_param, psys_tex[0]); … … 159 164 160 165 cgGLBindProgram(m_pos_fprog); 161 cgGLSetParameter1f(m_pos_timestep_param, 0. 1);166 cgGLSetParameter1f(m_pos_timestep_param, 0.05); 162 167 cgGLEnableTextureParameter(m_vel_tex_param); 163 168 cgGLSetTextureParameter(m_pos_tex_param, psys_tex[1]); … … 200 205 glDisable(GL_BLEND); 201 206 202 glPointSize(0.5); 203 glColor4f(.8,.8,.8,1.); 207 //glPointSize(0.5); 208 glPointSize(1.5); 209 glColor4f(.1,.0,.3,1.); 204 210 205 211 m_vertex_array->SetPointer(0); -
trunk/gui/vizservers/nanovis/ParticleSystem.h
r274 r378 34 34 35 35 Particle(){}; 36 Particle(float _x, float _y, float _z, float _life) :36 Particle(float _x, float _y, float _z, float _life) : 37 37 x(_x), y(_y), z(_z), aux(_life){} 38 38 }; … … 56 56 CGcontext m_g_context; 57 57 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; 59 59 CGparameter m_pos_timestep_param, m_pos_spherePos_param; 60 60 … … 63 63 int psys_height; 64 64 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); 66 67 ~ParticleSystem(); 67 68 void initialize(Particle* data); -
trunk/gui/vizservers/nanovis/nanovis.cpp
r377 r378 23 23 #include "RpFieldPrism3D.h" 24 24 25 // forward declarations 26 void init_particles(); 27 void makePatterns(); 28 void get_slice_vectors(); 29 25 30 ParticleSystem* psys; 26 31 float psys_x=0.4, psys_y=0, psys_z=0; … … 116 121 void load_volume(int index, int width, int height, int depth, int n_component, float* data); 117 122 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 */ 125 void 126 load_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); 150 205 151 206 #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))); 155 210 #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 170 257 171 258 /* Load a 3D volume from a dx-format file … … 270 357 double dval; 271 358 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 } 275 372 } 276 373 } … … 532 629 m_mvi_vert_std_param = cgGetNamedParameter(m_vert_std_vprog, "modelViewInv"); 533 630 631 /* 534 632 m_pos_fprog = loadProgram(g_context, CG_PROFILE_FP30, CG_SOURCE, "./shaders/update_pos.cg"); 535 633 m_pos_timestep_param = cgGetNamedParameter(m_pos_fprog, "timestep"); … … 537 635 m_pos_tex_param = cgGetNamedParameter(m_pos_fprog, "pos_tex"); 538 636 cgGLSetTextureParameter(m_vel_tex_param, volume[0]->id); 637 */ 638 539 639 540 640 m_render_vel_fprog = loadProgram(g_context, CG_PROFILE_FP30, CG_SOURCE, "./shaders/render_vel.cg"); … … 602 702 int index = i + psys->psys_height*j; 603 703 bool particle = rand() % 256 > 100; 704 particle = true; 604 705 if(particle) 605 706 { 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 610 712 } 611 713 else … … 627 729 628 730 629 void makePatterns();630 void get_slice_vectors();631 731 632 732 … … 680 780 //load_volume_file(0, "./data/test2.dx"); 681 781 782 load_vector_file(0, "./data/J-wire-vec.dx"); 783 load_volume_file(1, "./data/mu-wire-3d.dx"); 784 682 785 init_fbo(); //frame buffer objects 683 786 init_cg(); //init cg shaders … … 686 789 switch_shader(cur_shader); 687 790 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(); 692 802 } 693 803 … … 1085 1195 cgGLEnableProfile(CG_PROFILE_FP30); 1086 1196 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); 1091 1201 1092 1202 /* … … 1222 1332 1223 1333 1224 void activate_one_volume_shader(int n_actual_slices){1334 void activate_one_volume_shader(int volume_index, int n_actual_slices){ 1225 1335 1226 1336 cgGLSetStateMatrixParameter(m_mvp_vert_std_param, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY); … … 1230 1340 1231 1341 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); 1232 1343 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.); 1234 1352 cgGLBindProgram(m_one_volume_fprog); 1235 1353 cgGLEnableProfile(CG_PROFILE_FP30); … … 1241 1359 cgGLDisableProfile(CG_PROFILE_FP30); 1242 1360 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); 1245 1364 } 1246 1365 … … 1364 1483 */ 1365 1484 1366 activate_one_volume_shader( n_actual_slices);1485 activate_one_volume_shader(volume_index, n_actual_slices); 1367 1486 glPopMatrix(); 1368 1487 … … 1500 1619 #endif 1501 1620 1621 void 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 1502 1654 1503 1655 /*----------------------------------------------------*/ … … 1511 1663 1512 1664 //convolve 1513 //lic();1665 lic(); 1514 1666 1515 1667 /* … … 1527 1679 1528 1680 //advect particles 1529 //psys->advect();1681 psys->advect(); 1530 1682 1531 1683 final_fbo_capture(); … … 1547 1699 glMatrixMode(GL_MODELVIEW); 1548 1700 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); 1551 1702 1552 1703 glRotated(live_rot_x, 1., 0., 0.); … … 1554 1705 glRotated(live_rot_z, 0., 0., 1.); 1555 1706 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 1557 1715 //draw line integral convolution quad 1558 1716 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); 1563 1721 glEnd(); 1564 */ 1722 1723 glPopMatrix(); 1724 1565 1725 1566 1726 //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 1570 1739 //volume[0]->location =Vector3(0.,0.,0.); 1571 1740 //render_volume(0, 256); 1572 1741 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); 1575 1745 1576 1746 perf->enable(); 1577 render_volume(0, 256);1578 1747 perf->disable(); 1579 1748 fprintf(stderr, "pixels: %d\n", perf->get_pixel_count()); 1580 1749 perf->reset(); 1750 1751 draw_axis(); 1581 1752 1582 1753 glDisable(GL_DEPTH_TEST); … … 1652 1823 break; 1653 1824 case '+': 1654 slice_z+=0.1;1825 lic_slice_z+=0.05; 1655 1826 get_slice_vectors(); 1656 1827 break; 1657 1828 case '-': 1658 slice_z-=0.1;1829 lic_slice_z-=0.05; 1659 1830 get_slice_vectors(); 1660 1831 break; … … 1667 1838 case '3': 1668 1839 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(); 1669 1855 break; 1670 1856 default: -
trunk/gui/vizservers/nanovis/nanovis.h
r377 r378 87 87 float live_rot_z = 0.; 88 88 89 float live_obj_x = -0. 5; //object translation location from the origin90 float live_obj_y = -0. 5;89 float live_obj_x = -0.0; //object translation location from the origin 90 float live_obj_y = -0.0; 91 91 float live_obj_z = -2.5; 92 92 … … 95 95 bool right_down = false; 96 96 97 float slice_x=0, slice_y=0, slice_z=0.3;//image based flow visualization slice location97 float lic_slice_x=0, lic_slice_y=0, lic_slice_z=0.3;//image based flow visualization slice location 98 98 99 99 int win_width = NPIX; //size of the render window -
trunk/gui/vizservers/nanovis/shaders/one_volume.cg
r377 r378 25 25 float4 tex_coord = mul(modelViewInv, IN.TexCoord); 26 26 27 #if 0 28 //1 component29 float sample = tex3D(volume, tex_coord.xyz);27 if(renderParameters.y==1){ 28 //1 component 29 float sample = tex3D(volume, tex_coord.xyz); 30 30 31 if (sample.x < 0.) {31 if (sample.x < 0.) { 32 32 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 } 35 42 } 36 #endif37 43 44 else if(renderParameters.y==0){ 38 45 39 #if 1 40 //3 component41 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 } 44 51 45 52 //debug -
trunk/gui/vizservers/nanovis/shaders/render_vel.cg
r226 r378 27 27 ret.y = plane_normal.y * vel.y; 28 28 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); 31 32 } -
trunk/gui/vizservers/nanovis/shaders/update_pos.cg
r226 r378 18 18 uniform samplerRECT pos_tex, 19 19 uniform sampler3D vel_tex, 20 uniform float timestep 20 uniform float timestep, 21 uniform float3 scale 21 22 ) : COLOR 22 23 { … … 28 29 29 30 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; 30 37 ret = pos + vel*timestep; 31 38 //ret = pos; 32 39 33 40 /* 41 //not drawing if the particle is out of bound 34 42 if(ret.x<0 || ret.x>1 || ret.y<0 || ret.y>1 || ret.z<0 || ret.z>1 || time==0) 35 43 ret = float4(1,0,0,0); 36 44 else 37 ret.w = time-1;45 ret.w = 1; 38 46 */ 39 47 40 ret.w = 1. 0;48 ret.w = 1.; 41 49 return ret; 42 50 }
Note: See TracChangeset
for help on using the changeset viewer.