This page may help:<br><a href="http://vtk.org/Wiki/VTK/Examples/Cxx/Visualization/CorrectlyRenderingTranslucentGeometry">http://vtk.org/Wiki/VTK/Examples/Cxx/Visualization/CorrectlyRenderingTranslucentGeometry</a><br><br>
<br><div class="gmail_quote">On Tue, May 10, 2011 at 12:32 PM, Steven Chall <span dir="ltr"><<a href="mailto:stevec@renci.org">stevec@renci.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div link="blue" vlink="purple" lang="EN-US"><div><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;">Please look at the attached images, showing two sets of structures (vtkPolyData objects) constructed inside a loop using the code included below. I strongly believe that the code for the two images is identical except that actor->GetProperty()->SetOpacity(…) is being called for c113_transparent.png with an argument < 1.0. </span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> </span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;">c113_opaque.png (opacity == 1.0) looks ok. But c113_transparent.png (opacity < 1.0) has various kinds of ugly rendering artifacts that show up when opacity isn’t all the way on, maybe sorting errors? Also, note that the ordering of the structures is wrong front-to-back when opacity is less than full: for example, the brown structure appears to be in front of the red and dark gray ones, but it’s not when opacity is full on (nor should it be). I’m trying various combinations of normal parameter values, e.g., flipped, not flipped, etc., but I haven’t found the right combination to make partial transparency acceptable. </span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> </span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;">I’m running VTK 5.6.1 with Qt 4.7.1 in Win7 Enterprise, all 32 bits, on a ThinkPad with a 1.6 GHz i7 (Q720) cpu and 4 GB RAM. Thanks for any suggestions.</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> </span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;">-Steve</span></p><p class="MsoNormal" style="">
<span style="font-size: 9.5pt; font-family: Consolas;"> </span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;">vtkPoints *points = vtkPoints::New();</span></p><p class="MsoNormal" style="">
<span style="font-size: 9.5pt; font-family: Consolas;"> </span></p><p class="MsoNormal" style=""> //…read in a bunch of vertices…</p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> vtkCellArray *polys = vtkCellArray::New();</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> </span></p>
<p class="MsoNormal"> // …likewise read in a bunch of edges to connect the vertices…</p><p class="MsoNormal"> </p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> <span style="color: blue;">if</span> (structure) structure->Delete(); </span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> structure = vtkPolyData::New();</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> structure->SetPoints(points);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> points->Delete();</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> structure->SetPolys(polys);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> polys->Delete();</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> </span></p><p class="MsoNormal" style="">
<span style="font-size: 9.5pt; font-family: Consolas;"> <span style="color: blue;">if</span> (deci) deci->Delete(); </span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> deci = vtkDecimatePro::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> deci->SetInput(structure);</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> deci->SetTargetReduction(0.5);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> deci->PreserveTopologyOn();</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> <span style="color: blue;">if</span> (smoother) smoother->Delete();</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> smoother = vtkSmoothPolyDataFilter::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> smoother->SetInputConnection(deci->GetOutputPort());</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> smoother->SetNumberOfIterations(100);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> </span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> <span style="color: blue;">if</span> (normals) normals->Delete();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> normals = vtkPolyDataNormals::New();</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> normals->SetInputConnection(smoother->GetOutputPort());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> normals->FlipNormalsOn();</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> normals->AutoOrientNormalsOn();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> normals->NonManifoldTraversalOff();</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> normals->ConsistencyOn();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> <span style="color: green;">//normals->ComputeCellNormalsOn();</span></span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> <span style="color: blue;">if</span> (mapper) mapper->Delete();</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> mapper = vtkPolyDataMapper::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> mapper->SetInputConnection(normals->GetOutputPort());</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> <span style="color: blue;">if</span> (actor) actor->Delete(); </span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> actor = vtkActor::New(); </span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> actor->SetMapper(mapper);</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> actor->GetProperty()->SetInterpolationToPhong();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> </span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> <span style="color: blue;">if</span> (transparency != 0.0)</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> {</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> <span style="color: green;">//normals->FlipNormalsOff();</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> actor->GetProperty()->SetOpacity(1.0 - (transparency / 100.0));</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> }</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> </span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> actor->GetProperty()->SetSpecular(4);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> actor->GetProperty()->SetSpecularPower(30);</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> actor->GetProperty()->SetColor(clr[0], clr[1], clr[2]);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> actor->GetProperty()->SetSpecularColor(1, 1, 1);</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> renderer->AddActor(actor);</span></p><p class="MsoNormal" style=""><span style="font-size: 9.5pt; font-family: Consolas;"> </span></p>
<p class="MsoNormal"> </p><p class="MsoNormal"> </p><p class="MsoNormal"><span style="color: black;">-Steve Chall</span></p><p class="MsoNormal"><span style="color: black;"> Senior Research Software Developer</span></p><p class="MsoNormal">
<span style="color: black;"> Renaissance Computing Institute (RENCI)</span></p><p class="MsoNormal"><span style="color: black;"> Phone: <a href="tel:919-681-9639" value="+19196819639" target="_blank">919-681-9639</a></span></p>
<p class="MsoNormal"><span style="color: black;"> Email: <a href="mailto:stevec@renci.org" target="_blank"><span style="color: blue;">stevec@renci.org</span></a></span></p><p class="MsoNormal"> </p></div></div><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br>