[vtkusers] Flat interpolation under OpenGL2 backend

Ken Martin ken.martin at kitware.com
Thu Feb 18 11:05:40 EST 2016


Hello Fernando,

Making sure that I understand the issue. Essentially you have defined
scalars/colors on the points of a triangle. With phong shading the colors
interpolate across the triangle. With flat shading on the old backend, the
system takes the color of the first point and uses that for the entire
triangle. On the new backend the colors are still interpolated across the
triangle.  Is that the issue you see?

If so, then the issue is that on the new backend I am interpreting shading
to only mean lighting and normal calculations while in the old backend it
seems to include vertex color properties (but not other properties such as
tcoords, hmm wonder what happens with flat shading and texture based
coloring) In modern OpenGL (version 3.2 ) you can specify flat versus
smooth interpolation by attribute. So normals could be flat while colors
are smooth. Without requiring OpenGL 3.2 we would need to rebuild the VBO
each time you switch between flat and smooth, basically treating flat
shading as if you had cell colors instead of point colors.

If backward compatibility was not an issue :-) I would suggest moving to
require OpenGL 3.2 and then modifying vtkProperty so that people can
independently specify if they want normals/colors/etc to be
flat/smooth/perspective.

One stopgap, you could use vtkPointDataToCellData to essentially accomplish
what you want in either back end.

Thanks
Ken



On Thu, Feb 18, 2016 at 10:14 AM, Fernando Nellmeldin <
f.nellmeldin at open-engineering.com> wrote:

> Hello friends.
>
> In our application, we want to allow the user to alternate between a flat
> and a smooth shading of the colors in an actor. To do this, we have a
> option that allows the user to call setInterpolationToFlat() or
> setInterpolationToPhong() in the property of the vtkactor.
>
> The problem is that the call to set flat is not working, there is no
> change and the actor is always rendered smooth.
>
> I've tried with VTK 6.3.0 and VTK 7.0.0 under OpenGL2 backend. In VTK 5.10
> (using the old opengl), this works as expected.
>
> And please note that in the three cases, the code is exactly the same.
> Well, except the connection between the ugrid and the geometry filter that
> I have the usual if:
> #if VTK_MAJOR_VERSION <= 5
> geometryFilter->SetInputConnection(m_model->GetProducerPort());
> #else
> geometryFilter->SetInputData(m_model);
> #endif
>
> Therefore, is the support of flat interpolation dropped, or I have to add
> something to make it work under OpenGL2 backend?
>
> Thank you!
>
>
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>


-- 
Ken Martin PhD
Chairman & CFO
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065
518 371 3971

This communication, including all attachments, contains confidential and
legally privileged information, and it is intended only for the use of the
addressee.  Access to this email by anyone else is unauthorized. If you are
not the intended recipient, any disclosure, copying, distribution or any
action taken in reliance on it is prohibited and may be unlawful. If you
received this communication in error please notify us immediately and
destroy the original message.  Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160218/9966874d/attachment.html>


More information about the vtkusers mailing list