[vtkusers] depth sorting problems?

Steven Chall stevec at renci.org
Tue May 10 12:32:54 EDT 2011


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.

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.

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.

-Steve

vtkPoints *points = vtkPoints::New();

    //...read in a bunch of vertices...

  vtkCellArray *polys = vtkCellArray::New();

    // ...likewise read in a bunch of edges to connect the vertices...

  if (structure) structure->Delete();
  structure = vtkPolyData::New();
  structure->SetPoints(points);
  points->Delete();
  structure->SetPolys(polys);
  polys->Delete();

  if (deci) deci->Delete();
  deci = vtkDecimatePro::New();
  deci->SetInput(structure);
  deci->SetTargetReduction(0.5);
  deci->PreserveTopologyOn();

  if (smoother) smoother->Delete();
  smoother = vtkSmoothPolyDataFilter::New();
  smoother->SetInputConnection(deci->GetOutputPort());
  smoother->SetNumberOfIterations(100);

  if (normals) normals->Delete();
  normals = vtkPolyDataNormals::New();
  normals->SetInputConnection(smoother->GetOutputPort());
  normals->FlipNormalsOn();
 normals->AutoOrientNormalsOn();
  normals->NonManifoldTraversalOff();
  normals->ConsistencyOn();
  //normals->ComputeCellNormalsOn();

  if (mapper) mapper->Delete();
  mapper = vtkPolyDataMapper::New();
  mapper->SetInputConnection(normals->GetOutputPort());

  if (actor) actor->Delete();
  actor = vtkActor::New();
  actor->SetMapper(mapper);
  actor->GetProperty()->SetInterpolationToPhong();

  if (transparency != 0.0)
  {
    //normals->FlipNormalsOff();
    actor->GetProperty()->SetOpacity(1.0 - (transparency / 100.0));
  }

  actor->GetProperty()->SetSpecular(4);
  actor->GetProperty()->SetSpecularPower(30);
  actor->GetProperty()->SetColor(clr[0], clr[1], clr[2]);
  actor->GetProperty()->SetSpecularColor(1, 1, 1);

  renderer->AddActor(actor);



-Steve Chall
 Senior Research Software Developer
 Renaissance Computing Institute (RENCI)
 Phone: 919-681-9639
 Email: stevec at renci.org<mailto:stevec at renci.org>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110510/399b53ee/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: c113_transparent.png
Type: image/png
Size: 41514 bytes
Desc: c113_transparent.png
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110510/399b53ee/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: c113_opaque.png
Type: image/png
Size: 32082 bytes
Desc: c113_opaque.png
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110510/399b53ee/attachment-0001.png>


More information about the vtkusers mailing list