[vtkusers] VTK7 and PolygonOffset
Ken Martin
ken.martin at kitware.com
Tue Apr 12 10:52:12 EDT 2016
For the OpenGL2 backend VTK version 7.0 the offset code is based on two
properties, the factor and units. The shader math is shown below but the
basic gist is that the units (coffset below) impacts all fragments while
the factor (cfactor below) is weighted by the slope of the fragment. The
greater the z-slope of a fragment the farther you need to offset to make
sure the two fragments are not coincident. Positive values push farther
back in the z buffer. The properties are unitless in that the coordinate
system your actor is defined in has no impact on the values.
"float cscale =
length(vec2(dFdx(gl_FragCoord.z),dFdy(gl_FragCoord.z)));\n" "
gl_FragDepth = gl_FragCoord.z + cfactor*cscale + 0.000016*coffset;\n"
VTK defaults these properties to the following values for
polygons/lines/points such that if you turn on resolving coincident
topology using polygon offset the defaults should work fairly well to put
points on top of lines and line on top of polygons. Also be aware in VTK 7
you can specify mapper specific adjustments to these globals using
the SetRelativeCoincidentTopologyPolygonOffsetParameters style methods.
Those methods add the mapper specific value to the global for that mapper.
Values in the range of -10 --- +10 generally make sense. The factor and
units should typically have the same sign.
static double vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetFactor
= 2.0;static double
vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetUnits =
2.0;static double
vtkMapperGlobalResolveCoincidentTopologyLineOffsetFactor = 1.0;static
double vtkMapperGlobalResolveCoincidentTopologyLineOffsetUnits =
1.0;static double
vtkMapperGlobalResolveCoincidentTopologyPointOffsetUnits = 0.0;
Hope that helps
Ken
On Mon, Apr 11, 2016 at 4:26 PM, marcin.krotkiewski <
marcin.krotkiewski at gmail.com> wrote:
> Hello,
>
> I am wondering if there were any major changes between VTK6.3 and VTK7 in
> how SetResolveCoincidentTopologyPolygonOffsetParameters in the OpenGL2
> backend works.
>
> I have been using OpenGL2 and polygon offset to display contour lines on
> 3D surface meshes (digital elevation models). The parameters I use are (1,
> mesh_size), where mesh_size is some value related to the 'physical'
> distance between nodes in my surface meshes. In VTK7 that gives very wrong
> results. To get similar behavior I seem to have to use (2, 1), regardless
> of 'physical' distances between the mesh nodes.
>
> Could anyone shed some light on that?
>
> Thanks!
>
> Marcin
>
> _______________________________________________
> 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/20160412/9c6f4f64/attachment.html>
More information about the vtkusers
mailing list