[Ves] Flat Shader
Pat Marion
pat.marion at kitware.com
Mon Mar 25 22:20:03 EDT 2013
Hi Chris,
The new KiwiViewer 2.0 app is built from the kiwi-next-apps branch on the
'stage' remote. You can merge get this branch with a git checkout:
git remote add stage git://vtk.org/stage/VES.git
git fetch stage
git checkout -t stage/kiwi-next-apps
The commits on this branch need some cleanup and review before we merge
them into master, so for now you will need to use this branch (or just
merge that branch into your own development branch), but be warned that
there are some changes on this branch which make it more difficult to
compile, because it introduces required dependencies cURL and libarchive.
Part of the clean up will be to make this dependencies optional.
Instead of merging the entire branch, you could grab just this one commit:
89ef873f6c
git fetch stage
git cherry-pick 89ef873f6c
The new magic in KiwiViewer which fixes the rendering is the addition of
the vtkPolyDataNormals filter. This filter is part of VTK, it will
duplicate vertices along sharp edges so that repeated vertices can have
different normals. Here is the code that applies the filter:
const int normalsFeatureAngle = 25.0;
vtkNew<vtkPolyDataNormals> normals;
normals->SetInputData(polyData);
normals->SplittingOn();
normals->SetFeatureAngle(normalsFeatureAngle);
normals->Update();
polyData = normals->GetOutput();
Or, if you look in the new code, look in vesKiwiDataConversionTools.cpp at
the function: vtkSmartPointer<vtkPolyData>
vesKiwiDataConversionTools::TriangulatePolyData(vtkPolyData* input, bool
addNormals, bool duplicateVertices) { ... }
Depending on your input data size and amount of sharp edges, applying this
filter can be costly in cpu time and memory consumption, but I decided to
enable it automatically in KiwiViewer 2.0. I've loaded datasets with >1
million vertices without trouble.
Pat
On Tue, Mar 26, 2013 at 11:54 AM, Chris Vaught <cvaught at cmv-tech.com> wrote:
> I sent a message last year about the rendering issues that is shown in the
> attached image (HoleInPlate.png). The response was that this was caused by
> missing normals. The rendering would be fixed once a flat shading model
> was added. I just tried the new KiwiViewer app and it appears to be
> shading it properly (see attached HoleInPlateCorrect.png), which is great.
> Thanks for adding the flat shader. But how do I implement this into my
> app? I have updated the sources, compiled and opened the new KiwiSimple
> app. I changed the loading file to this demo file and the app still
> renders it incorrectly. Is there a setting that needs to be changed?
>
> Thanks for the help.
> Chris
>
> _______________________________________________
> Ves mailing list
> Ves at public.kitware.com
> http://public.kitware.com/cgi-bin/mailman/listinfo/ves
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/ves/attachments/20130326/595f4bae/attachment-0002.html>
More information about the Ves
mailing list