[vtkusers] Time for some more OpenGL2 Polygonal Updates

Ken Martin ken.martin at kitware.com
Thu Sep 3 10:22:48 EDT 2015


Heya folks, giving an update on some recent changes/features in the OpenGL2
backend.  Here we go...



1)      *SHADOW SUPPORT* - Added support for shadows back into VTK and
changed it up a bit. Shadows can provide valuable depth queues and
structural queues in many domains such as surgical simulation, CFD
analysis, and surgical planning. You can now turn on shadows in VTK by
simply doing renderer->UseShadowsOn()  (wow dude that’s easy)   Having said
that, remember that the default light in VTK is a headlight and a headlight
doesn’t really produce any shadows (ahh there’s the catch).  So if you want
shadows make sure to have a light that is a scene light for best
performance or a camera light.  There is an example/test in
Rendering/OpenGL2/Testing/Cxx/TestShadowMapPass.cxx.  That example sets up
Shadows using render passes which allows for a bit more flexibility but the
same approach is implemented under the hood in renderer->UseShadowsOn()



2)      *CUSTOM SHADERS* - Added support for customizing the default
PolyDataMapper shaders. You can now modify or completely replace the
default VTK shaders using methods such as



AddShaderReplacement: replaces a strings in the current shader
SetVertexShaderCode: replaces the default shader template with your own

AddObserver(vtkCommand::UpdateShaderEvent,...)



These methods (and similar others) give you a great degree on control of
the VTK PolyData shaders. There are examples/tests in
Rendering/OpenGL2/Testing/Cxx/TestUserShader.cxx and TestUserShader2.cxx.
Through the UpdateShaderEvent you can modify the default VTK uniforms or
your own uniforms as desired. There is currently not a general purpose easy
API for binding your own data arrays to attributes but we may add one at
some point in the future. Currently VTK will send down the default
attributes for you to use in your shader (position, normal, tcoords,
colors, etc)



3)      *IMPROVED POINT SPRITES* - Significantly improved the
vtkPointGaussianMapper. With some great help from Scott Wittenburg and
Sebastien Jourdain we added the ability to map size and/or opacity arrays
through a vtkPiecewiseFunction so that very large or small data can be
rendered in a very flexible manner. We also made it so that if you do
provide a cell array with an explicit list of points to use, then the
mapper will use only those points, and finally you can modify the fragment
shader code on the mapper now to draw whatever shapes you want. There is a
new example/test in
Rendering/OpenGL2/Testing/Cxx/TestPointGaussianMapperOpacity.cxx that shows
using the new features and includes sample shader code for drawing squares
or black edged circles.



4)      *ANDROID and iOS IMPROVEMENTS* - Revisited the android VTK build
with some help from Casey Goodlett and finally added two nightly android
dashboards for VTK.  One for API 18 with OpenGL ES 2.0 and one for API 21
with OpenGL ES 3.0. This should help us maintain working builds for Android
going forward.  While we were at it we added the vtkFrameBufferObject and
ShadowMap functionality into the OpenGL ES builds so that those devices can
make use of that functionality. We are still working on the android build
process and hope to someday soon put out some binaries to make using VTK on
android even easier.





Thanks

Ken



Ken Martin PhD

Chairman & CFO

Kitware Inc.

28 Corporate Drive

Clifton Park NY 12065

ken.martin at kitware.com

919 869-8871 (w)





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.



*From:* Ken Martin [mailto:ken.martin at kitware.com]
*Sent:* Wednesday, July 15, 2015 3:19 PM
*To:* 'vtkdev'
*Subject:* RE: Some OpenGL2 Polygonal Updates etc



It has been a while and I am overdue for updates on the new OpenGL
rendering engine. We are in pretty good shape in terms of the new rendering
engine with VTK. Tests are passing and we are generally ready to make it
the default for the upcoming VTK release.  The old engine will also be
available as a CMake option. Here are some specific changes since the last
update.



1)      Added support in the PointGaussianMapper for rendering points as
points ( /golfclap ).  Sometimes in cosmology distant regions will be
rendered as points while closer regions are rendered as splats.  Now this
mapper can handle both cases. This also makes this mapper an efficient
mapper in VTK for rendering point clouds. It will render vtkPoints with
colors quickly and with minimal memory.



2)      Moved the new backend to OpenGL 3.2. While it still should mostly
work with OpenGL 2.1 our target version is 3.2 which adds some nice
features and yet is still fairly old. One of the big additions is support
for geometry shaders. VTK now supports the use of  geometry shaders and
vtkOpenGLPolyDataMapper has some features to help make writing a geometry
shader easier for all the numerous rendering cases VTK supports.



