[vtkusers] depth sorting problems?
Aashish Chaudhary
aashish.chaudhary at kitware.com
Thu May 12 10:26:00 EDT 2011
If your hardware has proper extensions you could use
Depth peeling:
http://www.itk.org/Wiki/VTK/Depth_Peeling
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/CorrectlyRenderingTranslucentGeometry
On Tue, May 10, 2011 at 12:32 PM, Steven Chall <stevec at renci.org> wrote:
> 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
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
--
| Aashish Chaudhary
| R&D Engineer
| Kitware Inc.
| www.kitware.com
More information about the vtkusers
mailing list