- Timestamp:
- Jun 5, 2012 12:08:41 PM (12 years ago)
- Location:
- branches/nanovis2
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/nanovis2/gui/scripts/nanovisviewer.tcl
r3009 r3023 927 927 PanCamera 928 928 SendCmd "camera zoom $_view(zoom)" 929 FixSettings light2side 929 930 FixSettings light 930 931 FixSettings transp … … 1219 1220 SendCmd "volume shading specularLevel $specularLevel" 1220 1221 SendCmd "volume shading specularExp $specularExp" 1222 } 1223 } 1224 light2side { 1225 if {[isconnected]} { 1226 set val $_settings($this-light2side) 1227 SendCmd "volume shading light2side $val" 1221 1228 } 1222 1229 } … … 1744 1751 itcl::body Rappture::NanovisViewer::BuildVolumeTab {} { 1745 1752 foreach { key value } { 1753 light2side 0 1746 1754 light 40 1747 1755 transp 50 … … 1765 1773 label $inner.shading -text "Shading:" -font $fg 1766 1774 1775 checkbutton $inner.light2side -text "Two-sided lighting" -font $fg \ 1776 -variable [itcl::scope _settings($this-light2side)] \ 1777 -command [itcl::code $this FixSettings light2side] 1778 1767 1779 label $inner.dim -text "Glow" -font $fg 1768 1780 ::scale $inner.light -from 0 -to 100 -orient horizontal \ … … 1796 1808 0,0 $inner.vol -columnspan 4 -anchor w -pady 2 \ 1797 1809 1,0 $inner.shading -columnspan 4 -anchor w -pady {10 2} \ 1798 2,0 $inner.dim -anchor e -pady 2 \ 1799 2,1 $inner.light -columnspan 2 -pady 2 -fill x \ 1800 2,3 $inner.bright -anchor w -pady 2 \ 1801 3,0 $inner.fog -anchor e -pady 2 \ 1802 3,1 $inner.transp -columnspan 2 -pady 2 -fill x \ 1803 3,3 $inner.plastic -anchor w -pady 2 \ 1804 4,0 $inner.thin -anchor e -pady 2 \ 1805 4,1 $inner.thickness -columnspan 2 -pady 2 -fill x\ 1806 4,3 $inner.thick -anchor w -pady 2 1810 2,0 $inner.light2side -columnspan 4 -anchor w -pady 2 \ 1811 3,0 $inner.dim -anchor e -pady 2 \ 1812 3,1 $inner.light -columnspan 2 -pady 2 -fill x \ 1813 3,3 $inner.bright -anchor w -pady 2 \ 1814 4,0 $inner.fog -anchor e -pady 2 \ 1815 4,1 $inner.transp -columnspan 2 -pady 2 -fill x \ 1816 4,3 $inner.plastic -anchor w -pady 2 \ 1817 5,0 $inner.thin -anchor e -pady 2 \ 1818 5,1 $inner.thickness -columnspan 2 -pady 2 -fill x\ 1819 5,3 $inner.thick -anchor w -pady 2 1807 1820 1808 1821 # 4,0 $inner.clear -anchor e -pady 2 \ … … 1812 1825 1813 1826 blt::table configure $inner c0 c1 c3 r* -resize none 1814 blt::table configure $inner r 5-resize expand1827 blt::table configure $inner r6 -resize expand 1815 1828 } 1816 1829 -
branches/nanovis2/packages/vizservers/nanovis/Command.cpp
r3007 r3023 1378 1378 1379 1379 static int 1380 VolumeShadingLight2SideOp(ClientData clientData, Tcl_Interp *interp, int objc, 1381 Tcl_Obj *const *objv) 1382 { 1383 bool twoSidedLighting; 1384 if (GetBooleanFromObj(interp, objv[3], &twoSidedLighting) != TCL_OK) { 1385 return TCL_ERROR; 1386 } 1387 std::vector<Volume *> ivol; 1388 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) { 1389 return TCL_ERROR; 1390 } 1391 std::vector<Volume *>::iterator iter; 1392 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 1393 (*iter)->twoSidedLighting(twoSidedLighting); 1394 } 1395 return TCL_OK; 1396 } 1397 1398 static int 1380 1399 VolumeShadingOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 1381 1400 Tcl_Obj *const *objv) … … 1477 1496 {"diffuse", 1, VolumeShadingDiffuseOp, 4, 0, "value ?indices?",}, 1478 1497 {"isosurface", 1, VolumeShadingIsosurfaceOp, 4, 0, "bool ?indices?",}, 1498 {"light2side", 1, VolumeShadingLight2SideOp, 4, 0, "bool ?indices?",}, 1479 1499 {"opacity", 1, VolumeShadingOpacityOp, 4, 0, "value ?indices?",}, 1480 1500 {"specularExp", 9, VolumeShadingSpecularExpOp, 4, 0, "value ?indices?",}, -
branches/nanovis2/packages/vizservers/nanovis/ConvexPolygon.cpp
r2902 r3023 26 26 } 27 27 28 // Finds the intersection of the line through29 // p1 and p2 with the given plane, putting the30 // result in intersect.31 //32 // If the line lies in the plane, an arbitrary33 // point on the line is returned.34 //35 // http://astronomy.swin.edu.au/pbourke/geometry/planeline/36 bool37 findIntersection(const Vector4& pt1, const Vector4& pt2, const Vector4& plane, Vector4& ret)38 {39 float a = plane.x;40 float b = plane.y;41 float c = plane.z;42 float d = plane.w;43 44 Vector4 p1 = pt1;45 p1.perspectiveDivide();46 float x1 = p1.x;47 float y1 = p1.y;48 float z1 = p1.z;49 50 Vector4 p2 = pt2;51 p2.perspectiveDivide();52 float x2 = p2.x;53 float y2 = p2.y;54 float z2 = p2.z;55 56 float uDenom = a * (x1 - x2) + b * (y1 - y2) + c * (z1 - z2);57 float uNumer = a * x1 + b * y1 + c * z1 + d;58 59 if (uDenom == 0){60 //plane parallel to line61 ERROR("Unexpected code path: ConvexPolygon.cpp\n");62 if (uNumer == 0){63 ret = p1;64 return true;65 }66 return false;67 }68 69 float u = uNumer / uDenom;70 ret.x = x1 + u * (x2 - x1);71 ret.y = y1 + u * (y2 - y1);72 ret.z = z1 + u * (z2 - z1);73 ret.w = 1;74 return true;75 }76 77 28 void 78 29 ConvexPolygon::transform(const Mat4x4& mat) … … 99 50 } 100 51 101 void 52 #define SIGN_DIFFERS(x, y) \ 53 ( ((x) < 0.0 && (y) > 0.0) || ((x) > 0.0 && (y) < 0.0) ) 54 55 bool 102 56 ConvexPolygon::clip(Plane& clipPlane, bool copyToTexcoord) 103 57 { 104 58 if (vertices.size() == 0) { 105 //ERROR("ConvexPolygon: polygon has no vertices\n");106 return ;59 ERROR("polygon has no vertices\n"); 60 return false; 107 61 } 108 62 109 63 VertexVector clippedVerts; 110 64 clippedVerts.reserve(2 * vertices.size()); … … 112 66 // The algorithm is as follows: for each vertex 113 67 // in the current poly, check to see which 114 // half space it is in: clipped or retained.68 // half space it is in: clipped (outside) or inside. 115 69 // If the previous vertex was in the other 116 // half space, find the intersect of that edge117 // with the clip plane and add that intersect 70 // half space, find the intersection of that edge 71 // with the clip plane and add that intersection 118 72 // point to the new list of vertices. If the 119 // current vertex is in the retainedhalf-space,73 // current vertex is in the inside half-space, 120 74 // add it to the new list as well. 121 75 122 Vector4 intersect;123 76 Vector4 plane = clipPlane.getCoeffs(); 124 77 125 bool prevRetained = isRetained(vertices[0], plane); 126 if (prevRetained) 127 clippedVerts.push_back(vertices[0]); 128 129 for (unsigned int i = 1; i < vertices.size(); i++) { 130 bool retained = isRetained(vertices[i], plane); 131 if (retained != prevRetained) { 132 bool found = findIntersection(vertices[i - 1], vertices[i], 133 plane, intersect); 134 assert(found); 135 clippedVerts.push_back(intersect); 78 // This implementation is based on the Mesa 3D library (MIT license) 79 int v1 = 0; 80 // dot product >= 0 on/inside half-space, < 0 outside half-space 81 float dot1 = vertices[v1] * plane; 82 for (unsigned int i = 1; i <= vertices.size(); i++) { 83 int v2 = (i == vertices.size()) ? 0 : i; 84 float dot2 = vertices[v2] * plane; 85 if (dot1 >= 0.0) { 86 // on/inside 87 clippedVerts.push_back(vertices[v1]); 136 88 } 137 if (retained) { 138 clippedVerts.push_back(vertices[i]); 89 if (SIGN_DIFFERS(dot1, dot2)) { 90 if (dot1 < 0.0) { 91 // outside -> inside 92 double t = dot1 / (dot1 - dot2); 93 clippedVerts.push_back(vlerp(vertices[v1], vertices[v2], t)); 94 } else { 95 // inside -> outside 96 double t = dot2 / (dot2 - dot1); 97 clippedVerts.push_back(vlerp(vertices[v2], vertices[v1], t)); 98 } 139 99 } 140 prevRetained = retained; 141 } 142 143 bool retained = isRetained(vertices[0], plane); 144 if (retained != prevRetained) { 145 bool found = findIntersection(vertices[vertices.size() - 1], 146 vertices[0], plane, intersect); 147 assert(found); 148 clippedVerts.push_back(intersect); 100 dot1 = dot2; 101 v1 = v2; 149 102 } 150 103 151 104 vertices.clear(); 152 vertices.insert(vertices.begin(),153 clippedVerts.begin(),154 clippedVerts.end());155 105 156 if (copyToTexcoord) 157 copyVerticesToTexcoords(); 106 if (clippedVerts.size() < 3) { 107 texcoords.clear(); 108 return false; 109 } else { 110 vertices.insert(vertices.begin(), 111 clippedVerts.begin(), 112 clippedVerts.end()); 113 114 if (copyToTexcoord) 115 copyVerticesToTexcoords(); 116 117 return true; 118 } 158 119 } 120 121 #undef SIGN_DIFFERS 159 122 160 123 void … … 180 143 glVertex4fv((float *)&(vertices[i])); 181 144 } 182 } 145 } else { 146 WARN("No polygons to render\n"); 147 } 183 148 } 184 149 … … 199 164 glVertex4fv((float *)(&tmp)); 200 165 } 166 } else { 167 WARN("No polygons to render\n"); 201 168 } 202 169 } -
branches/nanovis2/packages/vizservers/nanovis/ConvexPolygon.h
r2877 r3023 39 39 40 40 // Clips the polygon, retaining the portion where ax + by + cz + d >= 0 41 voidclip(Plane& clipPlane, bool copyToTexcoords);41 bool clip(Plane& clipPlane, bool copyToTexcoords); 42 42 43 43 void emit(bool useTexture); … … 63 63 } 64 64 65 bool isRetained(const Vector4& point, const Vector4& plane)66 {67 return ((point * plane) >= 0);68 }69 70 65 VertexVector vertices; 71 66 TexVector texcoords; -
branches/nanovis2/packages/vizservers/nanovis/Makefile.in
r3007 r3023 155 155 shaders = \ 156 156 $(srcdir)/shaders/common.cg \ 157 $(srcdir)/shaders/cutplane_fp.cg \ 158 $(srcdir)/shaders/cutplane_vp.cg \ 157 159 $(srcdir)/shaders/heightcolor.cg \ 158 160 $(srcdir)/shaders/one_plane.cg \ -
branches/nanovis2/packages/vizservers/nanovis/NvRegularVolumeShader.cpp
r3006 r3023 39 39 volume->isosurface(), 40 40 volume->opacityScale(), 41 0.0f);41 (volume->twoSidedLighting() ? 1.0f : 0.0f)); 42 42 43 43 NvShader:: bind(); -
branches/nanovis2/packages/vizservers/nanovis/Vector3.h
r3007 r3023 26 26 { 27 27 public: 28 float x, y, z;29 30 28 Vector3() 31 29 {} … … 177 175 } 178 176 177 float x, y, z; 178 179 179 private: 180 180 float radians(float degree) const … … 186 186 typedef std::vector<Vector3> Vector3Array; 187 187 188 /** 189 * \brief Linear interpolation of 2 vectors 190 */ 191 inline Vector3 vlerp(const Vector3& v1, const Vector3& v2, double t) 192 { 193 return Vector3(v1.x * (1.0-t) + v2.x * t, 194 v1.y * (1.0-t) + v2.y * t, 195 v1.z * (1.0-t) + v2.z * t); 196 } 197 188 198 #endif -
branches/nanovis2/packages/vizservers/nanovis/Vector4.h
r3007 r3023 24 24 { 25 25 public: 26 float x, y, z, w;27 28 26 Vector4() 29 27 {} … … 79 77 return Vector4(x / op2, y / op2, z / op2, w / op2); 80 78 } 79 80 float x, y, z, w; 81 81 }; 82 82 83 83 typedef std::vector<Vector4> Vector4Array; 84 84 85 /** 86 * \brief Linear interpolation of 2 points 87 */ 88 inline Vector4 vlerp(const Vector4& v1, const Vector4& v2, double t) 89 { 90 return Vector4(v1.x * (1.0-t) + v2.x * t, 91 v1.y * (1.0-t) + v2.y * t, 92 v1.z * (1.0-t) + v2.z * t, 93 v1.w * (1.0-t) + v2.w * t); 94 } 95 96 /** 97 * \brief Finds the intersection of a line through 98 * p1 and p2 with the given plane. 99 * 100 * If the line lies in the plane, an arbitrary 101 * point on the line is returned. 102 * 103 * Reference: 104 * http://astronomy.swin.edu.au/pbourke/geometry/planeline/ 105 * 106 * \param[in] pt1 First point 107 * \param[in] pt2 Second point 108 * \param[in] plane Plane equation coefficients 109 * \param[out] ret Point of intersection if a solution was found 110 * \return Bool indicating if an intersection was found 111 */ 112 inline bool 113 planeLineIntersection(const Vector4& pt1, const Vector4& pt2, 114 const Vector4& plane, Vector4& ret) 115 { 116 float a = plane.x; 117 float b = plane.y; 118 float c = plane.z; 119 float d = plane.w; 120 121 Vector4 p1 = pt1; 122 float x1 = p1.x; 123 float y1 = p1.y; 124 float z1 = p1.z; 125 126 Vector4 p2 = pt2; 127 float x2 = p2.x; 128 float y2 = p2.y; 129 float z2 = p2.z; 130 131 float uDenom = a * (x1 - x2) + b * (y1 - y2) + c * (z1 - z2); 132 float uNumer = a * x1 + b * y1 + c * z1 + d; 133 134 if (uDenom == 0.0f) { 135 // Plane parallel to line 136 if (uNumer == 0.0f) { 137 // Line within plane 138 ret = p1; 139 return true; 140 } 141 // No solution 142 TRACE("No intersection between line and plane\n"); 143 return false; 144 } 145 146 float u = uNumer / uDenom; 147 ret.x = x1 + u * (x2 - x1); 148 ret.y = y1 + u * (y2 - y1); 149 ret.z = z1 + u * (z2 - z1); 150 ret.w = 1; 151 return true; 152 } 153 85 154 #endif -
branches/nanovis2/packages/vizservers/nanovis/Volume.cpp
r3006 r3023 37 37 _specular(0.3f), 38 38 _specularExp(90.0f), 39 _lightTwoSide(false), 39 40 _opacityScale(0.5f), 40 41 _name(NULL), -
branches/nanovis2/packages/vizservers/nanovis/Volume.h
r3006 r3023 236 236 } 237 237 238 bool twoSidedLighting() const 239 { 240 return _lightTwoSide; 241 } 242 243 void twoSidedLighting(bool value) 244 { 245 _lightTwoSide = value; 246 } 247 238 248 float opacityScale() const 239 249 { … … 360 370 float _specular; ///< Specular level material coefficient 361 371 float _specularExp; ///< Specular exponent 372 bool _lightTwoSide; ///< Two-sided lighting flag 373 362 374 /** 363 375 * The scale multiplied to the opacity assigned by the -
branches/nanovis2/packages/vizservers/nanovis/VolumeRenderer.cpp
r3007 r3023 38 38 VolumeRenderer::~VolumeRenderer() 39 39 { 40 delete _cutplaneShader; 40 41 delete _zincBlendeShader; 41 42 delete _regularVolumeShader; … … 47 48 void VolumeRenderer::initShaders() 48 49 { 50 _cutplaneShader = new NvShader(); 51 _cutplaneShader->loadVertexProgram("cutplane_vp.cg", "main"); 52 _cutplaneShader->loadFragmentProgram("cutplane_fp.cg", "main"); 53 49 54 //standard vertex program 50 55 _stdVertexShader = new NvStdVertexShader(); … … 102 107 for (hPtr = Tcl_FirstHashEntry(&NanoVis::volumeTable, &iter); hPtr != NULL; 103 108 hPtr = Tcl_NextHashEntry(&iter)) { 104 Volume *volPtr;109 Volume *volPtr; 105 110 volPtr = (Volume *)Tcl_GetHashValue(hPtr); 106 111 if (!volPtr->visible()) { … … 226 231 actual_slices[i] = n_actual_slices; 227 232 228 // These are object coordinates 229 Vector4 vert1 = (Vector4(-10, -10, -0.5, 1)); 230 Vector4 vert2 = (Vector4(-10, +10, -0.5, 1)); 231 Vector4 vert3 = (Vector4(+10, +10, -0.5, 1)); 232 Vector4 vert4 = (Vector4(+10, -10, -0.5, 1)); 233 TRACE("near: %g far: %g eye space bounds: (%g,%g)-(%g,%g) z_step: %g slices: %d", 234 zNear, zFar, eyeMinX, eyeMaxX, eyeMinY, eyeMaxY, z_step, n_actual_slices); 235 236 Vector4 vert1, vert2, vert3, vert4; 233 237 234 238 // Render cutplanes first with depth test enabled. They will mark the … … 237 241 // vice versa. 238 242 239 ConvexPolygon static_poly;240 243 for (int j = 0; j < volPtr->getCutplaneCount(); j++) { 241 244 if (!volPtr->isCutplaneEnabled(j)) { … … 244 247 float offset = volPtr->getCutplane(j)->offset; 245 248 int axis = volPtr->getCutplane(j)->orient; 246 247 if (axis == 3) { 248 vert1 = Vector4(-10, -10, offset, 1); 249 vert2 = Vector4(-10, +10, offset, 1); 250 vert3 = Vector4(+10, +10, offset, 1); 251 vert4 = Vector4(+10, -10, offset, 1); 252 //continue; 253 } else if (axis == 1) { 254 vert1 = Vector4(offset, -10, -10, 1); 255 vert2 = Vector4(offset, +10, -10, 1); 256 vert3 = Vector4(offset, +10, +10, 1); 257 vert4 = Vector4(offset, -10, +10, 1); 258 //continue; 259 } else if (axis == 2) { 260 vert1 = Vector4(-10, offset, -10, 1); 261 vert2 = Vector4(+10, offset, -10, 1); 262 vert3 = Vector4(+10, offset, +10, 1); 263 vert4 = Vector4(-10, offset, +10, 1); 264 //continue; 249 250 switch (axis) { 251 case 1: 252 vert1 = Vector4(offset, 0, 0, 1); 253 vert2 = Vector4(offset, 1, 0, 1); 254 vert3 = Vector4(offset, 1, 1, 1); 255 vert4 = Vector4(offset, 0, 1, 1); 256 break; 257 case 2: 258 vert1 = Vector4(0, offset, 0, 1); 259 vert2 = Vector4(1, offset, 0, 1); 260 vert3 = Vector4(1, offset, 1, 1); 261 vert4 = Vector4(0, offset, 1, 1); 262 break; 263 case 3: 264 default: 265 vert1 = Vector4(0, 0, offset, 1); 266 vert2 = Vector4(1, 0, offset, 1); 267 vert3 = Vector4(1, 1, offset, 1); 268 vert4 = Vector4(0, 1, offset, 1); 269 break; 265 270 } 266 271 267 vert1 = model_view_no_trans.transform(vert1); 268 vert2 = model_view_no_trans.transform(vert2); 269 vert3 = model_view_no_trans.transform(vert3); 270 vert4 = model_view_no_trans.transform(vert4); 271 272 ConvexPolygon *p = &static_poly; 273 p->vertices.clear(); 274 275 p->appendVertex(vert1); 276 p->appendVertex(vert2); 277 p->appendVertex(vert3); 278 p->appendVertex(vert4); 279 280 for (size_t k = 0; k < 6; k++) { 281 p->clip(volume_planes[k], true); 282 } 283 284 p->transform(model_view_no_trans_inverse); 285 p->transform(model_view_trans); 272 Vector4 texcoord1 = vert1; 273 Vector4 texcoord2 = vert2; 274 Vector4 texcoord3 = vert3; 275 Vector4 texcoord4 = vert4; 276 277 _cutplaneShader->bind(); 278 _cutplaneShader->setFPTextureParameter("volume", volPtr->textureID()); 279 _cutplaneShader->setFPTextureParameter("tf", volPtr->transferFunction()->id()); 286 280 287 281 glPushMatrix(); 282 glTranslatef(volPos.x, volPos.y, volPos.z); 288 283 glScalef(volScaling.x, volScaling.y, volScaling.z); 289 290 activateVolumeShader(volPtr, true, 0.0f);284 _cutplaneShader->setGLStateMatrixVPParameter("modelViewProjMatrix", 285 NvShader::MODELVIEW_PROJECTION_MATRIX); 291 286 glPopMatrix(); 292 287 … … 294 289 glDisable(GL_BLEND); 295 290 296 glBegin(GL_POLYGON); 297 p->emit(true); 291 glBegin(GL_QUADS); 292 glTexCoord3f(texcoord1.x, texcoord1.y, texcoord1.z); 293 glVertex3f(vert1.x, vert1.y, vert1.z); 294 glTexCoord3f(texcoord2.x, texcoord2.y, texcoord2.z); 295 glVertex3f(vert2.x, vert2.y, vert2.z); 296 glTexCoord3f(texcoord3.x, texcoord3.y, texcoord3.z); 297 glVertex3f(vert3.x, vert3.y, vert3.z); 298 glTexCoord3f(texcoord4.x, texcoord4.y, texcoord4.z); 299 glVertex3f(vert4.x, vert4.y, vert4.z); 298 300 glEnd(); 301 299 302 glDisable(GL_DEPTH_TEST); 300 301 deactivateVolumeShader(); 303 _cutplaneShader->disableFPTextureParameter("tf"); 304 _cutplaneShader->disableFPTextureParameter("volume"); 305 _cutplaneShader->unbind(); 302 306 } //done cutplanes 303 307 304 // Now do volume rendering308 // Now prepare proxy geometry slices 305 309 306 310 // Initialize view-aligned quads with eye space bounds of 307 311 // volume 308 vert1 = (Vector4(eyeMinX, eyeMinY, -0.5, 1));309 vert2 = (Vector4(eyeMaxX, eyeMinY, -0.5, 1));310 vert3 = (Vector4(eyeMaxX, eyeMaxY, -0.5, 1));311 vert4 = (Vector4(eyeMinX, eyeMaxY, -0.5, 1));312 vert1 = Vector4(eyeMinX, eyeMinY, -0.5, 1); 313 vert2 = Vector4(eyeMaxX, eyeMinY, -0.5, 1); 314 vert3 = Vector4(eyeMaxX, eyeMaxY, -0.5, 1); 315 vert4 = Vector4(eyeMinX, eyeMaxY, -0.5, 1); 312 316 313 317 size_t counter = 0; 314 318 315 // transform slices and store them319 // Transform slices and store them 316 320 float slice_z; 317 321 for (size_t j = 0; j < n_actual_slices; j++) { … … 337 341 338 342 for (size_t k = 0; k < 6; k++) { 339 poly->clip(volume_planes[k], true); 343 if (!poly->clip(volume_planes[k], true)) 344 break; 340 345 } 341 346 342 poly->transform(model_view_no_trans_inverse); 343 poly->transform(model_view_trans); 344 345 if (poly->vertices.size() >= 3) 347 if (poly->vertices.size() >= 3) { 348 poly->transform(model_view_no_trans_inverse); 349 poly->transform(model_view_trans); 346 350 total_rendered_slices++; 351 } 347 352 } 348 353 } //iterate all volumes … … 379 384 int volume_index = slices[i].volumeId; 380 385 int slice_index = slices[i].sliceId; 381 ConvexPolygon *cur = polys[volume_index][slice_index];386 ConvexPolygon *currentSlice = polys[volume_index][slice_index]; 382 387 float z_step = z_steps[volume_index]; 383 388 … … 396 401 397 402 #ifdef notdef 398 TRACE("shading slice: volume %s addr=%x slice=%d, volume=%d \n",399 volPtr->name(), volPtr, slice_index, volume_index);403 TRACE("shading slice: volume %s addr=%x slice=%d, volume=%d z_step=%g avgSD=%g\n", 404 volPtr->name(), volPtr, slice_index, volume_index, z_step, avgSampleDistance); 400 405 #endif 401 406 activateVolumeShader(volPtr, false, sampleRatio); … … 403 408 404 409 glBegin(GL_POLYGON); 405 cur ->emit(true);410 currentSlice->emit(true); 406 411 glEnd(); 407 412 -
branches/nanovis2/packages/vizservers/nanovis/VolumeRenderer.h
r3006 r3023 81 81 VolumeInterpolator *_volumeInterpolator; 82 82 83 /** 84 * shader for rendering a single cubic volume 83 /** 84 * Shader for single slice cutplane render 85 */ 86 NvShader *_cutplaneShader; 87 88 /** 89 * Shader for rendering a single cubic volume 85 90 */ 86 91 NvRegularVolumeShader *_regularVolumeShader; -
branches/nanovis2/packages/vizservers/nanovis/shaders/one_volume.cg
r3013 r3023 28 28 * y: isosurface flag (opacity scaling on/off) 29 29 * z: opacity scale 30 * w: two-sided lighting 30 31 */ 31 32 PixelOut main(v2f IN, … … 63 64 //lighting computation 64 65 #ifndef LIGHT_TWO_SIDE 65 float normal_dot_light = max(dot(normal, light_vector), 0); 66 float normal_dot_half = max(dot(normal, half_vector), 0); 66 float normal_dot_light = dot(normal, light_vector); 67 float normal_dot_half = dot(normal, half_vector); 68 if (renderParams.w > 0.5) { 69 normal_dot_light = abs(normal_dot_light); 70 normal_dot_half = abs(normal_dot_half); 71 } else { 72 normal_dot_light = max(normal_dot_light, 0); 73 normal_dot_half = max(normal_dot_half, 0); 74 } 67 75 #else 68 76 float normal_dot_light = abs(dot(normal, light_vector)); -
branches/nanovis2/packages/vizservers/nanovis/shaders/zincblende_volume.cg
r3006 r3023 60 60 */ 61 61 62 //sample transf or function texture62 //sample transfer function texture 63 63 float4 color = f4tex1D(tf, sample); 64 64
Note: See TracChangeset
for help on using the changeset viewer.