3)      One of the features OpenGL 3.2 does not always support is rendering
thick lines.  The spec only requires support for thicknesses up to 1.0.  So
we have implemented support in VTK using a geometry shader for thick lines
on systems that do not support them.



4)      Had a chance to work with the Mesa folks to fix an issue in Mesa
that was causing problems with cell coloring and picking. They were great
to work with and as of Mesa version 10.5.5 this is fixed.



5)      Made a large change to how cell coloring and picking was handled.
In the old OpenGL2 code we would duplicate vertices to handle cell coloring
so that each vertex was only used by one cell. This caused a huge explosion
in memory required for those cases. The new approach makes use of
gl_PrimitiveID to lookup cell colors (or cell normals or pick ids) in a
texture map which saves us from having to duplicate vertices. Unfortunately
gl_PrimitiveID is buggy on current Apple systems with AMD hardware so we
had to implement a workaround for those systems which does impact
performance on those systems. Apple is aware of the issue and will
hopefully have a fix in the future.



6)      Many fixes to vtkCompositePolyDataMapper2 to handle complex cases
that ParaView testing exposed.



Thanks

Ken



Ken Martin PhD

Chairman & CFO

Kitware Inc.

28 Corporate Drive

Clifton Park NY 12065

ken.martin at kitware.com

919 869-8871 (w)





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.



*From:* Ken Martin [mailto:ken.martin at kitware.com <ken.martin at kitware.com>]
*Sent:* Monday, February 2, 2015 11:26 AM
*To:* 'vtkdev'
*Subject:* Some OpenGL2 Polygonal Updates etc



Here are a few updates to the polygonal work we’ve been doing on the new
OpenGL2 backend in VTK.



1)      Created a vtkPointGaussianMapper [3] class for cosmology for
quickly rendering lots of translucent Gaussian splats.  This class will get
refined a bit as it starts getting used more. Similar in concept to the
PointSprite extensions that were added into Paraview by John Biddiscombe,
Ugo Varetto and Stephane Ploix from CSCS and EDF.



2)      Changed how the transformation matrices were handled in the vertex
shader [7]. It was doing V’ = VCDC * MCVC * V  and a couple tests were
failing. Instead we now compute MCDC on the CPU in double precision and
instead do V’ = MCDC * V in the shader which fixed the test and is
generally a better way to do it. We often need the other two matrices as
well which is why the original code just used those.



3)      Added a rendering timing framework/executable [5] to make it easier
to run test sequences across machines and see the results. Marcus and Rob
have expanded on it and Aashish has added a volume rendering test.



4)      Rewrote the vtkParametricFunctionSource [6] to be significantly
faster (4x) and more memory efficient.  We use this source to generate
surfaces for rendering timings and it was a bit slow.



5)      A bunch of fixes related to getting IceT to work with OpenGL2 [1]
which led to some release graphics resource issues being fixed [2].



6)      “Fixed” a longstanding failing test, TestChartXYZ [4] which was
intermittently failing on some systems.



7)      Marcus and Rob ran some rendering benchmarks showing upwards of 3
billion triangles per second on a 300 million triangle model. That is a big
model and some solid performance.





Currently I am wrapping up a change to the vtkCompositePolyDataMapper2 so
that in some common circumstances it will render significantly faster
(maybe 10x). This is targeted at helping apps that have lots of small
polygonal parts that are not glyphed. Also adding in support for texture
coordinate transformation matrices which are used by the GeoView classes in
VTK. Tim Thirion is fixing up some iOS build issues and David Lonnie is
working on removing an old text mapper that was causing some issues. JC has
been working on updating Slicer to build against the current VTK with
OpenGL2.



Thanks

Ken





[1] http://review.source.kitware.com/#/t/5130/

[2] http://review.source.kitware.com/#/t/5171/

[3] http://review.source.kitware.com/#/t/5198/

[4] http://review.source.kitware.com/#/t/5248/

[5] http://review.source.kitware.com/#/t/5276/

[6] http://review.source.kitware.com/#/t/5302/

[7] http://review.source.kitware.com/#/t/5327/





Ken Martin PhD

Chairman & CFO

Kitware Inc.

28 Corporate Drive

Clifton Park NY 12065

ken.martin at kitware.com

518 881-4901 (w)

518 371-4573 (f)



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/20150903/cfec7336/attachment.html>


More information about the vtkusers mailing list