diff -Nru paraview-5.4.1+dfsg3/debian/changelog paraview-5.4.1+dfsg4/debian/changelog --- paraview-5.4.1+dfsg3/debian/changelog 2017-09-20 21:30:47.000000000 +0000 +++ paraview-5.4.1+dfsg4/debian/changelog 2018-04-22 10:35:56.000000000 +0000 @@ -1,3 +1,50 @@ +paraview (5.4.1+dfsg4-3) unstable; urgency=medium + + * Team upload + * d/p/disable-local-FindMPI: fix FTBS with latest openmpi + * d/ruled: Remove forced MPI include path, it is no longer valid + + -- Gert Wollny Sun, 22 Apr 2018 12:35:56 +0200 + +paraview (5.4.1+dfsg4-2) unstable; urgency=medium + + * Team upload. + * [bd12fc4] d/p/fix_opengl_arm: use Extra OpenGL functions + Closes: #893735 + + -- Gert Wollny Fri, 23 Mar 2018 22:47:21 +0000 + +paraview (5.4.1+dfsg4-1) unstable; urgency=medium + + * Team upload. + * [a7b9430] New upstream version 5.4.1+dfsg4 + * [117a771] Use backend OpenGL2 + * [c5d2240] d/p/fix_gl2ps Update OpenGL2 backend + * [145a06f] d/rules: Switch to qt5 + * [a7aaa49] d/control: Switch to qt5 + * [fa81501] d/copyright: remove duplicate BSD-3-clause section + * [033db76] d/source: Add some overrides for the package + + -- Gert Wollny Thu, 15 Mar 2018 19:02:28 +0100 + +paraview (5.4.1+dfsg3-2) unstable; urgency=medium + + * Team upload. + + [ Gert Wollny ] + * [d289ee3] d/copyright: update copyright based on the ftp-master comments for vtk7 + + [ Anton Gladky ] + * [e9be492] Remove deprecated Testsuite-field + * [4952ac8] Set compat level to 11 + * [f2d150a] Set priority optional + * [f122067] Set Standards-Versions: 4.1.3 + * [c19be5e] Update VCS-fields + * [762408d] Apply cme fix dpkg + * [c1cfeae] Remove myself from uploaders + + -- Anton Gladky Wed, 07 Mar 2018 21:00:16 +0100 + paraview (5.4.1+dfsg3-1) unstable; urgency=medium * [de478ff] Use packaged protobuf version diff -Nru paraview-5.4.1+dfsg3/debian/compat paraview-5.4.1+dfsg4/debian/compat --- paraview-5.4.1+dfsg3/debian/compat 2017-09-20 16:21:23.000000000 +0000 +++ paraview-5.4.1+dfsg4/debian/compat 2018-04-22 10:35:56.000000000 +0000 @@ -1 +1 @@ -9 +11 diff -Nru paraview-5.4.1+dfsg3/debian/control paraview-5.4.1+dfsg4/debian/control --- paraview-5.4.1+dfsg3/debian/control 2017-09-20 21:26:57.000000000 +0000 +++ paraview-5.4.1+dfsg4/debian/control 2018-04-22 10:35:56.000000000 +0000 @@ -1,13 +1,16 @@ Source: paraview Maintainer: Debian Science Team -Uploaders: Anton Gladky Section: science -Testsuite: autopkgtest -Priority: extra -Build-Depends: debhelper (>= 9), +Priority: optional +Build-Depends: debhelper (>= 11), cmake, - libqt4-dev, - qt4-dev-tools, + qtbase5-dev, + libqt5opengl5-dev, + libqt5x11extras5-dev, + qttools5-dev, + qttools5-dev-tools, + qttools5-private-dev, + qtxmlpatterns5-dev-tools, libsqlite3-dev, libboost-all-dev, libavformat-dev, @@ -58,9 +61,9 @@ python-mpi4py, python-six, python-twisted -Standards-Version: 3.9.8 -Vcs-Browser: https://anonscm.debian.org/cgit/debian-science/packages/paraview.git -Vcs-Git: https://anonscm.debian.org/git/debian-science/packages/paraview.git +Standards-Version: 4.1.3 +Vcs-Browser: https://salsa.debian.org/science-team/paraview +Vcs-Git: https://salsa.debian.org/science-team/paraview.git Homepage: http://www.paraview.org/ Package: paraview diff -Nru paraview-5.4.1+dfsg3/debian/copyright paraview-5.4.1+dfsg4/debian/copyright --- paraview-5.4.1+dfsg3/debian/copyright 2017-09-20 21:26:36.000000000 +0000 +++ paraview-5.4.1+dfsg4/debian/copyright 2018-04-22 10:35:56.000000000 +0000 @@ -25,6 +25,7 @@ VTK/ThirdParty/ZopeInterface VTK/ThirdParty/mpi4py VTK/ThirdParty/Twisted + VTK/Rendering/VolumeOpenGL Plugins/SciberQuestToolKit/eigen* ThirdParty/cgns/vtkcgns/src ThirdParty/protobuf/vtkprotobuf/src @@ -35,33 +36,6 @@ 2000-2005 Kitware Inc. 28 Corporate Drive, Suite 204, Clifton Park, NY, 12065, USA. License: BSD-3-clause - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - . - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - . - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the - distribution. - . - * Neither the name of Kitware nor the names of any contributors may - be used to endorse or promote products derived from this software - without specific prior written permission. - . - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Files: VTK/ThirdParty/zlib/vtkzlib/* Copyright: 1995-2005 Jean-loup Gailly and Mark Adler @@ -715,7 +689,7 @@ If software is modified to produce derivative works, such modified software should be clearly marked, so as not to confuse it with the version available from LANL. - . + . Additionally, redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -728,7 +702,7 @@ Laboratory, LANL, the U.S. Government, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - . + . THIS SOFTWARE IS PROVIDED BY LOS ALAMOS NATIONAL SECURITY, LLC AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -742,8 +716,8 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Files: ThirdParty/pugixml/* -Copyright: 2006-2014, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) -License: MIT +Copyright: 2006-2014, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) +License: Expat * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without @@ -771,14 +745,14 @@ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - . + . * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - . + . * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - . + . THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -790,3 +764,240 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Files: Accelerators/Dax/* +Copyright: 2012 Sandia Corporation, Kitware Inc., + University of California Davis +License: BSD-3-clause + +Files: Examples/GUI/Qt/ImageViewer/main.cxx + Examples/GUI/Qt/Events/main.cxx + Examples/GUI/Qt/Events/GUI4.h +Copyright: 2004 Sandia Corporation +License: Sandia-2004 + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that this Notice and any + statement of authorship are reproduced on all copies. + +Files: Examples/GUI/Qt/Events/GUI4.cxx +Copyright: 2004 Sandia Corporation, + Ken Martin, Will Schroeder, Bill Lorensen +License: Sandia-2004+BSD-3-clause + Sandia-2004: Redistribution and use in source and binary forms, with + or without modification, are permitted provided that this Notice and any + statement of authorship are reproduced on all copies. + +Files: Examples/GUI/Qt/SimpleView/SimpleView.cxx + Examples/GUI/Qt/SimpleView/main.cxx + Examples/Infoviz/Cxx/CustomLinkView/CustomLinkView.* + Examples/Infoviz/Cxx/CustomLinkView/main.cxx + Examples/Infoviz/Cxx/EasyView/EasyView.h + Examples/Infoviz/Cxx/EasyView/main.cxx + Examples/Infoviz/Cxx/StatsView/Stats.* + Examples/Infoviz/Cxx/StatsView/main.cxx +Copyright: 2007 Sandia Corporation +License: Sandia-2007 + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that this Notice and any + statement of authorship are reproduced on all copies. + +Files: Examples/Statistics/*.cxx +Copyright: 2008 Sandia Corporation +License: Sandia-2008 + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that this Notice and any + statement of authorship are reproduced on all copies. + +Files: Examples/GUI/Qt/SimpleView/SimpleView.h + Examples/GUI/Qt/SimpleView/main.cxx + Examples/Infoviz/Cxx/EasyView/EasyView.h +Copyright: 2009 Sandia Corporation +License: Sandia-2009 + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that this Notice and any + statement of authorship are reproduced on all copies. + +Files: Infovis/Layout/vtkCosmicTreeLayoutStrategy.h + Infovis/Layout/vtkTreeOrbitLayoutStrategy.h +Copyright: 2005-2008 Sandia Corporation, Kitware Inc. + Sandia National Laboratories, New Mexico PO Box 5800 Albuquerque, NM 87185 + Kitware Inc., 28 Corporate Drive, Clifton Park, NY 12065, USA +License: BSD-3-clause + +Files: Common/Core/CaseFolding.txt +Copyright: 1991-2008 Unicode, Inc. +License: Unicode + Permission is hereby granted, free of charge, to any person obtaining + a copy of the Unicode data files and any associated documentation + (the "Data Files") or Unicode software and any associated documentation + (the "Software") to deal in the Data Files or Software + without restriction, including without limitation the rights to use, + copy, modify, merge, publish, distribute, and/or sell copies of + the Data Files or Software, and to permit persons to whom the Data Files + or Software are furnished to do so, provided that either + (a) this copyright and permission notice appear with all copies + of the Data Files or Software, or + (b) this copyright and permission notice appear in associated + Documentation. + . + THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF + ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT OF THIRD PARTY RIGHTS. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS + NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL + DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THE DATA FILES OR SOFTWARE. + . + Except as contained in this notice, the name of a copyright holder + shall not be used in advertising or otherwise to promote the sale, + use or other dealings in these Data Files or Software without prior + written authorization of the copyright holder. + +Files: Imaging/Morphological/vtkImageConnectivityFilter.* +Copyright: 2014 David Gobbi +License: BSD-3-clause + +Files: Examples/Android/NativeVTK/jni/main.cxx Examples/Android/JavaVTK/src/com/kitware/JavaVTK/* + Examples/Android/JavaVTK/jni/main.cxx + Interaction/Widgets/Testing/Cxx/TestPickingManager* +Copyright: 2007-2010 The Android Open Source Project +License: Apache-2 + +Files: Interaction/Widgets/Testing/Cxx/TestPickingManagerWidgets.cxx + Interaction/Widgets/Testing/Cxx/TestPickingManagerSeedWidget.cxx + Rendering/Core/Testing/Cxx/TestPickingManager.cxx + Rendering/Core/vtkPickingManager.* + Utilities/Scripts/SetupExternalData.sh +Copyright: Kitware Inc +License: Apache-2 + +Files: Rendering/OpenGL2/vtkDepthImageProcessingPass.cxx + Rendering/OpenGL2/vtkDepthImageProcessingPass.h + Rendering/OpenGL2/vtkEDLShading.cxx + Rendering/OpenGL2/vtkEDLShading.h +Copyright: 2005-2008 Sandia Corporation, Kitware Inc. +License: BSD-3-clause + +Files: Utilities/MetaIO/vtkmetaio/metaFEMObject.* + Utilities/Maintenance/ArchiveTestingData.py + Utilities/Maintenance/computeCodeCoverageLocally.sh + Utilities/Maintenance/SourceTarball.bash + Utilities/Maintenance/computeCodeCoverageLocallyForOneTest.sh +Copyright: Insight Software Consortium +License: Apache-2 + +Files: Common/Core/vtkMersenneTwister_Private.cxx + Common/Core/vtkMersenneTwister.h +Copyright: (C) 2001-2009 Makoto Matsumoto and Takuji Nishimura. + (C) 2009 Mutsuo Saito +License: BSD-2-clause + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + . + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Files: Common/Color/vtkColorSeries.* +Copyright: 2010 Brewer, Cynthia A. and Mark Harrower and Andy Woodruff and David Heyman +License: Apache-2-modified + The color schemes below are copyright under the following license, excerpted + from http://www.personal.psu.edu/cab38/ColorBrewer/ColorBrewer_updates.html + on August 13, 2012: + . + Apache-Style Software License for ColorBrewer software and + ColorBrewer Color Schemes + . + Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The Pennsylvania + State University. + . + Licensed under the Apache License, Version 2.0 (the "License"); you may not + use this file except in compliance with the License. + You may obtain a copy of the License at + . + http://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + License for the specific language governing permissions and limitations + under the License. + . + This text from my earlier Apache License Version 1.1 also remains in place for + guidance on attribution and permissions: + . + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions as source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: + "This product includes color specifications and designs developed by + Cynthia Brewer (http://colorbrewer.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + 4. The name "ColorBrewer" must not be used to endorse or promote products + derived from this software without prior written permission. For written + permission, please contact Cynthia Brewer at cbrewer@psu.edu. + 5. Products derived from this software may not be called "ColorBrewer", nor + may "ColorBrewer" appear in their name, without prior written permission + of Cynthia Brewer. + +Files: Filters/Parallel/vtkBlockDistribution.h + Infovis/Parallel/vtkPBGLConnectedComponents.cxx + Infovis/Parallel/Testing/Cxx/* + Infovis/Parallel/* + Infovis/Boost/Testing/Cxx/TestVariantSerialization.cxx + Infovis/Boost/vtkVariantBoostSerialization.h + Infovis/BoostGraphAlgorithms/vtkBoostBreadthFirstSearch.cxx + Common/DataModel/vtkDistributedGraphHelper.* +Copyright: 2008 The Trustees of Indiana University +License: Boost-1.0 + Boost Software License - Version 1.0 - August 17th, 2003 + . + Permission is hereby granted, free of charge, to any person or organization + obtaining a copy of the software and accompanying documentation covered by + this license (the "Software") to use, reproduce, display, distribute, + execute, and transmit the Software, and to prepare derivative works of the + Software, and to permit third-parties to whom the Software is furnished to + do so, all subject to the following: + . + The copyright notices in the Software and this entire statement, including + the above license grant, this restriction and the following disclaimer, + must be included in all copies of the Software, in whole or in part, and + all derivative works of the Software, unless such copies or derivative + works are solely in the form of machine-executable object code generated by + a source language processor. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT + SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE + FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + +License: Apache-2 + On Debian systems, the full text of the Apache License + Version 2.0 can be found in the file + `/usr/share/common-licenses/Apache-2.0'. + diff -Nru paraview-5.4.1+dfsg3/debian/patches/disable-local-FindMPI.patch paraview-5.4.1+dfsg4/debian/patches/disable-local-FindMPI.patch --- paraview-5.4.1+dfsg3/debian/patches/disable-local-FindMPI.patch 1970-01-01 00:00:00.000000000 +0000 +++ paraview-5.4.1+dfsg4/debian/patches/disable-local-FindMPI.patch 2018-04-22 10:35:56.000000000 +0000 @@ -0,0 +1,648 @@ +Description: Remove the FindMPI distributed by this package + since it doesn't find the proper include paths. The system cmake + provided version is better at this. +Author: Gert Wollny +Last-Changed: 2018-04-22 + +--- a/VTK/CMake/FindMPI.cmake ++++ /dev/null +@@ -1,639 +0,0 @@ +-# - Find a Message Passing Interface (MPI) implementation +-# The Message Passing Interface (MPI) is a library used to write +-# high-performance distributed-memory parallel applications, and +-# is typically deployed on a cluster. MPI is a standard interface +-# (defined by the MPI forum) for which many implementations are +-# available. All of them have somewhat different include paths, +-# libraries to link against, etc., and this module tries to smooth +-# out those differences. +-# +-# === Variables === +-# +-# This module will set the following variables per language in your project, +-# where is one of C, CXX, or Fortran: +-# MPI__FOUND TRUE if FindMPI found MPI flags for +-# MPI__COMPILER MPI Compiler wrapper for +-# MPI__COMPILE_FLAGS Compilation flags for MPI programs +-# MPI__INCLUDE_PATH Include path(s) for MPI header +-# MPI__LINK_FLAGS Linking flags for MPI programs +-# MPI__LIBRARIES All libraries to link MPI programs against +-# Additionally, FindMPI sets the following variables for running MPI +-# programs from the command line: +-# MPIEXEC Executable for running MPI programs +-# MPIEXEC_NUMPROC_FLAG Flag to pass to MPIEXEC before giving +-# it the number of processors to run on +-# MPIEXEC_PREFLAGS Flags to pass to MPIEXEC directly +-# before the executable to run. +-# MPIEXEC_POSTFLAGS Flags to pass to MPIEXEC after other flags +-# === Usage === +-# +-# To use this module, simply call FindMPI from a CMakeLists.txt file, or +-# run find_package(MPI), then run CMake. If you are happy with the auto- +-# detected configuration for your language, then you're done. If not, you +-# have two options: +-# 1. Set MPI__COMPILER to the MPI wrapper (mpicc, etc.) of your +-# choice and reconfigure. FindMPI will attempt to determine all the +-# necessary variables using THAT compiler's compile and link flags. +-# 2. If this fails, or if your MPI implementation does not come with +-# a compiler wrapper, then set both MPI__LIBRARIES and +-# MPI__INCLUDE_PATH. You may also set any other variables +-# listed above, but these two are required. This will circumvent +-# autodetection entirely. +-# When configuration is successful, MPI__COMPILER will be set to the +-# compiler wrapper for , if it was found. MPI__FOUND and other +-# variables above will be set if any MPI implementation was found for , +-# regardless of whether a compiler was found. +-# +-# When using MPIEXEC to execute MPI applications, you should typically use +-# all of the MPIEXEC flags as follows: +-# ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} PROCS +-# ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS +-# where PROCS is the number of processors on which to execute the program, +-# EXECUTABLE is the MPI program, and ARGS are the arguments to pass to the +-# MPI program. +-# +-# === Backward Compatibility === +-# +-# For backward compatibility with older versions of FindMPI, these +-# variables are set, but deprecated: +-# MPI_FOUND MPI_COMPILER MPI_LIBRARY +-# MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_EXTRA_LIBRARY +-# MPI_LINK_FLAGS MPI_LIBRARIES +-# In new projects, please use the MPI__XXX equivalents. +- +-#============================================================================= +-# Copyright 2001-2011 Kitware, Inc. +-# Copyright 2010-2011 Todd Gamblin tgamblin@llnl.gov +-# Copyright 2001-2009 Dave Partyka +-# +-# Distributed under the OSI-approved BSD License (the "License"); +-# see accompanying file Copyright.txt for details. +-# +-# This software is distributed WITHOUT ANY WARRANTY; without even the +-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +-# See the License for more information. +-#============================================================================= +-# (To distribute this file outside of CMake, substitute the full +-# License text for the above reference.) +- +-# include this to handle the QUIETLY and REQUIRED arguments +-include(FindPackageHandleStandardArgs) +- +-# +-# This part detects MPI compilers, attempting to wade through the mess of compiler names in +-# a sensible way. +-# +-# The compilers are detected in this order: +-# +-# 1. Try to find the most generic available MPI compiler, as this is usually set up by +-# cluster admins. e.g., if plain old mpicc is available, we'll use it and assume it's +-# the right compiler. +-# +-# 2. If a generic mpicc is NOT found, then we attempt to find one that matches +-# CMAKE__COMPILER_ID. e.g. if you are using XL compilers, we'll try to find mpixlc +-# and company, but not mpiicc. This hopefully prevents toolchain mismatches. +-# +-# If you want to force a particular MPI compiler other than what we autodetect (e.g. if you +-# want to compile regular stuff with GNU and parallel stuff with Intel), you can always set +-# your favorite MPI__COMPILER explicitly and this stuff will be ignored. +-# +- +-# Start out with the generic MPI compiler names, as these are most commonly used. +-set(_MPI_C_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r) +-set(_MPI_CXX_COMPILER_NAMES mpicxx mpiCC mpcxx mpCC mpic++ mpc++ +- mpicxx_r mpiCC_r mpcxx_r mpCC_r mpic++_r mpc++_r) +-set(_MPI_Fortran_COMPILER_NAMES mpif95 mpif95_r mpf95 mpf95_r +- mpif90 mpif90_r mpf90 mpf90_r +- mpif77 mpif77_r mpf77 mpf77_r) +- +-# GNU compiler names +-set(_MPI_GNU_C_COMPILER_NAMES mpigcc mpgcc mpigcc_r mpgcc_r) +-set(_MPI_GNU_CXX_COMPILER_NAMES mpig++ mpg++ mpig++_r mpg++_r) +-set(_MPI_GNU_Fortran_COMPILER_NAMES mpigfortran mpgfortran mpigfortran_r mpgfortran_r +- mpig77 mpig77_r mpg77 mpg77_r) +- +-# Intel MPI compiler names +-set(_MPI_Intel_C_COMPILER_NAMES mpiicc) +-set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc mpiicxx mpiic++ mpiiCC) +-set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort mpiif95 mpiif90 mpiif77) +- +-# PGI compiler names +-set(_MPI_PGI_C_COMPILER_NAMES mpipgcc mppgcc) +-set(_MPI_PGI_CXX_COMPILER_NAMES mpipgCC mppgCC) +-set(_MPI_PGI_Fortran_COMPILER_NAMES mpipgf95 mpipgf90 mppgf95 mppgf90 mpipgf77 mppgf77) +- +-# XLC MPI Compiler names +-set(_MPI_XL_C_COMPILER_NAMES mpxlc mpxlc_r mpixlc mpixlc_r) +-set(_MPI_XL_CXX_COMPILER_NAMES mpixlcxx mpixlC mpixlc++ mpxlcxx mpxlc++ mpixlc++ mpxlCC +- mpixlcxx_r mpixlC_r mpixlc++_r mpxlcxx_r mpxlc++_r mpixlc++_r mpxlCC_r) +-set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95_r +- mpixlf90 mpixlf90_r mpxlf90 mpxlf90_r +- mpixlf77 mpixlf77_r mpxlf77 mpxlf77_r +- mpixlf mpixlf_r mpxlf mpxlf_r) +- +-# append vendor-specific compilers to the list if we either don't know the compiler id, +-# or if we know it matches the regular compiler. +-foreach (lang C CXX Fortran) +- foreach (id GNU Intel PGI XL) +- if (NOT CMAKE_${lang}_COMPILER_ID OR CMAKE_${lang}_COMPILER_ID STREQUAL id) +- list(APPEND _MPI_${lang}_COMPILER_NAMES ${_MPI_${id}_${lang}_COMPILER_NAMES}) +- endif() +- unset(_MPI_${id}_${lang}_COMPILER_NAMES) # clean up the namespace here +- endforeach() +-endforeach() +- +- +-# Names to try for MPI exec +-set(_MPI_EXEC_NAMES mpiexec mpirun lamexec srun) +- +-# Grab the path to MPI from the registry if we're on windows. +-set(_MPI_PREFIX_PATH) +-if(WIN32) +- # MSMPI +- file(TO_CMAKE_PATH "$ENV{MSMPI_BIN}" msmpi_bin_path) # The default path ends with a '\' and doesn't mix with ';' when appending. +- list(APPEND _MPI_PREFIX_PATH "${msmpi_bin_path}") +- unset(msmpi_bin_path) +- list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MPI;InstallRoot]/Bin") +- list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\HPC;HpcMpiInstallDir]/..") +- list(APPEND _MPI_PREFIX_PATH "$ENV{MSMPI_INC}/..") # The SDK is installed separately from the runtime +- # MPICH +- list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/..") +- list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH2;Path]") +- list(APPEND _MPI_PREFIX_PATH "$ENV{ProgramW6432}/MPICH2/") +-endif() +- +-# Build a list of prefixes to search for MPI. +-foreach(SystemPrefixDir ${CMAKE_SYSTEM_PREFIX_PATH}) +- foreach(MpiPackageDir ${_MPI_PREFIX_PATH}) +- if(EXISTS ${SystemPrefixDir}/${MpiPackageDir}) +- list(APPEND _MPI_PREFIX_PATH "${SystemPrefixDir}/${MpiPackageDir}") +- endif() +- endforeach() +-endforeach() +- +- +-# +-# interrogate_mpi_compiler(lang try_libs) +-# +-# Attempts to extract compiler and linker args from an MPI compiler. The arguments set +-# by this function are: +-# +-# MPI__INCLUDE_PATH MPI__LINK_FLAGS MPI__FOUND +-# MPI__COMPILE_FLAGS MPI__LIBRARIES +-# +-# MPI__COMPILER must be set beforehand to the absolute path to an MPI compiler for +-# . Additionally, MPI__INCLUDE_PATH and MPI__LIBRARIES may be set +-# to skip autodetection. +-# +-# If try_libs is TRUE, this will also attempt to find plain MPI libraries in the usual +-# way. In general, this is not as effective as interrogating the compilers, as it +-# ignores language-specific flags and libraries. However, some MPI implementations +-# (Windows implementations) do not have compiler wrappers, so this approach must be used. +-# +-function (interrogate_mpi_compiler lang try_libs) +- # MPI_${lang}_NO_INTERROGATE will be set to a compiler name when the *regular* compiler was +- # discovered to be the MPI compiler. This happens on machines like the Cray XE6 that use +- # modules to set cc, CC, and ftn to the MPI compilers. If the user force-sets another MPI +- # compiler, MPI_${lang}_COMPILER won't be equal to MPI_${lang}_NO_INTERROGATE, and we'll +- # inspect that compiler anew. This allows users to set new compilers w/o rm'ing cache. +- string(COMPARE NOTEQUAL "${MPI_${lang}_NO_INTERROGATE}" "${MPI_${lang}_COMPILER}" interrogate) +- +- # If MPI is set already in the cache, don't bother with interrogating the compiler. +- if (interrogate AND ((NOT MPI_${lang}_INCLUDE_PATH) OR (NOT MPI_${lang}_LIBRARIES))) +- if (MPI_${lang}_COMPILER) +- # Check whether the -showme:compile option works. This indicates that we have either OpenMPI +- # or a newer version of LAM-MPI, and implies that -showme:link will also work. +- execute_process( +- COMMAND ${MPI_${lang}_COMPILER} -showme:compile +- OUTPUT_VARIABLE MPI_COMPILE_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE +- ERROR_VARIABLE MPI_COMPILE_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE +- RESULT_VARIABLE MPI_COMPILER_RETURN) +- +- if (MPI_COMPILER_RETURN EQUAL 0) +- # If we appear to have -showme:compile, then we should +- # also have -showme:link. Try it. +- execute_process( +- COMMAND ${MPI_${lang}_COMPILER} -showme:link +- OUTPUT_VARIABLE MPI_LINK_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE +- ERROR_VARIABLE MPI_LINK_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE +- RESULT_VARIABLE MPI_COMPILER_RETURN) +- +- if (MPI_COMPILER_RETURN EQUAL 0) +- # We probably have -showme:incdirs and -showme:libdirs as well, +- # so grab that while we're at it. +- execute_process( +- COMMAND ${MPI_${lang}_COMPILER} -showme:incdirs +- OUTPUT_VARIABLE MPI_INCDIRS OUTPUT_STRIP_TRAILING_WHITESPACE +- ERROR_VARIABLE MPI_INCDIRS ERROR_STRIP_TRAILING_WHITESPACE) +- +- execute_process( +- COMMAND ${MPI_${lang}_COMPILER} -showme:libdirs +- OUTPUT_VARIABLE MPI_LIBDIRS OUTPUT_STRIP_TRAILING_WHITESPACE +- ERROR_VARIABLE MPI_LIBDIRS ERROR_STRIP_TRAILING_WHITESPACE) +- +- else() +- # reset things here if something went wrong. +- set(MPI_COMPILE_CMDLINE) +- set(MPI_LINK_CMDLINE) +- endif() +- endif () +- +- # Older versions of LAM-MPI have "-showme". Try to find that. +- if (NOT MPI_COMPILER_RETURN EQUAL 0) +- execute_process( +- COMMAND ${MPI_${lang}_COMPILER} -showme +- OUTPUT_VARIABLE MPI_COMPILE_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE +- ERROR_VARIABLE MPI_COMPILE_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE +- RESULT_VARIABLE MPI_COMPILER_RETURN) +- endif() +- +- # MVAPICH uses -compile-info and -link-info. Try them. +- if (NOT MPI_COMPILER_RETURN EQUAL 0) +- execute_process( +- COMMAND ${MPI_${lang}_COMPILER} -compile-info +- OUTPUT_VARIABLE MPI_COMPILE_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE +- ERROR_VARIABLE MPI_COMPILE_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE +- RESULT_VARIABLE MPI_COMPILER_RETURN) +- +- # If we have compile-info, also have link-info. +- if (MPI_COMPILER_RETURN EQUAL 0) +- execute_process( +- COMMAND ${MPI_${lang}_COMPILER} -link-info +- OUTPUT_VARIABLE MPI_LINK_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE +- ERROR_VARIABLE MPI_LINK_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE +- RESULT_VARIABLE MPI_COMPILER_RETURN) +- endif() +- +- # make sure we got compile and link. Reset vars if something's wrong. +- if (NOT MPI_COMPILER_RETURN EQUAL 0) +- set(MPI_COMPILE_CMDLINE) +- set(MPI_LINK_CMDLINE) +- endif() +- endif() +- +- # MPICH just uses "-show". Try it. +- if (NOT MPI_COMPILER_RETURN EQUAL 0) +- execute_process( +- COMMAND ${MPI_${lang}_COMPILER} -show +- OUTPUT_VARIABLE MPI_COMPILE_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE +- ERROR_VARIABLE MPI_COMPILE_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE +- RESULT_VARIABLE MPI_COMPILER_RETURN) +- endif() +- +- if (MPI_COMPILER_RETURN EQUAL 0) +- # We have our command lines, but we might need to copy MPI_COMPILE_CMDLINE +- # into MPI_LINK_CMDLINE, if we didn't find the link line. +- if (NOT MPI_LINK_CMDLINE) +- set(MPI_LINK_CMDLINE ${MPI_COMPILE_CMDLINE}) +- endif() +- else() +- message(STATUS "Unable to determine MPI from MPI driver ${MPI_${lang}_COMPILER}") +- set(MPI_COMPILE_CMDLINE) +- set(MPI_LINK_CMDLINE) +- endif() +- +- # Here, we're done with the interrogation part, and we'll try to extract args we care +- # about from what we learned from the compiler wrapper scripts. +- +- # If interrogation came back with something, extract our variable from the MPI command line +- if (MPI_COMPILE_CMDLINE OR MPI_LINK_CMDLINE) +- # Extract compile flags from the compile command line. +- string(REGEX MATCHALL "(^| )-[Df]([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_FLAGS "${MPI_COMPILE_CMDLINE}") +- set(MPI_COMPILE_FLAGS_WORK) +- +- foreach(FLAG ${MPI_ALL_COMPILE_FLAGS}) +- if (MPI_COMPILE_FLAGS_WORK) +- set(MPI_COMPILE_FLAGS_WORK "${MPI_COMPILE_FLAGS_WORK} ${FLAG}") +- else() +- set(MPI_COMPILE_FLAGS_WORK ${FLAG}) +- endif() +- endforeach() +- +- # Extract include paths from compile command line +- string(REGEX MATCHALL "(^| )-I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") +- foreach(IPATH ${MPI_ALL_INCLUDE_PATHS}) +- string(REGEX REPLACE "^ ?-I" "" IPATH ${IPATH}) +- string(REGEX REPLACE "//" "/" IPATH ${IPATH}) +- list(APPEND MPI_INCLUDE_PATH_WORK ${IPATH}) +- endforeach() +- +- # try using showme:incdirs if extracting didn't work. +- if (NOT MPI_INCLUDE_PATH_WORK) +- set(MPI_INCLUDE_PATH_WORK ${MPI_INCDIRS}) +- separate_arguments(MPI_INCLUDE_PATH_WORK) +- endif() +- +- # If all else fails, just search for mpi.h in the normal include paths. +- if (NOT MPI_INCLUDE_PATH_WORK) +- set(MPI_HEADER_PATH "MPI_HEADER_PATH-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) +- find_path(MPI_HEADER_PATH mpi.h +- HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} +- PATH_SUFFIXES include) +- set(MPI_INCLUDE_PATH_WORK ${MPI_HEADER_PATH}) +- endif() +- +- # Extract linker paths from the link command line +- string(REGEX MATCHALL "(^| |-Wl,)-L([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") +- set(MPI_LINK_PATH) +- foreach(LPATH ${MPI_ALL_LINK_PATHS}) +- string(REGEX REPLACE "^(| |-Wl,)-L" "" LPATH ${LPATH}) +- string(REGEX REPLACE "//" "/" LPATH ${LPATH}) +- list(APPEND MPI_LINK_PATH ${LPATH}) +- endforeach() +- +- # try using showme:libdirs if extracting didn't work. +- if (NOT MPI_LINK_PATH) +- set(MPI_LINK_PATH ${MPI_LIBDIRS}) +- separate_arguments(MPI_LINK_PATH) +- endif() +- +- # Extract linker flags from the link command line +- string(REGEX MATCHALL "(^| )-Wl,([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") +- set(MPI_LINK_FLAGS_WORK) +- foreach(FLAG ${MPI_ALL_LINK_FLAGS}) +- if (MPI_LINK_FLAGS_WORK) +- set(MPI_LINK_FLAGS_WORK "${MPI_LINK_FLAGS_WORK} ${FLAG}") +- else() +- set(MPI_LINK_FLAGS_WORK ${FLAG}) +- endif() +- endforeach() +- +- # Extract the set of libraries to link against from the link command +- # line +- string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") +- # add the compiler implicit directories because some compilers +- # such as the intel compiler have libraries that show up +- # in the showme list that can only be found in the implicit +- # link directories of the compiler. Do this for C++ and C +- # compilers if the implicit link directories are defined. +- if (DEFINED CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES) +- set(MPI_LINK_PATH +- "${MPI_LINK_PATH};${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES}") +- endif () +- +- if (DEFINED CMAKE_C_IMPLICIT_LINK_DIRECTORIES) +- set(MPI_LINK_PATH +- "${MPI_LINK_PATH};${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") +- endif () +- +- # Determine full path names for all of the libraries that one needs +- # to link against in an MPI program +- foreach(LIB ${MPI_LIBNAMES}) +- string(REGEX REPLACE "^ ?-l" "" LIB ${LIB}) +- # MPI_LIB is cached by find_library, but we don't want that. Clear it first. +- set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) +- find_library(MPI_LIB NAMES ${LIB} HINTS ${MPI_LINK_PATH}) +- +- if (MPI_LIB) +- list(APPEND MPI_LIBRARIES_WORK ${MPI_LIB}) +- elseif (NOT MPI_FIND_QUIETLY) +- message(WARNING "Unable to find MPI library ${LIB}") +- endif() +- endforeach() +- +- # Sanity check MPI_LIBRARIES to make sure there are enough libraries +- list(LENGTH MPI_LIBRARIES_WORK MPI_NUMLIBS) +- list(LENGTH MPI_LIBNAMES MPI_NUMLIBS_EXPECTED) +- if (NOT MPI_NUMLIBS EQUAL MPI_NUMLIBS_EXPECTED) +- set(MPI_LIBRARIES_WORK "MPI_${lang}_LIBRARIES-NOTFOUND") +- endif() +- endif() +- +- elseif(try_libs) +- # If we didn't have an MPI compiler script to interrogate, attempt to find everything +- # with plain old find functions. This is nasty because MPI implementations have LOTS of +- # different library names, so this section isn't going to be very generic. We need to +- # make sure it works for MS MPI, though, since there are no compiler wrappers for that. +- find_path(MPI_HEADER_PATH mpi.h +- HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} +- PATH_SUFFIXES include Inc) +- set(MPI_INCLUDE_PATH_WORK ${MPI_HEADER_PATH}) +- +- # Decide between 32-bit and 64-bit libraries for Microsoft's MPI +- if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) +- set(MS_MPI_ARCH_DIR x64) +- set(MS_MPI_ARCH_DIR2 amd64) +- else() +- set(MS_MPI_ARCH_DIR x86) +- set(MS_MPI_ARCH_DIR2 i386) +- endif() +- +- set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) +- find_library(MPI_LIB +- NAMES mpi mpich mpich2 msmpi +- HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} +- PATH_SUFFIXES lib lib/${MS_MPI_ARCH_DIR} Lib Lib/${MS_MPI_ARCH_DIR} Lib/${MS_MPI_ARCH_DIR2}) +- set(MPI_LIBRARIES_WORK ${MPI_LIB}) +- +- # Right now, we only know about the extra libs for C++. +- # We could add Fortran here (as there is usually libfmpich, etc.), but +- # this really only has to work with MS MPI on Windows. +- # Assume that other MPI's are covered by the compiler wrappers. +- if (${lang} STREQUAL CXX) +- set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) +- find_library(MPI_LIB +- NAMES mpi++ mpicxx cxx mpi_cxx +- HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} +- PATH_SUFFIXES lib) +- if (MPI_LIBRARIES_WORK AND MPI_LIB) +- list(APPEND MPI_LIBRARIES_WORK ${MPI_LIB}) +- endif() +- endif() +- +- if (NOT MPI_LIBRARIES_WORK) +- set(MPI_LIBRARIES_WORK "MPI_${lang}_LIBRARIES-NOTFOUND") +- endif() +- endif() +- +- # If we found MPI, set up all of the appropriate cache entries +- set(MPI_${lang}_COMPILE_FLAGS ${MPI_COMPILE_FLAGS_WORK} CACHE STRING "MPI ${lang} compilation flags" FORCE) +- set(MPI_${lang}_INCLUDE_PATH ${MPI_INCLUDE_PATH_WORK} CACHE STRING "MPI ${lang} include path" FORCE) +- set(MPI_${lang}_LINK_FLAGS ${MPI_LINK_FLAGS_WORK} CACHE STRING "MPI ${lang} linking flags" FORCE) +- set(MPI_${lang}_LIBRARIES ${MPI_LIBRARIES_WORK} CACHE STRING "MPI ${lang} libraries to link against" FORCE) +- mark_as_advanced(MPI_${lang}_COMPILE_FLAGS MPI_${lang}_INCLUDE_PATH MPI_${lang}_LINK_FLAGS MPI_${lang}_LIBRARIES) +- +- # clear out our temporary lib/header detectionv variable here. +- set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI lib detection" FORCE) +- set(MPI_HEADER_PATH "MPI_HEADER_PATH-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI header detection" FORCE) +- endif() +- +- # finally set a found variable for each MPI language +- if (MPI_${lang}_INCLUDE_PATH AND MPI_${lang}_LIBRARIES) +- set(MPI_${lang}_FOUND TRUE PARENT_SCOPE) +- else() +- set(MPI_${lang}_FOUND FALSE PARENT_SCOPE) +- endif() +-endfunction() +- +- +-# This function attempts to compile with the regular compiler, to see if MPI programs +-# work with it. This is a last ditch attempt after we've tried interrogating mpicc and +-# friends, and after we've tried to find generic libraries. Works on machines like +-# Cray XE6, where the modules environment changes what MPI version cc, CC, and ftn use. +-function(try_regular_compiler lang success) +- set(scratch_directory ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}) +- if (${lang} STREQUAL Fortran) +- set(test_file ${scratch_directory}/cmake_mpi_test.f90) +- file(WRITE ${test_file} +- "program hello\n" +- "include 'mpif.h'\n" +- "integer ierror\n" +- "call MPI_INIT(ierror)\n" +- "call MPI_FINALIZE(ierror)\n" +- "end\n") +- else() +- if (${lang} STREQUAL CXX) +- set(test_file ${scratch_directory}/cmake_mpi_test.cpp) +- else() +- set(test_file ${scratch_directory}/cmake_mpi_test.c) +- endif() +- file(WRITE ${test_file} +- "#include \n" +- "int main(int argc, char **argv) {\n" +- " MPI_Init(&argc, &argv);\n" +- " MPI_Finalize();\n" +- "}\n") +- endif() +- try_compile(compiler_has_mpi ${scratch_directory} ${test_file}) +- if (compiler_has_mpi) +- set(MPI_${lang}_NO_INTERROGATE ${CMAKE_${lang}_COMPILER} CACHE STRING "Whether to interrogate MPI ${lang} compiler" FORCE) +- set(MPI_${lang}_COMPILER ${CMAKE_${lang}_COMPILER} CACHE STRING "MPI ${lang} compiler" FORCE) +- set(MPI_${lang}_COMPILE_FLAGS "" CACHE STRING "MPI ${lang} compilation flags" FORCE) +- set(MPI_${lang}_INCLUDE_PATH "" CACHE STRING "MPI ${lang} include path" FORCE) +- set(MPI_${lang}_LINK_FLAGS "" CACHE STRING "MPI ${lang} linking flags" FORCE) +- set(MPI_${lang}_LIBRARIES "" CACHE STRING "MPI ${lang} libraries to link against" FORCE) +- endif() +- set(${success} ${compiler_has_mpi} PARENT_SCOPE) +- unset(compiler_has_mpi CACHE) +-endfunction() +- +-# End definitions, commence real work here. +- +-# Most mpi distros have some form of mpiexec which gives us something we can reliably look for. +-find_program(MPIEXEC +- NAMES ${_MPI_EXEC_NAMES} +- PATHS ${_MPI_PREFIX_PATH} +- PATH_SUFFIXES bin +- DOC "Executable for running MPI programs.") +- +-# call get_filename_component twice to remove mpiexec and the directory it exists in (typically bin). +-# This gives us a fairly reliable base directory to search for /bin /lib and /include from. +-get_filename_component(_MPI_BASE_DIR "${MPIEXEC}" PATH) +-get_filename_component(_MPI_BASE_DIR "${_MPI_BASE_DIR}" PATH) +- +-set(MPIEXEC_NUMPROC_FLAG "-np" CACHE STRING "Flag used by MPI to specify the number of processes for MPIEXEC; the next option will be the number of processes.") +-set(MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by MPIEXEC.") +-set(MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will come after all flags given to MPIEXEC.") +-set(MPIEXEC_MAX_NUMPROCS "2" CACHE STRING "Maximum number of processors available to run MPI applications.") +-mark_as_advanced(MPIEXEC MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXEC_POSTFLAGS MPIEXEC_MAX_NUMPROCS) +- +- +-#============================================================================= +-# Backward compatibility input hacks. Propagate the FindMPI hints to C and +-# CXX if the respective new versions are not defined. Translate the old +-# MPI_LIBRARY and MPI_EXTRA_LIBRARY to respective MPI_${lang}_LIBRARIES. +-# +-# Once we find the new variables, we translate them back into their old +-# equivalents below. +-foreach (lang C CXX) +- # Old input variables. +- set(_MPI_OLD_INPUT_VARS COMPILER COMPILE_FLAGS INCLUDE_PATH LINK_FLAGS) +- +- # Set new vars based on their old equivalents, if the new versions are not already set. +- foreach (var ${_MPI_OLD_INPUT_VARS}) +- if (NOT MPI_${lang}_${var} AND MPI_${var}) +- set(MPI_${lang}_${var} "${MPI_${var}}") +- endif() +- endforeach() +- +- # Special handling for MPI_LIBRARY and MPI_EXTRA_LIBRARY, which we nixed in the +- # new FindMPI. These need to be merged into MPI__LIBRARIES +- if (NOT MPI_${lang}_LIBRARIES AND (MPI_LIBRARY OR MPI_EXTRA_LIBRARY)) +- set(MPI_${lang}_LIBRARIES ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY}) +- endif() +-endforeach() +-#============================================================================= +- +- +-# This loop finds the compilers and sends them off for interrogation. +-foreach (lang C CXX Fortran) +- if (CMAKE_${lang}_COMPILER_WORKS) +- # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler. +- if (MPI_${lang}_COMPILER) +- if (NOT IS_ABSOLUTE "${MPI_${lang}_COMPILER}") +- # Get rid of our default list of names and just search for the name the user wants. +- set(_MPI_${lang}_COMPILER_NAMES ${MPI_${lang}_COMPILER}) +- set(MPI_${lang}_COMPILER "MPI_${lang}_COMPILER-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) +- endif() +- # If the user specifies a compiler, we don't want to try to search libraries either. +- set(try_libs FALSE) +- else() +- set(try_libs TRUE) +- endif() +- +- find_program(MPI_${lang}_COMPILER +- NAMES ${_MPI_${lang}_COMPILER_NAMES} +- PATHS "${MPI_HOME}/bin" "$ENV{MPI_HOME}/bin" ${_MPI_PREFIX_PATH}) +- interrogate_mpi_compiler(${lang} ${try_libs}) +- mark_as_advanced(MPI_${lang}_COMPILER) +- +- # last ditch try -- if nothing works so far, just try running the regular compiler and +- # see if we can create an MPI executable. +- set(regular_compiler_worked 0) +- if (NOT MPI_${lang}_LIBRARIES OR NOT MPI_${lang}_INCLUDE_PATH) +- try_regular_compiler(${lang} regular_compiler_worked) +- endif() +- +- if (regular_compiler_worked) +- find_package_handle_standard_args(MPI_${lang} DEFAULT_MSG MPI_${lang}_COMPILER) +- else() +- find_package_handle_standard_args(MPI_${lang} DEFAULT_MSG MPI_${lang}_LIBRARIES MPI_${lang}_INCLUDE_PATH) +- endif() +- endif() +-endforeach() +- +- +-#============================================================================= +-# More backward compatibility stuff +-# +-# Bare MPI sans ${lang} vars are set to CXX then C, depending on what was found. +-# This mimics the behavior of the old language-oblivious FindMPI. +-set(_MPI_OLD_VARS FOUND COMPILER INCLUDE_PATH COMPILE_FLAGS LINK_FLAGS LIBRARIES) +-if (MPI_CXX_FOUND) +- foreach (var ${_MPI_OLD_VARS}) +- set(MPI_${var} ${MPI_CXX_${var}}) +- endforeach() +-elseif (MPI_C_FOUND) +- foreach (var ${_MPI_OLD_VARS}) +- set(MPI_${var} ${MPI_C_${var}}) +- endforeach() +-else() +- # Note that we might still have found Fortran, but you'll need to use MPI_Fortran_FOUND +- set(MPI_FOUND FALSE) +-endif() +- +-# Chop MPI_LIBRARIES into the old-style MPI_LIBRARY and MPI_EXTRA_LIBRARY, and set them in cache. +-if (MPI_LIBRARIES) +- list(GET MPI_LIBRARIES 0 MPI_LIBRARY_WORK) +- set(MPI_LIBRARY ${MPI_LIBRARY_WORK} CACHE FILEPATH "MPI library to link against" FORCE) +-else() +- set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND" CACHE FILEPATH "MPI library to link against" FORCE) +-endif() +- +-list(LENGTH MPI_LIBRARIES MPI_NUMLIBS) +-if (MPI_NUMLIBS GREATER 1) +- set(MPI_EXTRA_LIBRARY_WORK ${MPI_LIBRARIES}) +- list(REMOVE_AT MPI_EXTRA_LIBRARY_WORK 0) +- set(MPI_EXTRA_LIBRARY ${MPI_EXTRA_LIBRARY_WORK} CACHE STRING "Extra MPI libraries to link against" FORCE) +-else() +- set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND" CACHE STRING "Extra MPI libraries to link against" FORCE) +-endif() +-#============================================================================= +- +-# unset these vars to cleanup namespace +-unset(_MPI_OLD_VARS) +-unset(_MPI_PREFIX_PATH) +-unset(_MPI_BASE_DIR) +-foreach (lang C CXX Fortran) +- unset(_MPI_${lang}_COMPILER_NAMES) +-endforeach() diff -Nru paraview-5.4.1+dfsg3/debian/patches/fix_gl2ps_new.patch paraview-5.4.1+dfsg4/debian/patches/fix_gl2ps_new.patch --- paraview-5.4.1+dfsg3/debian/patches/fix_gl2ps_new.patch 2017-09-20 16:21:53.000000000 +0000 +++ paraview-5.4.1+dfsg4/debian/patches/fix_gl2ps_new.patch 2018-04-22 10:35:56.000000000 +0000 @@ -1,10 +1,10 @@ Description: Workaround to compile paraview Author: Anton Gladky -Last-Update: 2017-09-17 +Last-Update: 2018-03-15 ---- paraview-5.4.1+dfsg1.orig/VTK/Rendering/GL2PS/vtkGL2PSUtilities.cxx -+++ paraview-5.4.1+dfsg1/VTK/Rendering/GL2PS/vtkGL2PSUtilities.cxx -@@ -241,8 +241,7 @@ void vtkGL2PSUtilities::DrawString(const +--- a/VTK/Rendering/GL2PS/vtkGL2PSUtilities.cxx ++++ b/VTK/Rendering/GL2PS/vtkGL2PSUtilities.cxx +@@ -241,8 +241,7 @@ // move the bottom left corner to the baseline as this is how PDF // draws text blpos[1] -= m.Descent[1]; @@ -14,7 +14,7 @@ } else { -@@ -624,7 +623,7 @@ void vtkGL2PSUtilities::DrawPathPS(vtkPa +@@ -624,7 +623,7 @@ out << "grestore" << endl; glRasterPos3dv(rasterPos); @@ -23,7 +23,7 @@ } void vtkGL2PSUtilities::DrawPathPDF(vtkPath *path, double rasterPos[3], -@@ -776,7 +775,7 @@ void vtkGL2PSUtilities::DrawPathPDF(vtkP +@@ -776,7 +775,7 @@ colorRgba[2] = rgba[2]/255.0; colorRgba[3] = rgba[3]/255.0; @@ -32,7 +32,7 @@ } void vtkGL2PSUtilities::DrawPathSVG(vtkPath *path, double rasterPos[3], -@@ -937,7 +936,7 @@ void vtkGL2PSUtilities::DrawPathSVG(vtkP +@@ -937,7 +936,7 @@ << "" << endl; glRasterPos3dv(rasterPos); @@ -41,3 +41,129 @@ } +--- a/VTK/Rendering/GL2PSOpenGL2/Testing/Cxx/TestGL2PSAddPolyPrimitive.cxx ++++ b/VTK/Rendering/GL2PSOpenGL2/Testing/Cxx/TestGL2PSAddPolyPrimitive.cxx +@@ -96,21 +96,21 @@ + // Point: + setVertex(vertices[0], 200, 307.5, 0, 0.f, 0.f, 1.f, 1.f); + gl2psAddPolyPrimitive(GL2PS_POINT, 1, vertices, offset, ofactor, ounits, +- pattern, factor, /*width=*/15, boundary); ++ pattern, factor, /*width=*/15, 0, 0, boundary); + + // Line: + // Note that the first vertex's color is used for the entire line. + setVertex(vertices[0], 100, 50, 0, 1.f, 0.f, 0.f, 1.f); + setVertex(vertices[1], 300, 50, 0, 0.f, 0.f, 1.f, 1.f); + gl2psAddPolyPrimitive(GL2PS_LINE, 2, vertices, offset, ofactor, ounits, +- pattern, factor, width, boundary); ++ pattern, factor, width, 0, 0, boundary); + + // Triangle: + setVertex(vertices[0], 100, 100, 0, 1.f, 0.f, 0.f, 1.f); + setVertex(vertices[1], 300, 100, 0, 0.f, 1.f, 0.f, 1.f); + setVertex(vertices[2], 200, 300, 0, 0.f, 0.f, 1.f, 1.f); + gl2psAddPolyPrimitive(GL2PS_TRIANGLE, 3, vertices, offset, ofactor, ounits, +- pattern, factor, width, boundary); ++ pattern, factor, width, 0, 0, boundary); + + // Text: + setVertex(vertices[0], 200, 325, 0, 0.f, 0.f, 0.f, 1.f); +--- a/VTK/Rendering/GL2PSOpenGL2/vtkOpenGLGL2PSHelperImpl.cxx ++++ b/VTK/Rendering/GL2PSOpenGL2/vtkOpenGLGL2PSHelperImpl.cxx +@@ -270,7 +270,7 @@ + { + case GL_POINTS: + gl2psAddPolyPrimitive(GL2PS_POINT, 1, verts, 0, 0.f, 0.f, 0xffff, 1, +- pointSize, 0); ++ pointSize, 0, 0, 0); + break; + + case GL_LINES: +@@ -278,7 +278,7 @@ + if (curVert == 0) + { + gl2psAddPolyPrimitive(GL2PS_LINE, 2, verts, 0, 0.f, 0.f, +- this->LineStipple, 1, lineWidth, 0); ++ this->LineStipple, 1, lineWidth, 0, 0, 0); + } + break; + +@@ -287,7 +287,7 @@ + if (curVert == 0) + { + gl2psAddPolyPrimitive(GL2PS_TRIANGLE, 3, verts, 0, 0.f, 0.f, 0xffff, +- 1, 1, 0); ++ 1, 1, 0, 0, 0); + } + break; + +@@ -357,9 +357,9 @@ + bgVerts[4].xyz[2] = bgVerts[0].xyz[2]; + + gl2psAddPolyPrimitive(GL2PS_TRIANGLE, 3, bgVerts, 0, 0, 0, 0xffff, 0, +- 0, 0); ++ 0, 0, 0, 0); + gl2psAddPolyPrimitive(GL2PS_TRIANGLE, 3, bgVerts + 2, 0, 0, 0, 0xffff, 0, +- 0, 0); ++ 0, 0, 0, 0); + } + } + +@@ -407,7 +407,14 @@ + // we cannot draw the text + return; + } +- if (::ComputeBottomLeft(tprop, m.BoundingBox, pos, this->TextAsPath, blpos)) ++ ++#if GL2PS_MAJOR_VERSION > 1 || \ ++ (GL2PS_MAJOR_VERSION == 1 && (GL2PS_MINOR_VERSION > 4 || \ ++ (GL2PS_MINOR_VERSION == 4 && GL2PS_MICRO_VERSION > 0))) ++#define HAVE_gl2psTextOptColorBL ++#endif ++#if HAVE_gl2psTextOptColorBL ++ if (::ComputeBottomLeft(tprop, m.BoundingBox, pos, this->TextAsPath, blpos)) + { + // move the bottom left corner to the baseline as this is how PDF + // draws text +@@ -419,13 +426,16 @@ + } + else + { ++#endif + // move the bottom left corner to the baseline as this + // how PDF draws text. + gl2psRasterPos.xyz[0] -= m.Descent[0]; + gl2psRasterPos.xyz[1] -= m.Descent[1]; + gl2psForceRasterPos(&gl2psRasterPos); + gl2psTextOptColor(str.c_str(), fontname, fontSize, align, angle, rgba); ++#if HAVE_gl2psTextOptColorBL + } ++#endif + } + else + { +@@ -983,7 +993,7 @@ + gl2psRasterPos.rgba[2] = 0.f; + gl2psRasterPos.rgba[3] = 0.f; + gl2psForceRasterPos(&gl2psRasterPos); +- gl2psSpecial(gl2psGetFileFormat(), out.str().c_str(), NULL); ++ gl2psSpecial(gl2psGetFileFormat(), out.str().c_str()); + } + + //------------------------------------------------------------------------------ +@@ -1140,7 +1150,7 @@ + gl2psRasterPos.rgba[2] = 0.f; + gl2psRasterPos.rgba[3] = 0.f; + gl2psForceRasterPos(&gl2psRasterPos); +- gl2psSpecial(gl2psGetFileFormat(), out.str().c_str(), NULL); ++ gl2psSpecial(gl2psGetFileFormat(), out.str().c_str()); + } + + //------------------------------------------------------------------------------ +@@ -1300,5 +1310,5 @@ + gl2psRasterPos.rgba[2] = 0.f; + gl2psRasterPos.rgba[3] = 0.f; + gl2psForceRasterPos(&gl2psRasterPos); +- gl2psSpecial(gl2psGetFileFormat(), out.str().c_str(), NULL); ++ gl2psSpecial(gl2psGetFileFormat(), out.str().c_str()); + } diff -Nru paraview-5.4.1+dfsg3/debian/patches/fix_opengl_arm.patch paraview-5.4.1+dfsg4/debian/patches/fix_opengl_arm.patch --- paraview-5.4.1+dfsg3/debian/patches/fix_opengl_arm.patch 1970-01-01 00:00:00.000000000 +0000 +++ paraview-5.4.1+dfsg4/debian/patches/fix_opengl_arm.patch 2018-04-22 10:35:56.000000000 +0000 @@ -0,0 +1,43 @@ +Author: Gert Wollny +Description: Use QOpenGLExtraFunctions instead of *3_2, because the + latter is not available on ARM. +Debian-Bug: https://bugs.debian.org/893735 +--- a/VTK/GUISupport/Qt/QVTKOpenGLWidget.cxx ++++ b/VTK/GUISupport/Qt/QVTKOpenGLWidget.cxx +@@ -19,7 +19,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include +@@ -455,17 +455,21 @@ + + // blit from this->FBO to QOpenGLWidget's FBO. + vtkQVTKOpenGLWidgetDebugMacro("paintGL::blit-to-defaultFBO"); +- QOpenGLFunctions_3_2_Core* f = +- QOpenGLContext::currentContext()->versionFunctions(); +- if (f) ++ ++ QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); ++ QOpenGLExtraFunctions *fx = QOpenGLContext::currentContext()->extraFunctions(); ++ ++ if (f && fx) + { + f->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, this->defaultFramebufferObject()); +- f->glDrawBuffer(GL_COLOR_ATTACHMENT0); ++ ++ GLenum buffers[] = {GL_COLOR_ATTACHMENT0}; ++ fx->glDrawBuffers(1, buffers); + + f->glBindFramebuffer(GL_READ_FRAMEBUFFER, this->FBO->handle()); +- f->glReadBuffer(GL_COLOR_ATTACHMENT0); ++ fx->glReadBuffer(GL_COLOR_ATTACHMENT0); + f->glDisable(GL_SCISSOR_TEST); // Scissor affects glBindFramebuffer. +- f->glBlitFramebuffer(0, 0, this->RenderWindow->GetSize()[0], this->RenderWindow->GetSize()[1], ++ fx->glBlitFramebuffer(0, 0, this->RenderWindow->GetSize()[0], this->RenderWindow->GetSize()[1], + 0, 0, this->RenderWindow->GetSize()[0], this->RenderWindow->GetSize()[1], GL_COLOR_BUFFER_BIT, + GL_NEAREST); + diff -Nru paraview-5.4.1+dfsg3/debian/patches/series paraview-5.4.1+dfsg4/debian/patches/series --- paraview-5.4.1+dfsg3/debian/patches/series 2017-09-20 16:21:23.000000000 +0000 +++ paraview-5.4.1+dfsg4/debian/patches/series 2018-04-22 10:35:56.000000000 +0000 @@ -5,3 +5,5 @@ use_system_mpi4py.patch remove_webgl.patch fix_gl2ps_new.patch +fix_opengl_arm.patch +disable-local-FindMPI.patch diff -Nru paraview-5.4.1+dfsg3/debian/rules paraview-5.4.1+dfsg4/debian/rules --- paraview-5.4.1+dfsg3/debian/rules 2017-09-20 21:23:14.000000000 +0000 +++ paraview-5.4.1+dfsg4/debian/rules 2018-04-22 10:35:56.000000000 +0000 @@ -5,10 +5,10 @@ UPSTREAM_VERSION = $(shell dpkg-parsechangelog | awk '/^Version:/ { sub("-[^-]*$$", "", $$2); print $$2}') %: - dh $@ --with python2 --parallel + dh $@ --with python2 export LD_LIBRARY_PATH+=:$(CURDIR)/debian/paraview/usr/lib/paraview -export QT_SELECT=qt4 +export QT_SELECT=qt5 CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS) CFLAGS:=$(shell dpkg-buildflags --get CFLAGS) $(CPPFLAGS) -Wall -pedantic @@ -60,15 +60,14 @@ -DPARAVIEW_INSTALL_DEVELOPMENT_FILES=ON \ -DBUILD_DOCUMENTATION=ON \ -DPARAVIEW_USE_MPI=ON \ - -DMPI_INCLUDE_PATH="/usr/include/mpi" \ -DPARAVIEW_ENABLE_PYTHON=ON \ -DPARAVIEW_BUILD_PLUGIN_AdiosReader:BOOL=ON \ -DPARAVIEW_BUILD_PLUGIN_EyeDomeLighting:BOOL=ON \ -DPARAVIEW_BUILD_PLUGIN_MobileRemoteControl=OFF \ -DEigen_DIR=/usr/include/eigen3 \ -DPARAVIEW_BUILD_WEB_DOCUMENTATION=ON \ - -DVTK_RENDERING_BACKEND:STRING=OpenGL \ - -DPARAVIEW_QT_VERSION=4 \ + -DVTK_RENDERING_BACKEND:STRING=OpenGL2 \ + -DPARAVIEW_QT_VERSION=5 \ -DVTK_INSTALL_NO_DOCUMENTATION=ON override_dh_auto_configure: diff -Nru paraview-5.4.1+dfsg3/debian/source/lintian-overrides paraview-5.4.1+dfsg4/debian/source/lintian-overrides --- paraview-5.4.1+dfsg3/debian/source/lintian-overrides 1970-01-01 00:00:00.000000000 +0000 +++ paraview-5.4.1+dfsg4/debian/source/lintian-overrides 2018-04-22 10:35:56.000000000 +0000 @@ -0,0 +1,10 @@ +# Team maintained +paraview source: no-human-maintainers + +# There is a bunch of specialized BSD like licenses that +# all would need a unique but useless name +paraview source: dep5-copyright-license-name-not-unique * + + +#There is a paragraph, don't know why linitian complains +paraview source: missing-license-paragraph-in-dep5-copyright * diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/CMakeLists.txt paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/CMakeLists.txt --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/CMakeLists.txt 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,134 +0,0 @@ -include(vtkObjectFactory) - -set(Module_SRCS - vtkOpenGLHAVSVolumeMapper.cxx - vtkOpenGLProjectedAAHexahedraMapper.cxx - vtkOpenGLProjectedTetrahedraMapper.cxx - vtkOpenGLRayCastImageDisplayHelper.cxx - vtkOpenGLVolumeTextureMapper2D.cxx - vtkOpenGLVolumeTextureMapper3D.cxx - vtkSmartVolumeMapper.cxx - ) - -if (NOT Module_vtkRenderingVolumeOpenGLNew) - list(APPEND Module_SRCS vtkOpenGLGPUVolumeRayCastMapper.cxx) -endif() - -set(shader_files - vtkGPUVolumeRayCastMapper_AdditiveFS.glsl - vtkGPUVolumeRayCastMapper_AdditiveCroppingFS.glsl - vtkGPUVolumeRayCastMapper_AdditiveNoCroppingFS.glsl - vtkGPUVolumeRayCastMapper_CompositeFS.glsl - vtkGPUVolumeRayCastMapper_CompositeMaskFS.glsl - vtkGPUVolumeRayCastMapper_CompositeBinaryMaskFS.glsl - vtkGPUVolumeRayCastMapper_CompositeCroppingFS.glsl - vtkGPUVolumeRayCastMapper_CompositeNoCroppingFS.glsl - vtkGPUVolumeRayCastMapper_HeaderFS.glsl - vtkGPUVolumeRayCastMapper_MIPCroppingFS.glsl - vtkGPUVolumeRayCastMapper_MIPFS.glsl - vtkGPUVolumeRayCastMapper_MIPBinaryMaskFS.glsl - vtkGPUVolumeRayCastMapper_MIPFourDependentFS.glsl - vtkGPUVolumeRayCastMapper_MIPFourDependentCroppingFS.glsl - vtkGPUVolumeRayCastMapper_MIPFourDependentNoCroppingFS.glsl - vtkGPUVolumeRayCastMapper_MIPNoCroppingFS.glsl - vtkGPUVolumeRayCastMapper_MinIPCroppingFS.glsl - vtkGPUVolumeRayCastMapper_MinIPFS.glsl - vtkGPUVolumeRayCastMapper_MinIPBinaryMaskFS.glsl - vtkGPUVolumeRayCastMapper_MinIPFourDependentFS.glsl - vtkGPUVolumeRayCastMapper_MinIPFourDependentCroppingFS.glsl - vtkGPUVolumeRayCastMapper_MinIPFourDependentNoCroppingFS.glsl - vtkGPUVolumeRayCastMapper_MinIPNoCroppingFS.glsl - vtkGPUVolumeRayCastMapper_ParallelProjectionFS.glsl - vtkGPUVolumeRayCastMapper_PerspectiveProjectionFS.glsl - vtkGPUVolumeRayCastMapper_ScaleBiasFS.glsl - vtkGPUVolumeRayCastMapper_OneComponentFS.glsl - vtkGPUVolumeRayCastMapper_FourComponentsFS.glsl - vtkGPUVolumeRayCastMapper_NoShadeFS.glsl - vtkGPUVolumeRayCastMapper_ShadeFS.glsl - vtkHAVSVolumeMapper_kbufferVP.asm - vtkHAVSVolumeMapper_k2FP.asm - vtkHAVSVolumeMapper_k2BeginFP.asm - vtkHAVSVolumeMapper_k2EndFP.asm - vtkHAVSVolumeMapper_k6FP.asm - vtkHAVSVolumeMapper_k6BeginFP.asm - vtkHAVSVolumeMapper_k6EndFP.asm - vtkProjectedAAHexahedraMapper_VS.glsl - vtkProjectedAAHexahedraMapper_GS.glsl - vtkProjectedAAHexahedraMapper_FS.glsl - vtkVolumeTextureMapper3D_FourDependentNoShadeFP.asm - vtkVolumeTextureMapper3D_FourDependentShadeFP.asm - vtkVolumeTextureMapper3D_OneComponentNoShadeFP.asm - vtkVolumeTextureMapper3D_OneComponentShadeFP.asm - vtkVolumeTextureMapper3D_TwoDependentNoShadeFP.asm - vtkVolumeTextureMapper3D_TwoDependentShadeFP.asm - ) - -unset(shader_h_files) -foreach(file ${shader_files}) - get_filename_component(file_we ${file} NAME_WE) - set(src ${CMAKE_CURRENT_SOURCE_DIR}/${file}) - set(res ${CMAKE_CURRENT_BINARY_DIR}/${file_we}.cxx) - set(resh ${CMAKE_CURRENT_BINARY_DIR}/${file_we}.h) - list(APPEND shader_h_files ${resh}) - add_custom_command( - OUTPUT ${res} ${resh} - DEPENDS ${src} vtkEncodeString - COMMAND vtkEncodeString - ARGS ${res} ${src} ${file_we} - --build-header VTKRENDERINGVOLUMEOPENGL_EXPORT vtkRenderingVolumeOpenGLModule.h - ) - list(APPEND Module_SRCS ${res}) - set_source_files_properties(${file_we} - PROPERTIES - WRAP_EXCLUDE 1 - WRAP_EXCLUDE_PYTHON 1 - ) -endforeach() - -if (VTK_LEGACY_REMOVE) - set_source_files_properties( - vtkOpenGLVolumeTextureMapper2D.h - vtkOpenGLVolumeTextureMapper2D.cxx - vtkOpenGLVolumeTextureMapper3D.h - vtkOpenGLVolumeTextureMapper3D.cxx - PROPERTIES - WRAP_EXCLUDE 1 - WRAP_EXCLUDE_PYTHON 1 - ) -endif() - -# Nwo for the object factory. -set(opengl_overrides - HAVSVolumeMapper - ProjectedAAHexahedraMapper - ProjectedTetrahedraMapper - RayCastImageDisplayHelper - ) - -if (NOT VTK_LEGACY_REMOVE) - list (APPEND opengl_overrides - VolumeTextureMapper2D - VolumeTextureMapper3D) -endif() - -if(NOT Module_vtkRenderingVolumeOpenGLNew) - list(APPEND opengl_overrides GPUVolumeRayCastMapper) -endif() - -foreach(_override ${opengl_overrides}) - vtk_add_override(vtk${_override} vtkOpenGL${_override}) -endforeach() -vtk_object_factory_configure("${vtk_module_overrides}") - -list(APPEND Module_SRCS - ${CMAKE_CURRENT_BINARY_DIR}/${vtk-module}ObjectFactory.cxx) -set_source_files_properties( - ${vtk-module}ObjectFactory.cxx - PROPERTIES - WRAP_EXCLUDE 1 - WRAP_EXCLUDE_PYTHON 1 - ) - -vtk_module_library(vtkRenderingVolumeOpenGL ${Module_SRCS}) -include(vtkOpenGL) -vtk_opengl_link(vtkRenderingVolumeOpenGL) diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/module.cmake paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/module.cmake --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/module.cmake 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/module.cmake 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -set(VTK_RENDERINGVOLUMEOPENGLNEW) -if (Module_vtkRenderingVolumeOpenGLNew AND - NOT (VTK_RENDERING_BACKEND STREQUAL "OpenGL2")) - set (VTK_RENDERINGVOLUMEOPENGLNEW vtkRenderingVolumeOpenGLNew) -else () - set (VTK_RENDERINGVOLUMEOPENGLNEW "") -endif() -vtk_module(vtkRenderingVolumeOpenGL - IMPLEMENTS - vtkRenderingVolume - BACKEND - OpenGL - IMPLEMENTATION_REQUIRED_BY_BACKEND - TEST_DEPENDS - vtkTestingCore - vtkTestingRendering - vtkRenderingFreeType - vtkImagingSources - vtkImagingGeneral - vtkInteractionStyle - KIT - vtkOpenGL - DEPENDS - ${VTK_RENDERINGVOLUMEOPENGLNEW} - vtkCommonCore - vtkImagingCore - vtkRenderingOpenGL - vtkRenderingVolume - PRIVATE_DEPENDS - vtkCommonDataModel - vtkCommonMath - vtkCommonSystem - vtkCommonTransforms - vtkFiltersCore - vtkFiltersGeneral - vtkFiltersGeometry - vtkFiltersSources - vtkRenderingCore - vtksys - ) \ No newline at end of file diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_AdditiveCroppingFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_AdditiveCroppingFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_AdditiveCroppingFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_AdditiveCroppingFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_AdditiveCroppingFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Implementation of some functions used by the Additive method when cropping -// is on. - -#version 110 - -// GLSL Spec 1.10 rev 59 30-April-2004 defines gl_FragData[] but implementation -// older than the spec only has it as an extension -// (nVidia Linux driver 100.14.13, OpenGL version 2.1.1, -// on Quadro FX 3500/PCI/SSE2) -#extension GL_ARB_draw_buffers : enable - -// sum scalar buffer as an input -uniform sampler2D scalarBufferTexture; -// 2D Texture fragment coordinates [0,1] from fragment coordinates -// the scalar frame buffer texture has the size of the plain buffer but -// we use a fraction of it. The texture coordinates is less than 1 if -// the reduction factor is less than 1. -vec2 fragTexCoord; - -float initialValue() -{ - return texture2D(scalarBufferTexture,fragTexCoord).r; -} - -void writeColorAndSumScalar(vec4 color, - float sumValue) -{ - // color framebuffer - gl_FragData[0]=color; - - // sum scalar framebuffer. - gl_FragData[1].r=sumValue; - gl_FragData[1].g=0.0; - gl_FragData[1].b=0.0; - gl_FragData[1].a=0.0; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_AdditiveFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_AdditiveFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_AdditiveFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_AdditiveFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_AdditiveFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Fragment program with ray cast and Maximum Intensity Projection (MIP) -// method. -// Compilation: header part and the projection part are inserted first. -// pos is defined and initialized in header -// rayDir is defined in header and initialized in the projection part -// initMaxValue() and writeColorAndMaxScalar are defined in some specific -// file depending on cropping flag being on or off. - -#version 110 - -uniform sampler3D dataSetTexture; -uniform sampler1D colorTexture; -uniform sampler1D opacityTexture; - -uniform vec3 lowBounds; -uniform vec3 highBounds; - -// Entry position (global scope) -vec3 pos; -// Incremental vector in texture space (global scope) -vec3 rayDir; - -float tMax; - -// Sub-functions, depending on cropping mode -float initialValue(); -void writeColorAndSumScalar(vec4 color, - float sumValue); - -void trace(void) -{ - // Max intensity is the lowest value. - float sumValue=initialValue(); - bool inside=true; - vec4 sample; - - float t=0.0; - // We NEED two nested while loops. It is trick to work around hardware - // limitation about the maximum number of loops. - while(inside) - { - while(inside) - { - sample=texture3D(dataSetTexture,pos); - - vec4 opacity=texture1D(opacityTexture,sample.r); - sumValue=sumValue+opacity.a*sample.r; - pos=pos+rayDir; - t+=1.0; - - // yes, t=lowBounds.x && pos.y>=lowBounds.y - && pos.z>=lowBounds.z && pos.x<=highBounds.x && pos.y<=highBounds.y - && pos.z<=highBounds.z; - } - } - - float clampedValue=clamp(sumValue,0.0,1.0); - vec4 color=vec4(clampedValue,clampedValue,clampedValue,1.0); // opaque - - writeColorAndSumScalar(color,sumValue); -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_AdditiveNoCroppingFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_AdditiveNoCroppingFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_AdditiveNoCroppingFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_AdditiveNoCroppingFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_AdditiveNoCroppingFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Implementation of some functions used by the Additive method when cropping -// is off. - -#version 110 - -float initialValue() -{ - return 0.0; -} -void writeColorAndSumScalar(vec4 color, - float sumValue) -{ - // we don't need to write sumValue to a buffer when there is no cropping. - // color framebuffer - gl_FragColor=color; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeBinaryMaskFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeBinaryMaskFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeBinaryMaskFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeBinaryMaskFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_CompositeBinaryMaskFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Fragment program part with ray cast and composite method with masks. -// Only regions in the mask texture contribute. Regions outside are as good -// as completely transparent. - -#version 110 - -uniform sampler3D dataSetTexture; -uniform sampler3D maskTexture; -uniform sampler1D opacityTexture; - -uniform vec3 lowBounds; -uniform vec3 highBounds; - -// Entry position (global scope) -vec3 pos; -// Incremental vector in texture space (global scope) -vec3 rayDir; - -float tMax; - -// from cropping vs no cropping -vec4 initialColor(); - -// from 1 vs 4 component shader. -float scalarFromValue(vec4 value); -vec4 colorFromValue(vec4 value); - -// from noshade vs shade. -void initShade(); -vec4 shade(vec4 value); - -void trace(void) -{ - vec4 destColor=initialColor(); - float remainOpacity=1.0-destColor.a; - - bool inside=true; - - vec4 maskValue; - vec4 color; - vec4 opacity; - - initShade(); - - float t=0.0; - - // We NEED two nested while loops. It is trick to work around hardware - // limitation about the maximum number of loops. - - while(inside) - { - while(inside) - { - vec4 value=texture3D(dataSetTexture,pos); - float scalar=scalarFromValue(value); - opacity=texture1D(opacityTexture,scalar); - - if(opacity.a>0.0) - { - // get the mask value at this same location - maskValue=texture3D(maskTexture,pos); - if(maskValue.a!=0.0) - { - color=shade(value); - color=color*opacity.a; - destColor=destColor+color*remainOpacity; - remainOpacity=remainOpacity*(1.0-opacity.a); - } - } - - - pos=pos+rayDir; - t+=1.0; - inside=t=0.0039); // 1/255=0.0039 - } - } - gl_FragColor = destColor; - gl_FragColor.a = 1.0-remainOpacity; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeCroppingFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeCroppingFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeCroppingFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeCroppingFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_CompositeCroppingFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Implementation of some function used by the composite method when cropping -// is on. - -#version 110 - -// color buffer as an input -uniform sampler2D frameBufferTexture; -// 2D Texture fragment coordinates [0,1] from fragment coordinates -// the frame buffer texture has the size of the plain buffer but -// we use a fraction of it. The texture coordinates is less than 1 if -// the reduction factor is less than 1. -vec2 fragTexCoord; - -vec4 initialColor() -{ - return texture2D(frameBufferTexture,fragTexCoord); -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_CompositeFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Fragment program part with ray cast and composite method. - -#version 110 - -uniform sampler3D dataSetTexture; -uniform sampler1D opacityTexture; - -uniform vec3 lowBounds; -uniform vec3 highBounds; - -// Entry position (global scope) -vec3 pos; -// Incremental vector in texture space (global scope) -vec3 rayDir; - -float tMax; - -// from cropping vs no cropping -vec4 initialColor(); - -// from 1 vs 4 component shader. -float scalarFromValue(vec4 value); -vec4 colorFromValue(vec4 value); - -// from noshade vs shade. -void initShade(); -vec4 shade(vec4 value); - -void trace(void) -{ - vec4 destColor=initialColor(); - float remainOpacity=1.0-destColor.a; - - bool inside=true; - - vec4 color; - vec4 opacity; - - initShade(); - - float t=0.0; - - // We NEED two nested while loops. It is trick to work around hardware - // limitation about the maximum number of loops. - - while(inside) - { - while(inside) - { - vec4 value=texture3D(dataSetTexture,pos); - float scalar=scalarFromValue(value); - // opacity is the sampled texture value in the 1D opacity texture at - // scalarValue - opacity=texture1D(opacityTexture,scalar); - if(opacity.a>0.0) - { - color=shade(value); - color=color*opacity.a; - destColor=destColor+color*remainOpacity; - remainOpacity=remainOpacity*(1.0-opacity.a); - } - pos=pos+rayDir; - t+=1.0; - inside=t=0.0039); // 1/255=0.0039 - } - } - gl_FragColor = destColor; - gl_FragColor.a = 1.0-remainOpacity; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeMaskFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeMaskFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeMaskFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeMaskFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_CompositeMaskFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Fragment program part with ray cast and composite method with masks. - -#version 110 - -uniform sampler3D dataSetTexture; -uniform sampler3D maskTexture; -uniform sampler1D mask1ColorTexture; -uniform sampler1D mask2ColorTexture; -uniform sampler1D opacityTexture; - -uniform vec3 lowBounds; -uniform vec3 highBounds; - -uniform float maskBlendFactor; - -// Entry position (global scope) -vec3 pos; -// Incremental vector in texture space (global scope) -vec3 rayDir; - -float tMax; - -// from cropping vs no cropping -vec4 initialColor(); - -// from 1 vs 4 component shader. -float scalarFromValue(vec4 value); -vec4 colorFromValue(vec4 value); - -// from noshade vs shade. -void initShade(); -vec4 shade(vec4 value); - -void trace(void) -{ - vec4 destColor=initialColor(); - float remainOpacity=1.0-destColor.a; - - bool inside=true; - - vec4 maskValue; - vec4 color; - vec4 opacity; - - initShade(); - - float t=0.0; - - // We NEED two nested while loops. It is trick to work around hardware - // limitation about the maximum number of loops. - - while(inside) - { - while(inside) - { - vec4 value=texture3D(dataSetTexture,pos); - float scalar=scalarFromValue(value); - opacity=texture1D(opacityTexture,scalar); - - if(maskBlendFactor==0.0) - { - color=shade(value); - } - else - { - // get the mask value at this same location - maskValue=texture3D(maskTexture,pos); - if(maskValue.a==0.0) - { - color=shade(value); - } - else - { - if(maskValue.a==1.0/255.0) - { - color=texture1D(mask1ColorTexture,scalar); - } - else - { - // maskValue.a == 2.0/255.0 - color=texture1D(mask2ColorTexture,scalar); - } - color.a=1.0; - if(maskBlendFactor<1.0) - { - color=(1.0-maskBlendFactor)*shade(value)+maskBlendFactor*color; - } -// color.r = 1; -// color.g = 0; -// color.b = 0; -// color.a = 1; - } - } - - color=color*opacity.a; - destColor=destColor+color*remainOpacity; - remainOpacity=remainOpacity*(1.0-opacity.a); - - pos=pos+rayDir; - t+=1.0; - inside=t=0.0039); // 1/255=0.0039 - } - } - gl_FragColor = destColor; - gl_FragColor.a = 1.0-remainOpacity; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeNoCroppingFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeNoCroppingFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeNoCroppingFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_CompositeNoCroppingFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_CompositeNoCroppingFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Implementation of some function used by the composite method when cropping -// is off. - -#version 110 - -// Max intensity is the lowest value. -vec4 initialColor() -{ - return vec4(0.0,0.0,0.0,0.0); -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_FourComponentsFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_FourComponentsFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_FourComponentsFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_FourComponentsFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_FourComponentsFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Fragment shader that implements scalarFromValue() and colorFromValue() in -// the case of a one-component dataset. -// The functions are used in composite mode. - -#version 110 - -// "value" is a sample of the dataset. -// Think of "value" as an object. - -float scalarFromValue(vec4 value) -{ - return value.w; -} - -vec4 colorFromValue(vec4 value) -{ - return vec4(value.xyz,1.0); -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_HeaderFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_HeaderFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_HeaderFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_HeaderFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_HeaderFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -#version 110 - -// Depth map of the polygonal geometry -uniform sampler2D depthTexture; - -// 2D noise texture to jitter the starting point of the ray in order to -// remove patterns when the opacity transfer function make the data on the -// border of the dataset to be visible. -uniform sampler2D noiseTexture; - -uniform vec2 windowLowerLeftCorner; -uniform vec2 invOriginalWindowSize; -uniform vec2 invWindowSize; - -// Change-of-coordinate matrix from eye space to texture space -uniform mat4 textureToEye; - -// Entry position (global scope) -vec3 pos; -// Incremental vector in texture space (global scope) -vec3 rayDir; - -// Abscissa along the ray of the point on the depth map -// tracing stops when t>=tMax -float tMax; - -// 2D Texture fragment coordinates [0,1] from fragment coordinates -// the frame buffer texture has the size of the plain buffer but -// we use a fraction of it. The texture coordinates is less than 1 if -// the reduction factor is less than 1. -vec2 fragTexCoord; - -// Defined in the right projection method. -// May use pos in global scope as input. -// Use rayDir in global scope as output. -void incrementalRayDirection(); -void trace(); - -void main() -{ - - // device coordinates are between -1 and 1 - // we need texture coordinates between 0 and 1 - // the depth buffer has the original size buffer. - fragTexCoord=(gl_FragCoord.xy-windowLowerLeftCorner)*invWindowSize; - vec4 depth=texture2D(depthTexture,fragTexCoord); - if(gl_FragCoord.z>=depth.x) // depth test - { - discard; - } - - // color buffer or max scalar buffer have a reduced size. - fragTexCoord=(gl_FragCoord.xy-windowLowerLeftCorner)*invOriginalWindowSize; - // Abscissa of the point on the depth buffer along the ray. - // point in texture coordinates - vec4 maxPoint; - - // from window coordinates to normalized device coordinates - maxPoint.x=(gl_FragCoord.x-windowLowerLeftCorner.x)*2.0*invWindowSize.x-1.0; - maxPoint.y=(gl_FragCoord.y-windowLowerLeftCorner.y)*2.0*invWindowSize.y-1.0; - maxPoint.z=(2.0*depth.x-(gl_DepthRange.near+gl_DepthRange.far))/gl_DepthRange.diff; - maxPoint.w=1.0; - - // from normalized device coordinates to eye coordinates - maxPoint=gl_ProjectionMatrixInverse*maxPoint; - - // from eye coordinates to texture coordinates - maxPoint=textureToEye*maxPoint; - // homogeneous to cartesian coordinates - maxPoint/=maxPoint.w; - - // Entry position. divide by q. - // pos=gl_TexCoord[0].xyz/gl_TexCoord[0].w; - - pos.x=gl_TexCoord[0].x/gl_TexCoord[0].w; - pos.y=gl_TexCoord[0].y/gl_TexCoord[0].w; - pos.z=gl_TexCoord[0].z/gl_TexCoord[0].w; - - // Incremental vector in texture space. Computation depends on the - // type of projection (parallel or perspective) - incrementalRayDirection(); - - vec4 noiseValue=texture2D(noiseTexture,pos.xy*100.0); // with repeat/tiling mode on the noise texture. - - pos+=(noiseValue.x)*rayDir; - - tMax=length(maxPoint.xyz-pos.xyz) /length(rayDir); - - - // Tracing method. Set the final fragment color. - trace(); -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPBinaryMaskFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPBinaryMaskFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPBinaryMaskFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPBinaryMaskFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_MinIPBinaryMaskFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Fragment program with ray cast and Minimum Intensity Projection (MinIP) -// method, in the presence of an auxiliary mask. Only regions in the -// mask texture contribute. Regions outside are as good as completely -// transparent. -// -// Compilation: header part and the projection part are inserted first. -// pos is defined and initialized in header -// rayDir is defined in header and initialized in the projection part -// initMinValue() and writeColorAndMinScalar are defined in some specific -// file depending on cropping flag being on or off. - -#version 110 - -uniform sampler3D dataSetTexture; -uniform sampler3D maskTexture; -uniform sampler1D colorTexture; -uniform sampler1D opacityTexture; - -uniform vec3 lowBounds; -uniform vec3 highBounds; - -// Entry position (global scope) -vec3 pos; -// Incremental vector in texture space (global scope) -vec3 rayDir; - -float tMax; - -// Sub-functions, depending on cropping mode -float initialMinValue(); -void writeColorAndMinScalar(vec4 sample, - vec4 opacity, - float minValue); - -void trace(void) -{ - // Max intensity is the lowest value. - float minValue=initialMinValue(); - bool inside=true; - vec4 sample; - vec4 maskValue; - - float t=0.0; - // We NEED two nested while loops. It is trick to work around hardware - // limitation about the maximum number of loops. - while(inside) - { - while(inside) - { - // get the mask value at this location - maskValue=texture3D(maskTexture,pos); - - if(maskValue.a!=0.0) - { - sample=texture3D(dataSetTexture,pos); - minValue=min(minValue,sample.r); - } - - pos=pos+rayDir; - t+=1.0; - inside=t=lowBounds.x && pos.y>=lowBounds.y - && pos.z>=lowBounds.z && pos.x<=highBounds.x && pos.y<=highBounds.y - && pos.z<=highBounds.z; - - } - } - - sample=texture1D(colorTexture,minValue); - vec4 opacity=texture1D(opacityTexture,minValue); - - writeColorAndMinScalar(sample,opacity,minValue); -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPCroppingFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPCroppingFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPCroppingFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPCroppingFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_MinIPCroppingFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Implementation of some functions used by the Minimum Intensity Projection -// (MinIP) method when cropping is on. - -#version 110 - -// GLSL Spec 1.10 rev 59 30-April-2004 defines gl_FragData[] but implementation -// older than the spec only has it as an extension -// (nVidia Linux driver 100.14.13, OpenGL version 2.1.1, -// on Quadro FX 3500/PCI/SSE2) -#extension GL_ARB_draw_buffers : enable - -// max scalar buffer as an input -uniform sampler2D scalarBufferTexture; -// 2D Texture fragment coordinates [0,1] from fragment coordinates -// the scalar frame buffer texture has the size of the plain buffer but -// we use a fraction of it. The texture coordinates is less than 1 if -// the reduction factor is less than 1. -vec2 fragTexCoord; - -float initialMinValue() -{ - return texture2D(scalarBufferTexture,fragTexCoord).r; -} - -void writeColorAndMinScalar(vec4 sample, - vec4 opacity, - float minValue) -{ - // color framebuffer - gl_FragData[0].r =sample.r * opacity.a; - gl_FragData[0].g =sample.g * opacity.a; - gl_FragData[0].b =sample.b * opacity.a; - gl_FragData[0].a=opacity.a; - - // min scalar framebuffer - gl_FragData[1].r=minValue; - gl_FragData[1].g=0.0; - gl_FragData[1].b=0.0; - gl_FragData[1].a=0.0; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPFourDependentCroppingFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPFourDependentCroppingFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPFourDependentCroppingFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPFourDependentCroppingFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_MinIPFourDependentCroppingFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Implementation of some functions used by the 4-component Minimum Intensity -// Projection (MinIP) method when cropping is on. - -#version 110 - -// GLSL Spec 1.10 rev 59 30-April-2004 defines gl_FragData[] but implementation -// older than the spec only has it as an extension -// (nVidia Linux driver 100.14.13, OpenGL version 2.1.1, -// on Quadro FX 3500/PCI/SSE2) -#extension GL_ARB_draw_buffers : enable - -// max scalar buffer as an input -uniform sampler2D scalarBufferTexture; - -// color buffer as an input -uniform sampler2D frameBufferTexture; - -// 2D Texture fragment coordinates [0,1] from fragment coordinates -// the scalar frame buffer texture has the size of the plain buffer but -// we use a fraction of it. The texture coordinates is less than 1 if -// the reduction factor is less than 1. -vec2 fragTexCoord; - -float initialMinValue() -{ - return texture2D(scalarBufferTexture,fragTexCoord).r; -} - -vec4 initialColor() -{ - return texture2D(frameBufferTexture,fragTexCoord); -} - -void writeColorAndMinScalar(vec4 color, - vec4 opacity, - float minValue) -{ - // color framebuffer - gl_FragData[0].r = color.r*opacity.a; - gl_FragData[0].g = color.g*opacity.a; - gl_FragData[0].b = color.b*opacity.a; - gl_FragData[0].a=opacity.a; - - // min scalar framebuffer - gl_FragData[1].r=minValue; - gl_FragData[1].g=0.0; - gl_FragData[1].b=0.0; - gl_FragData[1].a=0.0; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPFourDependentFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPFourDependentFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPFourDependentFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPFourDependentFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_MinIPFourDependentFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Fragment program with ray cast and 4-dependent-component Minimum Intensity -// Projection (MinIP) method. -// Compilation: header part and the projection part are inserted first. -// pos is defined and initialized in header -// rayDir is defined in header and initialized in the projection part - -#version 110 - -uniform sampler3D dataSetTexture; -uniform sampler1D opacityTexture; - -uniform vec3 lowBounds; -uniform vec3 highBounds; - -// Entry position (global scope) -vec3 pos; -// Incremental vector in texture space (global scope) -vec3 rayDir; - -float tMax; - -// Sub-functions, depending on cropping mode -float initialMinValue(); -vec4 initialColor(); -void writeColorAndMinScalar(vec4 color, - vec4 opacity, - float minValue); - -void trace(void) -{ - // Max intensity is the lowest value. - float minValue=initialMinValue(); - vec4 color=initialColor(); - bool inside=true; - float t=0.0; - vec4 sample; - bool changed=false; - - // We NEED two nested while loops. It is a trick to work around hardware - // limitation about the maximum number of loops. - while(inside) - { - while(inside) - { - sample=texture3D(dataSetTexture,pos); - if(sample.w=lowBounds.x && pos.y>=lowBounds.y - && pos.z>=lowBounds.z && pos.x<=highBounds.x && pos.y<=highBounds.y - && pos.z<=highBounds.z; - } - } - - if(changed) - { - vec4 opacity=texture1D(opacityTexture,minValue); - writeColorAndMinScalar(color,opacity,minValue); - } - else - { - discard; - } -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPFourDependentNoCroppingFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPFourDependentNoCroppingFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPFourDependentNoCroppingFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPFourDependentNoCroppingFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_MinIPFourDependentNoCroppingFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Implementation of some functions used by the 4-component Minimum Intensity -// Projection (MinIP) method when cropping is off. - -#version 110 - -float initialMinValue() -{ - return 1.0; -} - -vec4 initialColor() -{ - return vec4(0.0,0.0,0.0,0.0); -} - -void writeColorAndMinScalar(vec4 color, - vec4 opacity, - float minValue) -{ - // minValue is not used - - // color framebuffer - gl_FragColor.r = color.r*opacity.a; - gl_FragColor.g = color.g*opacity.a; - gl_FragColor.b = color.b*opacity.a; - gl_FragColor.a=opacity.a; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_MinIPFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Fragment program with ray cast and Minimum Intensity Projection (MinIP) -// method. -// Compilation: header part and the projection part are inserted first. -// pos is defined and initialized in header -// rayDir is defined in header and initialized in the projection part -// initMinValue() and writeColorAndMinScalar are defined in some specific -// file depending on cropping flag being on or off. - -#version 110 - -uniform sampler3D dataSetTexture; -uniform sampler1D colorTexture; -uniform sampler1D opacityTexture; - -uniform vec3 lowBounds; -uniform vec3 highBounds; - -// Entry position (global scope) -vec3 pos; -// Incremental vector in texture space (global scope) -vec3 rayDir; - -float tMax; - -// Sub-functions, depending on cropping mode -float initialMinValue(); -void writeColorAndMinScalar(vec4 sample, - vec4 opacity, - float minValue); - -void trace(void) -{ - // Max intensity is the lowest value. - float minValue=initialMinValue(); - bool inside=true; - vec4 sample; - - float t=0.0; - // We NEED two nested while loops. It is trick to work around hardware - // limitation about the maximum number of loops. - while(inside) - { - while(inside) - { - sample=texture3D(dataSetTexture,pos); - minValue=min(minValue,sample.r); - pos=pos+rayDir; - t+=1.0; - inside=t=lowBounds.x && pos.y>=lowBounds.y - && pos.z>=lowBounds.z && pos.x<=highBounds.x && pos.y<=highBounds.y - && pos.z<=highBounds.z; - - - } - } - - sample=texture1D(colorTexture,minValue); - vec4 opacity=texture1D(opacityTexture,minValue); - - writeColorAndMinScalar(sample,opacity,minValue); -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPNoCroppingFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPNoCroppingFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPNoCroppingFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MinIPNoCroppingFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_MinIPNoCroppingFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Implementation of some functions used by the Minimum Intensity projection -// (MinIP) method when cropping is off. - -#version 110 - -float initialMinValue() -{ - return 1.0; -} - -void writeColorAndMinScalar(vec4 sample, - vec4 opacity, - float minValue) -{ - // we don't need to write minValue to a buffer when there is no cropping. - // color framebuffer - gl_FragColor.r =sample.r * opacity.a; - gl_FragColor.g =sample.g * opacity.a; - gl_FragColor.b =sample.b * opacity.a; - gl_FragColor.a=opacity.a; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPBinaryMaskFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPBinaryMaskFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPBinaryMaskFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPBinaryMaskFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_MIPFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Fragment program with ray cast and Maximum Intensity Projection (MIP) -// method. -// Compilation: header part and the projection part are inserted first. -// pos is defined and initialized in header -// rayDir is defined in header and initialized in the projection part -// initMaxValue() and writeColorAndMaxScalar are defined in some specific -// file depending on cropping flag being on or off. - -#version 110 - -uniform sampler3D dataSetTexture; -uniform sampler3D maskTexture; -uniform sampler1D colorTexture; -uniform sampler1D opacityTexture; - -uniform vec3 lowBounds; -uniform vec3 highBounds; - -// Entry position (global scope) -vec3 pos; -// Incremental vector in texture space (global scope) -vec3 rayDir; - -float tMax; - -// Sub-functions, depending on cropping mode -float initialMaxValue(); -void writeColorAndMaxScalar(vec4 sample, - vec4 opacity, - float maxValue); - -void trace(void) -{ - // Max intensity is the lowest value. - float maxValue=initialMaxValue(); - bool inside=true; - vec4 sample; - vec4 maskValue; - - float t=0.0; - // We NEED two nested while loops. It is trick to work around hardware - // limitation about the maximum number of loops. - while(inside) - { - while(inside) - { - // get the mask value at this location - maskValue=texture3D(maskTexture,pos); - - if(maskValue.a!=0.0) - { - sample=texture3D(dataSetTexture,pos); - maxValue=max(maxValue,sample.r); - } - - pos=pos+rayDir; - t+=1.0; - - // yes, t=lowBounds.x && pos.y>=lowBounds.y - && pos.z>=lowBounds.z && pos.x<=highBounds.x && pos.y<=highBounds.y - && pos.z<=highBounds.z; - } - } - - sample=texture1D(colorTexture,maxValue); - vec4 opacity=texture1D(opacityTexture,maxValue); - - writeColorAndMaxScalar(sample,opacity,maxValue); -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPCroppingFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPCroppingFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPCroppingFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPCroppingFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_MIPCroppingFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Implementation of some functions used by the Maximum Intensity Projection -// (MIP) method when cropping is on. - -#version 110 - -// GLSL Spec 1.10 rev 59 30-April-2004 defines gl_FragData[] but implementation -// older than the spec only has it as an extension -// (nVidia Linux driver 100.14.13, OpenGL version 2.1.1, -// on Quadro FX 3500/PCI/SSE2) -#extension GL_ARB_draw_buffers : enable - -// max scalar buffer as an input -uniform sampler2D scalarBufferTexture; -// 2D Texture fragment coordinates [0,1] from fragment coordinates -// the scalar frame buffer texture has the size of the plain buffer but -// we use a fraction of it. The texture coordinates is less than 1 if -// the reduction factor is less than 1. -vec2 fragTexCoord; - -float initialMaxValue() -{ - return texture2D(scalarBufferTexture,fragTexCoord).r; -} - -void writeColorAndMaxScalar(vec4 sample, - vec4 opacity, - float maxValue) -{ - // color framebuffer - gl_FragData[0].r =sample.r * opacity.a; - gl_FragData[0].g =sample.g * opacity.a; - gl_FragData[0].b =sample.b * opacity.a; - gl_FragData[0].a=opacity.a; - - // max scalar framebuffer - gl_FragData[1].r=maxValue; - gl_FragData[1].g=0.0; - gl_FragData[1].b=0.0; - gl_FragData[1].a=0.0; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPFourDependentCroppingFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPFourDependentCroppingFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPFourDependentCroppingFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPFourDependentCroppingFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_MIPFourDependentCroppingFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Implementation of some functions used by the 4-component Maximum Intensity -// Projection (MIP) method when cropping is on. - -#version 110 - -// GLSL Spec 1.10 rev 59 30-April-2004 defines gl_FragData[] but implementation -// older than the spec only has it as an extension -// (nVidia Linux driver 100.14.13, OpenGL version 2.1.1, -// on Quadro FX 3500/PCI/SSE2) -#extension GL_ARB_draw_buffers : enable - -// max scalar buffer as an input -uniform sampler2D scalarBufferTexture; - -// color buffer as an input -uniform sampler2D frameBufferTexture; - -// 2D Texture fragment coordinates [0,1] from fragment coordinates -// the scalar frame buffer texture has the size of the plain buffer but -// we use a fraction of it. The texture coordinates is less than 1 if -// the reduction factor is less than 1. -vec2 fragTexCoord; - -float initialMaxValue() -{ - return texture2D(scalarBufferTexture,fragTexCoord).r; -} - -vec4 initialColor() -{ - return texture2D(frameBufferTexture,fragTexCoord); -} - -void writeColorAndMaxScalar(vec4 color, - vec4 opacity, - float maxValue) -{ - // color framebuffer - gl_FragData[0].r = color.r*opacity.a; - gl_FragData[0].g = color.g*opacity.a; - gl_FragData[0].b = color.b*opacity.a; - gl_FragData[0].a=opacity.a; - - // max scalar framebuffer - gl_FragData[1].r=maxValue; - gl_FragData[1].g=0.0; - gl_FragData[1].b=0.0; - gl_FragData[1].a=0.0; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPFourDependentFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPFourDependentFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPFourDependentFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPFourDependentFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_MIPFourDependentFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Fragment program with ray cast and 4-dependent-component Maximum Intensity -// Projection (MIP) method. -// Compilation: header part and the projection part are inserted first. -// pos is defined and initialized in header -// rayDir is defined in header and initialized in the projection part - -#version 110 - -uniform sampler3D dataSetTexture; -uniform sampler1D opacityTexture; - -uniform vec3 lowBounds; -uniform vec3 highBounds; - -// Entry position (global scope) -vec3 pos; -// Incremental vector in texture space (global scope) -vec3 rayDir; - -float tMax; - -// Sub-functions, depending on cropping mode -float initialMaxValue(); -vec4 initialColor(); -void writeColorAndMaxScalar(vec4 color, - vec4 opacity, - float maxValue); - -void trace(void) -{ - // Max intensity is the lowest value. - float maxValue=initialMaxValue(); - vec4 color=initialColor(); - bool inside=true; - float t=0.0; - vec4 sample; - bool changed=false; - - // We NEED two nested while loops. It is a trick to work around hardware - // limitation about the maximum number of loops. - while(inside) - { - while(inside) - { - sample=texture3D(dataSetTexture,pos); - if(sample.w>maxValue) - { - changed=true; - maxValue=sample.w; - color=sample; - } - pos=pos+rayDir; - t+=1.0; - - // yes, t=lowBounds.x && pos.y>=lowBounds.y - && pos.z>=lowBounds.z && pos.x<=highBounds.x && pos.y<=highBounds.y - && pos.z<=highBounds.z; - } - } - - if(changed) - { - vec4 opacity=texture1D(opacityTexture,maxValue); - writeColorAndMaxScalar(color,opacity,maxValue); - } - else - { - discard; - } -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPFourDependentNoCroppingFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPFourDependentNoCroppingFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPFourDependentNoCroppingFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPFourDependentNoCroppingFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_MIPFourDependentNoCroppingFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Implementation of some functions used by the 4-component Maximum Intensity -// Projection (MIP) method when cropping is off. - -#version 110 - -float initialMaxValue() -{ - return 0.0; -} - -vec4 initialColor() -{ - return vec4(0.0,0.0,0.0,0.0); -} - -void writeColorAndMaxScalar(vec4 color, - vec4 opacity, - float maxValue) -{ - // maxValue is not used - - // color framebuffer - gl_FragColor.r = color.r*opacity.a; - gl_FragColor.g = color.g*opacity.a; - gl_FragColor.b = color.b*opacity.a; - gl_FragColor.a=opacity.a; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_MIPFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Fragment program with ray cast and Maximum Intensity Projection (MIP) -// method. -// Compilation: header part and the projection part are inserted first. -// pos is defined and initialized in header -// rayDir is defined in header and initialized in the projection part -// initMaxValue() and writeColorAndMaxScalar are defined in some specific -// file depending on cropping flag being on or off. - -#version 110 - -uniform sampler3D dataSetTexture; -uniform sampler1D colorTexture; -uniform sampler1D opacityTexture; - -uniform vec3 lowBounds; -uniform vec3 highBounds; - -// Entry position (global scope) -vec3 pos; -// Incremental vector in texture space (global scope) -vec3 rayDir; - -float tMax; - -// Sub-functions, depending on cropping mode -float initialMaxValue(); -void writeColorAndMaxScalar(vec4 sample, - vec4 opacity, - float maxValue); - -void trace(void) -{ - // Max intensity is the lowest value. - float maxValue=initialMaxValue(); - bool inside=true; - vec4 sample; - - float t=0.0; - // We NEED two nested while loops. It is trick to work around hardware - // limitation about the maximum number of loops. - while(inside) - { - while(inside) - { - sample=texture3D(dataSetTexture,pos); - maxValue=max(maxValue,sample.r); - pos=pos+rayDir; - t+=1.0; - - // yes, t=lowBounds.x && pos.y>=lowBounds.y - && pos.z>=lowBounds.z && pos.x<=highBounds.x && pos.y<=highBounds.y - && pos.z<=highBounds.z; - } - } - - sample=texture1D(colorTexture,maxValue); - vec4 opacity=texture1D(opacityTexture,maxValue); - - writeColorAndMaxScalar(sample,opacity,maxValue); -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPNoCroppingFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPNoCroppingFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPNoCroppingFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_MIPNoCroppingFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_MIPNoCroppingFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Implementation of some functions used by the Maximum Intensity projection -// (MIP) method when cropping is off. - -#version 110 - -float initialMaxValue() -{ - return 0.0; -} - -void writeColorAndMaxScalar(vec4 sample, - vec4 opacity, - float maxValue) -{ - // we don't need to write maxValue to a buffer when there is no cropping. - // color framebuffer - gl_FragColor.r =sample.r * opacity.a; - gl_FragColor.g =sample.g * opacity.a; - gl_FragColor.b =sample.b * opacity.a; - gl_FragColor.a=opacity.a; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_NoShadeFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_NoShadeFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_NoShadeFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_NoShadeFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_NoShadeFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Fragment shader that implements initShade() and shade() in the case of no -// shading. -// The functions are used in composite mode. - -#version 110 - -// "value" is a sample of the dataset. -// Think of "value" as an object. - -// from 1- vs 4-component shader. -vec4 colorFromValue(vec4 value); - -// ---------------------------------------------------------------------------- -void initShade() -{ - // empty, nothing to do. -} - -// ---------------------------------------------------------------------------- -vec4 shade(vec4 value) -{ - return colorFromValue(value); -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_OneComponentFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_OneComponentFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_OneComponentFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_OneComponentFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_OneComponentFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Fragment shader that implements scalarFromValue() and colorFromValue() in -// the case of a one-component dataset. -// The functions are used in composite mode. - -#version 110 - -// "value" is a sample of the dataset. -// Think of "value" as an object. - -uniform sampler1D colorTexture; - -float scalarFromValue(vec4 value) -{ - return value.x; -} - -vec4 colorFromValue(vec4 value) -{ - return texture1D(colorTexture,value.x); -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_ParallelProjectionFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_ParallelProjectionFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_ParallelProjectionFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_ParallelProjectionFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_ParallelProjectionFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Parallel projection. - -#version 110 - -uniform vec3 parallelRayDirection; - -// Incremental vector in texture space (global scope) -vec3 rayDir; - -// Defined in the right projection method. -void incrementalRayDirection() -{ - rayDir=parallelRayDirection; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_PerspectiveProjectionFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_PerspectiveProjectionFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_PerspectiveProjectionFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_PerspectiveProjectionFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_PerspectiveProjectionFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// Perspective projection. - -#version 110 - -// Entry position (global scope) -vec3 pos; -// Incremental vector in texture space (global scope) -vec3 rayDir; - -// Camera position in texture space -uniform vec3 cameraPosition; -// Sample distance in world space -uniform float sampleDistance; -// Matrix coefficients: diagonal (a11,a22,a33) -uniform vec3 matrix1; -// Matrix coefficients: others (2a12,2a23,2a13) -uniform vec3 matrix2; - -// Defined in the right projection method. -void incrementalRayDirection() -{ - // Direction of the ray in texture space, not normalized. - rayDir=pos-cameraPosition; - - // x^2, y^2, z^2 - vec3 normDir=rayDir*rayDir; - normDir.x=dot(normDir,matrix1); - - // xy,yz,zx - vec3 coefs=rayDir*rayDir.yxz; - coefs.x=dot(coefs,matrix2); - - // n^2 - normDir.x=normDir.x+coefs.x; - - // 1/n - // normDir=1/sqrt(normDir) - normDir.x=inversesqrt(normDir.x); - - // Final scale factor for the ray direction in texture space - // normDir=normDir*sampleDistance - normDir.x=normDir.x*sampleDistance; - // Now, rayDir is the incremental direction in texture space - rayDir=rayDir*normDir.x; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_ScaleBiasFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_ScaleBiasFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_ScaleBiasFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_ScaleBiasFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_ScaleBiasFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// This fragment shader scales and biases a framebuffer passed as a texture. -// Incoming color from the texture is pre-multiplied by alpha. -// It does not affect the alpha component. -// Passing the framebuffer as a texture allows the use of a reduction factor -// compared to the size of the final image. - -#version 110 - -// Framebuffer to scale. -uniform sampler2D frameBufferTexture; -uniform float scale; -uniform float bias; - -void main() -{ - vec4 color=texture2D(frameBufferTexture,gl_TexCoord[0].xy); - if(color.a==0.0) - { - discard; - } - // As incoming color is pre-multiplied by alpha, the bias has to be - // multiplied by alpha before adding it. - gl_FragColor.r=color.r*scale+bias*color.a; - gl_FragColor.g=color.g*scale+bias*color.a; - gl_FragColor.b=color.b*scale+bias*color.a; - gl_FragColor.a=color.a; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_ShadeFS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_ShadeFS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_ShadeFS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkGPUVolumeRayCastMapper_ShadeFS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,207 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_ShadeFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -// Fragment shader that implements initShade() and shade() in the case of -// shading. -// The functions are used in composite mode. - -#version 110 - -// "value" is a sample of the dataset. -// Think of "value" as an object. - -// from 1- vs 4-component shader. -vec4 colorFromValue(vec4 value); - -uniform sampler3D dataSetTexture; // need neighbors for gradient - -// Change-of-coordinate matrix from eye space to texture space -uniform mat3 eyeToTexture3; -uniform mat4 eyeToTexture4; - -// Tranpose of Change-of-coordinate matrix from texture space to eye space -uniform mat3 transposeTextureToEye; - -// Used to compute the gradient. -uniform vec3 cellStep; -uniform vec3 cellScale; - - -// Entry position (global scope), updated in the loop -vec3 pos; -// Incremental vector in texture space (global scope) -vec3 rayDir; - - -// local to the implementation, shared between initShade() and shade() -const vec3 minusOne=vec3(-1.0,-1.0,-1.0); -const vec4 clampMin=vec4(0.0,0.0,0.0,0.0); -const vec4 clampMax=vec4(1.0,1.0,1.0,1.0); - -vec3 xvec; -vec3 yvec; -vec3 zvec; -vec3 wReverseRayDir; -vec3 lightPos; -vec3 ldir; -vec3 h; -vec4 hPos; // homogeneous position - -// ---------------------------------------------------------------------------- -void initShade() -{ - xvec=vec3(cellStep.x,0.0,0.0); // 0.01 - yvec=vec3(0.0,cellStep.y,0.0); - zvec=vec3(0.0,0.0,cellStep.z); - - // Reverse ray direction in eye space - wReverseRayDir=eyeToTexture3*rayDir; - wReverseRayDir=wReverseRayDir*minusOne; - wReverseRayDir=normalize(wReverseRayDir); - - // Directonal light: w==0 - if(gl_LightSource[0].position.w==0.0) - { - ldir=gl_LightSource[0].position.xyz; - ldir=normalize(ldir); - h=normalize(ldir+wReverseRayDir); - } - else - { - lightPos=gl_LightSource[0].position.xyz/gl_LightSource[0].position.w; - hPos.w=1.0; // used later - } -} - -// ---------------------------------------------------------------------------- -vec4 shade(vec4 value) -{ - vec3 g1; - vec3 g2; - vec4 tmp; - float att; - float spot; - - g1.x=texture3D(dataSetTexture,pos+xvec).x; - g1.y=texture3D(dataSetTexture,pos+yvec).x; - g1.z=texture3D(dataSetTexture,pos+zvec).x; - g2.x=texture3D(dataSetTexture,pos-xvec).x; - g2.y=texture3D(dataSetTexture,pos-yvec).x; - g2.z=texture3D(dataSetTexture,pos-zvec).x; - // g1-g2 is the gradient in texture coordinates - // the result is the normalized gradient in eye coordinates. - - g2=g1-g2; - g2=g2*cellScale; - - float normalLength=length(g2); - if(normalLength>0.0) - { - g2=normalize(transposeTextureToEye*g2); - } - else - { - g2=vec3(0.0,0.0,0.0); - } - - vec4 color=colorFromValue(value); - - vec4 frontLightProduct_Diffuse= gl_LightSource[0].diffuse*gl_FrontMaterial.diffuse; - vec4 frontLightProduct_Specular= gl_LightSource[0].specular*gl_FrontMaterial.specular; - - // initialize color to 0.0 - vec4 finalColor=vec4(0.0,0.0,0.0,0.0); - - if(gl_LightSource[0].position.w!=0.0) - { - // We need to know the eye position only if light is positional - // ldir= vertex position in eye coordinates - hPos.xyz=pos; - tmp=eyeToTexture4*hPos; - ldir=tmp.xyz/tmp.w; - // ldir=light direction - ldir=lightPos-ldir; - float sqrDistance=dot(ldir,ldir); - ldir=normalize(ldir); - h=normalize(ldir+wReverseRayDir); - att=1.0/(gl_LightSource[0].constantAttenuation+gl_LightSource[0].linearAttenuation*sqrt(sqrDistance)+gl_LightSource[0].quadraticAttenuation*sqrDistance); - } - else - { - att=1.0; - } - - if(att>0.0) - { - - if(gl_LightSource[0].spotCutoff==180.0) - { - spot=1.0; - } - else - { - float coef=-dot(ldir,gl_LightSource[0].spotDirection); - if(coef>=gl_LightSource[0].spotCosCutoff) - { - spot=pow(coef,gl_LightSource[0].spotExponent); - } - else - { - spot=0.0; - } - } - - if(spot>0.0) - { - // LIT operation... - float nDotL=dot(g2,ldir); - float nDotH=dot(g2,h); - - // separate nDotL and nDotH for two-sided shading, otherwise we - // get black spots. - - if(nDotL<0.0) // two-sided shading - { - nDotL=-nDotL; - } - - if(nDotH<0.0) // two-sided shading - { - nDotH=-nDotH; - } - - // ambient term for this light - finalColor+=gl_FrontLightProduct[0].ambient; - - // diffuse term for this light - if(nDotL>0.0) - { - finalColor +=(frontLightProduct_Diffuse*nDotL)*color; - } - - // specular term for this light - float shininessFactor=pow(nDotH,gl_FrontMaterial.shininess); - finalColor+=frontLightProduct_Specular*shininessFactor; - finalColor*=att*spot; - } - } - - // scene ambient term - finalColor+=gl_FrontLightModelProduct.sceneColor*color; - - // clamp. otherwise we get black spots - finalColor=clamp(finalColor,clampMin,clampMax); - - return finalColor; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k2BeginFP.asm paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k2BeginFP.asm --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k2BeginFP.asm 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k2BeginFP.asm 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -!!ARBfp1.0 -#------------------------------------------------------------------------------ -# Copyright 2005 by University of Utah -# -# Hardware-Assisted Visibility Sorting -# -# The program consists of the following steps: -# -# 1. Clear k-buffers entries 1 and 2 to -1.0 -# -# The following textures are used: -# -# Tex 1: k-buffer entries 1 and 2 (same) -# - -# ----------------------------------------------------------------------------- -# use the ATI_draw_buffers extension -OPTION ATI_draw_buffers; -# this does not matter now, but will matter on future hardware -OPTION ARB_precision_hint_nicest; - -MOV result.color[0], 0.0; -MOV result.color[1], -1.0; - -END diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k2EndFP.asm paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k2EndFP.asm --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k2EndFP.asm 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k2EndFP.asm 1970-01-01 00:00:00.000000000 +0000 @@ -1,133 +0,0 @@ -!!ARBfp1.0 -# ----------------------------------------------------------------------------- -# Copyright 2005 by University of Utah -# -# Hardware-Assisted Visibility Sorting -# -# The program consists of the following steps: -# -# 1. Find the first and second entries in the fixed sized k-buffer list sorted -# by z (2+1 entries) -# 2. Perform a 3D pre-integrated transfer function lookup using front and back -# scalar data values + the segment length computed from the depth values -# of the first and second entries from the k-buffer. -# 3. Composite the color and opacity from the transfer funcion with the -# color and opacity from the framebuffer. Discard winning k-buffer entry, -# write the remaining k-buffer entries. -# -# The following textures are used: -# -# Tex 0: framebuffer (pbuffer, 2D RGBA 8/16 bpp int or 16/32 bpp float) -# Tex 1: k-buffer entries 1 and 2(same) -# Tex 2: transfer function (regular, 3D RGBA 8/16 bpp int) -# - -# ----------------------------------------------------------------------------- -# use the ATI_draw_buffers extension -OPTION ATI_draw_buffers; -# this may matter on future ATI hardware -OPTION ARB_precision_hint_nicest; - -# ----------------------------------------------------------------------------- -# input and temporaries -ATTRIB p = fragment.position; # fragment position in screen space -PARAM sz = program.local[0]; # texture scale and max gap length parameters - # {1/pw, 1/ph, max, not_used)} -PARAM half = { 0.5, 0.5, 0.0, 0.0 }; -PARAM exp = { 0.0, 0.0, 0.0, 1.44269504 }; # 1/ln2 - -TEMP a1, a2; # k-buffer entries -TEMP r0, r1; # sorted results -TEMP c, c0; # color and opacity -TEMP t; # temporary variable -TEMP colorBack,colorFront; -TEMP taud, zeta, gamma, Psi; - -# ----------------------------------------------------------------------------- -# compute texture coordinates from window position so that it is not -# interpolated perspective correct. Then look up the color and opacity from -# the framebuffer -MUL t, p, sz; # t.xy = p.xy * sz.xy, only x and y are used for texture lookup -TEX c0, t, texture[0], 2D; # framebuffer color - -# ----------------------------------------------------------------------------- -# Check opacity and kill fragment if it is greater than tolerance -SUB t.w, 0.99, c0.w; -KIL t.w; - -# ----------------------------------------------------------------------------- -# set up the k-buffer entries a1, a2 -# each k-buffer entry consists of the scalar data value in x or z and the -# depth value in y or w -TEX a1, t, texture[1], 2D; # k-buffer entry 1 -MOV a2, a1.zwzw; # k-buffer entry 2 - -# ----------------------------------------------------------------------------- -# find fragment with minimum z (r0), save the other to r1 - -# r0 = min_d(a1, a2); r1 = max_d(a1, a2); -SUB t.w, a1.y, a2.y; # t.w < 0 iff a1.y < a2.y -CMP r1, t.w, a2, a1; # r1 = (a1.y < a2.y ? a2 : a1) -CMP r0, t.w, a1, a2; # r0 = (a1.y < a2.y ? a1 : a2) - -# ----------------------------------------------------------------------------- -# set up texture coordinates for transfer function lookup -MOV t.x, r0.x; # front scalar -MOV t.y, r1.x; # back scalar -SUB t.z, r1.y, r0.y; # z distance between front and back - -# ----------------------------------------------------------------------------- -# nullify fragment if distance is greater than unit scale (non-convexities) -SUB t.w, sz.z, t.z; -CMP t.z, t.w, 0.0, t.z; - -# ----------------------------------------------------------------------------- -# transfer function lookup -TEX colorFront, t.x, texture[3], 1D; -TEX colorBack, t.y, texture[3], 1D; -MUL taud.x, t.z, colorBack.a; -MUL taud.y, t.z, colorFront.a; - -# ----------------------------------------------------------------------------- -# compute zeta = exp(-0.5*(taudf+taudb) -DP3 zeta.w, taud, half; -MUL zeta.w, exp.w, zeta.w; -EX2 zeta.w, -zeta.w; - -# ----------------------------------------------------------------------------- -# compute gamma = taud/(1+taud); -ADD t, taud, 1.0; -RCP t.x, t.x; -RCP t.y, t.y; -MUL gamma, taud, t; - -# ----------------------------------------------------------------------------- -# lookup Psi -TEX Psi.w, gamma, texture[2], 2D; - -# ----------------------------------------------------------------------------- -# compute color = cb(psi-zeta) + cf(1.0-psi) -SUB t.w, Psi.w, zeta.w; -MUL colorBack, colorBack, t.w; -SUB t.w, 1.0, Psi.w; -MUL colorFront, colorFront, t.w; -ADD c, colorBack, colorFront; -SUB c.a, 1.0, zeta.w; - -# ----------------------------------------------------------------------------- -# nullify winning entry if the scalar value < 0 -CMP c, r0.x, 0.0, c; -CMP c, r1.x, 0.0, c; - -# ----------------------------------------------------------------------------- -# composite color with the color from the framebuffer !!!front to back!!! -SUB t.w, 1.0, c0.w; -MAD result.color[0], c, t.w, c0; - -# ----------------------------------------------------------------------------- -# write remaining k-buffer entry and invalidate one entry -MOV r1.z, -1.0; -MOV r1.w, 10000.0; -MOV result.color[1], r1; - -END diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k2FP.asm paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k2FP.asm --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k2FP.asm 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k2FP.asm 1970-01-01 00:00:00.000000000 +0000 @@ -1,152 +0,0 @@ -!!ARBfp1.0 -# ----------------------------------------------------------------------------- -# Copyright 2005 by University of Utah -# -# Hardware-Assisted Visibility Sorting -# -# The program consists of the following steps: -# -# 1. Find the first and second entries in the fixed size k-buffer list sorted -# by d (2+1 entries) -# 2. Perform a 3D pre-integrated transfer function lookup using front and back -# scalar data values + the segment length computed from the distance values -# of the first and second entries from the k-buffer. -# 3. Composite the color and opacity from the transfer funcion with the -# color and opacity from the framebuffer. Discard winning k-buffer entry, -# write the remaining k-buffer entries. -# -# The following textures are used: -# -# Tex 0: framebuffer (pbuffer, 2D RGBA 16/32 bpp float) -# Tex 1: k-buffer entries 1 and 2 (same) -# Tex 4: transfer function (regular, 3D RGBA 8/16 bpp int) -# - -# ----------------------------------------------------------------------------- -# use the ATI_draw_buffers extension -OPTION ATI_draw_buffers; -# this does not matter now, but will matter on future hardware -OPTION ARB_precision_hint_nicest; - -# ----------------------------------------------------------------------------- -# input and temporaries -ATTRIB p = fragment.position; # fragment position in screen space -ATTRIB v = fragment.texcoord[0]; # v.x = scalar value in -ATTRIB e = fragment.texcoord[1]; # fragment position in eye space -PARAM sz = program.local[0]; # texture scale and max gap length parameters - # {1/pw, 1/ph, max, not_used)} -PARAM half = { 0.5, 0.5, 0.0, 0.0 }; -PARAM exp = { 0.0, 0.0, 0.0, 1.44269504 }; # 1/ln2 - -TEMP a0, a1, a2; # k-buffer entries -TEMP r0, r1, r2, r3; # sorted results -TEMP c, c0; # color and opacity -TEMP t; # temporary (boolean flag for min/max, dependent texture coordinate, - # pbuffer texture coordinate, fragment to eye distance) -TEMP colorBack, colorFront; -TEMP taud, zeta, gamma, Psi; - -# ----------------------------------------------------------------------------- -# compute texture coordinates from window position so that it is not -# interpolated perspective correct. Then look up the color and opacity from -# the framebuffer -MUL t, p, sz; # t.xy = p.xy * sz.xy, only x and y are used for texture lookup -TEX c0, t, texture[0], 2D; # framebuffer color - -# ----------------------------------------------------------------------------- -# Check opacity and kill fragment if it is greater than tolerance -SUB t.w, 0.99, c0.w; -KIL t.w; - -# ----------------------------------------------------------------------------- -# set up the k-buffer entries a0, a1 -# each k-buffer entry contains the scalar data value in x or z -# and the distance value in y or w -TEX a1, t, texture[1], 2D; # k-buffer entry 1 -MOV a2, a1.zwzw; # k-buffer entry 2 - -# ----------------------------------------------------------------------------- -# compute fragment to eye distance -DP3 t, e, e; -RSQ t.y, t.y; -MUL a0.y, t.x, t.y; # fragment to eye distance -MOV a0.x, v.x; # scalar data value - -# ----------------------------------------------------------------------------- -# find fragment with minimum d (r0), save the rest to r1, r2, r3 - -# r0 = min_d(a0, a1); r1 = max_d(a0, a1); -SUB t.w, a0.y, a1.y; # t.w < 0 iff a0.y < a1.y -CMP r1, t.w, a1, a0; # r1 = (a0.y < a1.y ? a1 : a0) -CMP r0, t.w, a0, a1; # r0 = (a0.y < a1.y ? a0 : a1) - -# r0 = min_d(r0, a2); r2 = max_d(r0, a2) -SUB t.w, r0.y, a2.y; # t.w < 0 iff r0.y < a2.y -CMP r2, t.w, a2, r0; # r2 = (r0.y < a2.y ? a2 : r0) -CMP r0, t.w, r0, a2; # r0 = (r0.y < a2.y ? r0 : a2) - -# ----------------------------------------------------------------------------- -# find fragment with minimum d (r3) from r1, r2 - -# r3 = min_d(r1, r2); -SUB t.w, r1.y, r2.y; # t.w < 0 iff r1.y < r2.y -CMP r3, t.w, r1, r2; # r3 = (r1.y < r2.y ? r1 : r2); - -# ----------------------------------------------------------------------------- -# set up texture coordinates for transfer function lookup -MOV t.x, r0.x; # front scalar -MOV t.y, r3.x; # back scalar -SUB t.z, r3.y, r0.y; # distance between front and back fragment - -# ----------------------------------------------------------------------------- -# nullify fragment if distance is greater than unit scale (non-convexities) -SUB t.w, sz.z, t.z; -CMP t.z, t.w, 0.0, t.z; - -# ----------------------------------------------------------------------------- -# transfer function lookup -TEX colorFront, t.x, texture[3], 1D; -TEX colorBack, t.y, texture[3], 1D; -MUL taud.x, t.z, colorBack.a; -MUL taud.y, t.z, colorFront.a; - -# ----------------------------------------------------------------------------- -# compute zeta = exp(-0.5*(taudf+taudb)) -DP3 zeta.w, taud, half; -MUL zeta.w, exp.w, zeta.w; -EX2 zeta.w, -zeta.w; - -# ----------------------------------------------------------------------------- -# compute gamma = taud/(1+taud); -ADD t, taud, 1.0; -RCP t.x, t.x; -RCP t.y, t.y; -MUL gamma, taud, t; - -# ----------------------------------------------------------------------------- -# lookup Psi -TEX Psi.w, gamma, texture[2], 2D; - -# ----------------------------------------------------------------------------- -# compute color = cb(psi-zeta) + cf(1.0-psi) -SUB t.w, Psi.w, zeta.w; -MUL colorBack, colorBack, t.w; -SUB t.w, 1.0, Psi.w; -MUL colorFront, colorFront, t.w; -ADD c, colorBack, colorFront; -SUB c.a, 1.0, zeta.w; - -# ----------------------------------------------------------------------------- -# nullify winning entry if the scalar value < 0 -CMP c, r0.x, 0.0, c; - -# ----------------------------------------------------------------------------- -# composite color with the color from the framebuffer !!!front to back!!! -SUB t.w, 1.0, c0.w; -MAD result.color[0], c, t.w, c0; - -# ----------------------------------------------------------------------------- -# write remaining k-buffer entries -MOV r1.zw, r2.xxxy; -MOV result.color[1], r1; -END diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k6BeginFP.asm paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k6BeginFP.asm --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k6BeginFP.asm 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k6BeginFP.asm 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -!!ARBfp1.0 -# ----------------------------------------------------------------------------- -# Copyright 2005 by University of Utah -# -# Hardware-Assisted Visibility Sorting -# -# The program consists of the following steps: -# -# 1. Clear k-buffers entries 1 and 2 to -1.0 -# -# The following textures are used: -# -# Tex 1: k-buffer entries 1 and 2 -# Tex 2: k-buffer entries 3 and 4 -# Tex 3: k-buffer entries 5 and 6 -# - -# ----------------------------------------------------------------------------- -# use the ATI_draw_buffers extension -OPTION ATI_draw_buffers; -# this does not matter now, but will matter on future hardware -OPTION ARB_precision_hint_nicest; - -MOV result.color[0], 0.0; -MOV result.color[1], -1.0; -MOV result.color[2], -1.0; -MOV result.color[3], -1.0; -END diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k6EndFP.asm paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k6EndFP.asm --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k6EndFP.asm 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k6EndFP.asm 1970-01-01 00:00:00.000000000 +0000 @@ -1,182 +0,0 @@ -!!ARBfp1.0 -# ----------------------------------------------------------------------------- -# Copyright 2005 by University of Utah -# -# Hardware-Assisted Visibility Sorting -# -# The program consists of the following steps: -# -# 1. Find the first and second entries in the fixed size k-buffer list sorted -# by z (6+1 entries) -# 2. Perform a 3D pre-integrated transfer function lookup using front and back -# scalar data values + the segment length computed from the depth values -# of the first and second entries from the k-buffer. -# 3. Composite the color and opacity from the transfer funcion with the -# color and opacity from the framebuffer. Discard winning k-buffer entry, -# write the remaining k-buffer entries. -# -# The following textures are used: -# -# Tex 0: framebuffer (pbuffer, 2D RGBA 8/16 bpp int or 16/32 bpp float) -# Tex 1: k-buffer entries 1 and 2(same) -# Tex 2: k-buffer entries 3 and 4(same) -# Tex 3: k-buffer entries 5 and 6(same) -# Tex 4: transfer function (regular, 3D RGBA 8/16 bpp int) -# - -# ----------------------------------------------------------------------------- -# use the ATI_draw_buffers extension -OPTION ATI_draw_buffers; -# this may matter on future ATI hardware -OPTION ARB_precision_hint_nicest; - -# ----------------------------------------------------------------------------- -# input and temporaries -ATTRIB p = fragment.position; # fragment position in screen space -PARAM sz = program.local[0]; # texture scale and max gap length parameters - # {1/pw, 1/ph, max, not_used)} -PARAM half = { 0.5, 0.5, 0.0, 0.0 }; -PARAM exp = { 0.0, 0.0, 0.0, 1.44269504 }; # 1/ln2 - -TEMP a1, a2, a3, a4, a5, a6; # k-buffer entries -TEMP r0, r1, r2, r3, r4, r5, r6; # sorted results -TEMP c, c0; # color and opacity -TEMP t; # temporary variable -TEMP colorBack,colorFront; -TEMP taud, zeta, gamma, Psi; - -# ----------------------------------------------------------------------------- -# compute texture coordinates from window position so that it is not -# interpolated perspective correct. Then look up the color and opacity from -# the framebuffer -MUL t, p, sz; # t.xy = p.xy * sz.xy, only x and y are used for texture lookup -TEX c0, t, texture[0], 2D; # framebuffer color - -# ----------------------------------------------------------------------------- -# Check opacity and kill fragment if it is greater than tolerance -SUB t.w, 0.99, c0.w; -KIL t.w; - -# ----------------------------------------------------------------------------- -# set up the k-buffer entries a1, a2 -# each k-buffer entry consists of the scalar data value in x or z and the -# depth value in y or w -TEX a1, t, texture[1], 2D; # k-buffer entry 1 -TEX a3, t, texture[2], 2D; # k-buffer entry 3 -TEX a5, t, texture[3], 2D; # k-buffer entry 5 -MOV a2, a1.zwzw; # k-buffer entry 2 -MOV a4, a3.zwzw; # k-buffer entry 4 -MOV a6, a5.zwzw; # k-buffer entry 6 - -# ----------------------------------------------------------------------------- -# find fragment with minimum z (r0), save the other to r1 - -# r0 = min_z(a1.y, a2.y); r1 = max_z(a1.y, a2.y); -SUB t.w, a1.y, a2.y; # t.w < 0 iff a1.y < a2.y -CMP r1, t.w, a2, a1; # r1 = (a1.y < a2.y ? a2 : a1) -CMP r0, t.w, a1, a2; # r0 = (a1.y < a2.y ? a1 : a2) - -# r0 = min_z(r0.y, a3.y); r2 = max_z(r0.y, a3.y) -SUB t.w, r0.y, a3.y; # t.w < 0 iff r0.y < a3.y -CMP r2, t.w, a3, r0; # r2 = (r0.y < a3.y ? a3 : r0); -CMP r0, t.w, r0, a3; # r0 = (r0.y < a3.y ? r0 : a3); - -# r0 = min_z(r0.y, a4.y); r3 = max_z(r0.y, a4.y) -SUB t.w, r0.y, a4.y; # t.w < 0 iff r0.y < a4.y -CMP r3, t.w, a4, r0; # r3 = (r0.y < a4.y ? a4 : r0) -CMP r0, t.w, r0, a4; # r0 = (r0.y < a4.y ? r0 : a4); - -# r0 = min_z(r0.y, a5.y); r4 = max_z(r0.y, a5.y) -SUB t.w, r0.y, a5.y; # t.w < 0 iff r0.y < a5.y -CMP r4, t.w, a5, r0; # r4 = (r0.y < a5.y ? a5 : r0); -CMP r0, t.w, r0, a5; # r0 = (r0.y < a5.y ? r0 : a5); - -# r0 = min_z(r0.y, a6.y); r5 = max_z(r0.y, a6.y) -SUB t.w, r0.y, a6.y; # t.w < 0 iff r0.y < a6.y -CMP r5, t.w, a6, r0; # r5 = (r0.y < a6.y ? a6 : r0); -CMP r0, t.w, r0, a6; # r0 = (r0.y < a6.y ? r0 : a6); - -# ----------------------------------------------------------------------------- -# find fragment with minimum d (r7) from r1, r2, r3, r4, r5 - -# r6 = min_z(r1.y, r2.y); -SUB t.w, r1.y, r2.y; # t.w < 0 iff r1.y < r2.y -CMP r6, t.w, r1, r2; # r6 = (r1.y < r2.y ? r1 : r2); - -# r6 = min_z(r6.y, r3.y); -SUB t.w, r6.y, r3.y; # t.w < 0 iff r6.y < r3.y -CMP r6, t.w, r6, r3; # r6 = (r6.y < r3.y ? r6 : r3); - -# r6 = min_z(r6.y, r4.y); -SUB t.w, r6.y, r4.y; # t.w < 0 iff r6.y < r4.y -CMP r6, t.w, r6, r4; # r6 = (r6.y < r4.y ? r6 : r4); - -# r6 = min_z(r6.y, r5.y); -SUB t.w, r6.y, r5.y; # t.w < 0 iff r6.y < r5.y -CMP r6, t.w, r6, r5; # r6 = (r6.y < r5.y ? r6 : r5); - -# ----------------------------------------------------------------------------- -# set up texture coordinates for transfer function lookup -MOV t.x, r0.x; # front scalar -MOV t.y, r6.x; # back scalar -SUB t.z, r6.y, r0.y; # z distance between front and back - -# ----------------------------------------------------------------------------- -# nullify fragment if distance is greater than unit scale (non-convexities) -SUB t.w, sz.z, t.z; -CMP t.z, t.w, 0.0, t.z; - -# ----------------------------------------------------------------------------- -# transfer function lookup -TEX colorFront, t.x, texture[5], 1D; -TEX colorBack, t.y, texture[5], 1D; -MUL taud.x, t.z, colorBack.a; -MUL taud.y, t.z, colorFront.a; - -# ----------------------------------------------------------------------------- -# compute zeta = exp(-0.5*(taudf+taudb)) -DP3 zeta.w, taud, half; -MUL zeta.w, exp.w, zeta.w; -EX2 zeta.w, -zeta.w; - -# ----------------------------------------------------------------------------- -# compute gamma = taud/(1+taud); -ADD t, taud, 1.0; -RCP t.x, t.x; -RCP t.y, t.y; -MUL gamma, taud, t; - -# ----------------------------------------------------------------------------- -# lookup Psi -TEX Psi.w, gamma, texture[4], 2D; - -# ----------------------------------------------------------------------------- -# compute color = cb(psi-zeta) + cf(1.0-psi) -SUB t.w, Psi.w, zeta.w; -MUL colorBack, colorBack, t.w; -SUB t.w, 1.0, Psi.w; -MUL colorFront, colorFront, t.w; -ADD c, colorBack, colorFront; -SUB c.a, 1.0, zeta.w; - -# ----------------------------------------------------------------------------- -# nullify winning entry if the scalar value < 0 -CMP c, r0.x, 0.0, c; -CMP c, r6.x, 0.0, c; - -# ----------------------------------------------------------------------------- -# composite color with the color from the framebuffer !!!front to back!!! -SUB t.w, 1.0, c0.w; -MAD result.color[0], c, t.w, c0; - -# ----------------------------------------------------------------------------- -# write remaining k-buffer entry and invalidate one entry -MOV r1.zw, r2.xxxy; -MOV r3.zw, r4.xxxy; -MOV r5.z, -1.0; -MOV r5.w, 10000.0; -MOV result.color[1], r1; -MOV result.color[2], r3; -MOV result.color[3], r5; - -END diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k6FP.asm paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k6FP.asm --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k6FP.asm 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_k6FP.asm 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ -!!ARBfp1.0 -# ----------------------------------------------------------------------------- -# Copyright 2005 by University of Utah -# -# Hardware-Assisted Visibility Sorting -# -# The program consists of the following steps: -# -# 1. Find the first and second entries in the fixed size k-buffer list sorted -# by d (6+1 entries) -# 2. Perform a 3D pre-integrated transfer function lookup using front and back -# scalar data values + the segment length computed from the distance values -# of the first and second entries from the k-buffer. -# 3. Composite the color and opacity from the transfer funcion with the -# color and opacity from the framebuffer. Discard winning k-buffer entry, -# write the remaining k-buffer entries. -# -# The following textures are used: -# -# Tex 0: framebuffer (pbuffer, 2D RGBA 16/32 bpp float) -# Tex 1: k-buffer entry 1 and 2(same) -# Tex 2: k-buffer entry 3 and 4(same) -# Tex 3: k-buffer entry 5 and 6(same) -# Tex 4: transfer function (regular, 3D RGBA 8/16 bpp int) -# - -# ----------------------------------------------------------------------------- -# use the ATI_draw_buffers extension -OPTION ATI_draw_buffers; -# this does not matter now, but will matter on future hardware -OPTION ARB_precision_hint_nicest; - -# ----------------------------------------------------------------------------- -# input and temporaries -ATTRIB p = fragment.position; # fragment position in screen space -ATTRIB v = fragment.texcoord[0]; # v.x = scalar value -ATTRIB e = fragment.texcoord[1]; # fragment position in eye space -PARAM sz = program.local[0]; # texture scale and max gap length parameters - # {1/pw, 1/ph, max, not_used} -PARAM half = { 0.5, 0.5, 0.0, 0.0 }; -PARAM exp = { 0.0, 0.0, 0.0, 1.44269504 }; # 1/ln2 - -TEMP a0, a1, a2, a3, a4, a5, a6; # k-buffer entries -TEMP r0, r1, r2, r3, r4, r5, r6, r7; # sorted results -TEMP c, c0; # color and opacity -TEMP t; # temporary (boolean flag for min/max, dependent texture coordinate, - # pbuffer texture coordinate, fragment to eye distance) -TEMP colorBack, colorFront; -TEMP taud, zeta, gamma, Psi; - -# ----------------------------------------------------------------------------- -# compute texture coordinates from window position so that it is not -# interpolated perspective correct. Then look up the color and opacity from -# the framebuffer -MUL t, p, sz; # t.xy = p.xy * sz.xy, only x and y are used for texture lookup -TEX c0, t, texture[0], 2D; # framebuffer color - -# ----------------------------------------------------------------------------- -# Check opacity and kill fragment if it is greater than a constant tolerance -SUB t.w, 0.99, c0.w; -KIL t.w; - -# ----------------------------------------------------------------------------- -# set up the k-buffer entries a0, a1, a2, a3, a4, a5, a6 -# each k-buffer entry contains the scalar data value in x or z -# and the distance value in y or w -TEX a1, t, texture[1], 2D; # k-buffer entry 1 -TEX a3, t, texture[2], 2D; # k-buffer entry 3 -TEX a5, t, texture[3], 2D; # k-buffer entry 5 -MOV a2, a1.zwzw; # k-buffer entry 2 -MOV a4, a3.zwzw; # k-buffer entry 4 -MOV a6, a5.zwzw; # k-buffer entry 6 - - -# ----------------------------------------------------------------------------- -# compute fragment to eye distance -DP3 t, e, e; -RSQ t.y, t.y; -MUL a0.y, t.x, t.y; # fragment to eye distance -MOV a0.x, v.x; # scalar data value - -# ----------------------------------------------------------------------------- -# find fragment with minimum d (r0), save the rest to r1, r2, r3, r4, r5 - -# r0 = min_z(a0.y, a1.y); r1 = max_z(a0.y, a1.y); -SUB t.w, a0.y, a1.y; # t.w < 0 iff a0.y < a1.y -CMP r1, t.w, a1, a0; # r1 = (a0.y < a1.y ? a1 : a0) -CMP r0, t.w, a0, a1; # r0 = (a0.y < a1.y ? a0 : a1) - -# r0 = min_z(r0.y, a2.y); r2 = max_z(r0.y, a2.y) -SUB t.w, r0.y, a2.y; # t.w < 0 iff r0.y < a2.y -CMP r2, t.w, a2, r0; # r2 = (r0.y < a2.y ? a2 : r0); -CMP r0, t.w, r0, a2; # r0 = (r0.y < a2.y ? r0 : a2); - -# r0 = min_z(r0.y, a3.y); r3 = max_z(r0.y, a3.y) -SUB t.w, r0.y, a3.y; # t.w < 0 iff r0.y < a3.y -CMP r3, t.w, a3, r0; # r3 = (r0.y < a3.y ? a3 : r0) -CMP r0, t.w, r0, a3; # r0 = (r0.y < a3.y ? r0 : a3); - -# r0 = min_z(r0.y, a4.y); r4 = max_z(r0.y, a4.y) -SUB t.w, r0.y, a4.y; # t.w < 0 iff r0.y < a4.y -CMP r4, t.w, a4, r0; # r4 = (r0.y < a4.y ? a4 : r0); -CMP r0, t.w, r0, a4; # r0 = (r0.y < a4.y ? r0 : a4); - -# r0 = min_z(r0.y, a5.y); r5 = max_z(r0.y, a5.y) -SUB t.w, r0.y, a5.y; # t.w < 0 iff r0.y < a5.y -CMP r5, t.w, a5, r0; # r5 = (r0.y < a5.y ? a5 : r0); -CMP r0, t.w, r0, a5; # r0 = (r0.y < a5.y ? r0 : a5); - -# r0 = min_z(r0.y, a6.y); r6 = max_z(r0.y, a6.y) -SUB t.w, r0.y, a6.y; # t.w < 0 iff r0.y < a6.y -CMP r6, t.w, a6, r0; # r6 = (r0.y < a6.y ? a6 : r0); -CMP r0, t.w, r0, a6; # r0 = (r0.y < a6.y ? r0 : a6); - -# ----------------------------------------------------------------------------- -# find fragment with minimum d (r7) from r1, r2 - -# r7 = min_z(r1.y, r2.y); -SUB t.w, r1.y, r2.y; # t.w < 0 iff r1.y < r2.y -CMP r7, t.w, r1, r2; # r7 = (r1.y < r2.y ? r1 : r2); - -# r7 = min_z(r7.y, r3.y); -SUB t.w, r7.y, r3.y; # t.w < 0 iff r7.y < r3.y -CMP r7, t.w, r7, r3; # r7 = (r7.y < r3.y ? r7 : r3); - -# r7 = min_z(r7.y, r4.y); -SUB t.w, r7.y, r4.y; # t.w < 0 iff r7.y < r4.y -CMP r7, t.w, r7, r4; # r7 = (r7.y < r4.y ? r7 : r4); - -# r7 = min_z(r7.y, r5.y); -SUB t.w, r7.y, r5.y; # t.w < 0 iff r7.y < r5.y -CMP r7, t.w, r7, r5; # r7 = (r7.y < r5.y ? r7 : r5); - -# r7 = min_z(r7.y, r6.y); -SUB t.w, r7.y, r6.y; # t.w < 0 iff r7.y < r6.y -CMP r7, t.w, r7, r6; # r7 = (r7.y < r6.y ? r7 : r6); - -# ----------------------------------------------------------------------------- -# set up texture coordinates for transfer function lookup - -MOV t.x, r0.x; # front scalar -MOV t.y, r7.x; # back scalar -SUB t.z, r7.y, r0.y; # distance between front and back fragment - -# ----------------------------------------------------------------------------- -# nullify fragment if distance is greater than unit scale (non-convexities) -SUB t.w, sz.z, t.z; -CMP t.z, t.w, 0.0, t.z; - -# ----------------------------------------------------------------------------- -# transfer function lookup -TEX colorFront, t.x, texture[5], 1D; -TEX colorBack, t.y, texture[5], 1D; -MUL taud.x, t.z, colorBack.a; -MUL taud.y, t.z, colorFront.a; - -# ----------------------------------------------------------------------------- -# compute zeta = exp(-0.5*(taudf+taudb)) -DP3 zeta.w, taud, half; -MUL zeta.w, exp.w, zeta.w; -EX2 zeta.w, -zeta.w; - -# ----------------------------------------------------------------------------- -# compute gamma = taud/(1+taud); -ADD t, taud, 1.0; -RCP t.x, t.x; -RCP t.y, t.y; -MUL gamma, taud, t; - -# ----------------------------------------------------------------------------- -# lookup Psi -TEX Psi.w, gamma, texture[4], 2D; - -# ----------------------------------------------------------------------------- -# compute color = cb(psi-zeta) + cf(1.0-psi) -SUB t.w, Psi.w, zeta.w; -MUL colorBack, colorBack, t.w; -SUB t.w, 1.0, Psi.w; -MUL colorFront, colorFront, t.w; -ADD c, colorBack, colorFront; -SUB c.a, 1.0, zeta.w; - -# ----------------------------------------------------------------------------- -# nullify winning entry if the scalar value < 0 -CMP c, r0.x, 0.0, c; - -# ----------------------------------------------------------------------------- -# composite color with the color from the framebuffer !!!front to back!!! -SUB t.w, 1.0, c0.w; -MAD result.color[0], c, t.w, c0; - -# ----------------------------------------------------------------------------- -# write remaining k-buffer entries -MOV r1.zw, r2.xxxy; -MOV r3.zw, r4.xxxy; -MOV r5.zw, r6.xxxy; -MOV result.color[1], r1; -MOV result.color[2], r3; -MOV result.color[3], r5; - -END diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_kbufferVP.asm paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_kbufferVP.asm --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_kbufferVP.asm 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkHAVSVolumeMapper_kbufferVP.asm 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -!!ARBvp1.0 -# ----------------------------------------------------------------------------- -# Copyright 2005 by University of Utah -# -# This program fixes perspective-correct texture lookups -# ----------------------------------------------------------------------------- - -ATTRIB iPos = vertex.position; -ATTRIB iTex0 = vertex.texcoord[0]; -PARAM mvp[4] = { state.matrix.mvp }; -PARAM mv[4] = { state.matrix.modelview }; -OUTPUT oPos = result.position; -OUTPUT oTex0 = result.texcoord[0]; -OUTPUT oTex1 = result.texcoord[1]; - -# ----------------------------------------------------------------------------- -# transform vertex to clip coordinates -DP4 oPos.x, mvp[0], iPos; -DP4 oPos.y, mvp[1], iPos; -DP4 oPos.z, mvp[2], iPos; -DP4 oPos.w, mvp[3], iPos; - -# ----------------------------------------------------------------------------- -# transform vertex to eye coordinates -DP4 oTex1.x, mv[0], iPos; -DP4 oTex1.y, mv[1], iPos; -DP4 oTex1.z, mv[2], iPos; - -# ----------------------------------------------------------------------------- -# texcoord 0 contains the scalar data value -MOV oTex0, iTex0; - -END diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLGPUVolumeRayCastMapper.cxx paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLGPUVolumeRayCastMapper.cxx --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLGPUVolumeRayCastMapper.cxx 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLGPUVolumeRayCastMapper.cxx 1970-01-01 00:00:00.000000000 +0000 @@ -1,6979 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkOpenGLGPUVolumeRayCastMapper.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -#include "vtkOpenGLGPUVolumeRayCastMapper.h" - -#include "vtkObjectFactory.h" -#include "vtkVolume.h" -#include "vtkRenderer.h" -#include "vtkRenderWindow.h" -#include "vtkCamera.h" -#include "vtkMatrix4x4.h" -#include "vtkImageData.h" - -#include "vtkTimerLog.h" - -#include "vtkVolumeProperty.h" -#include "vtkColorTransferFunction.h" -#include "vtkPiecewiseFunction.h" - -#include "vtkOpenGLExtensionManager.h" -#include "vtkgl.h" - -#include "vtkOpenGL.h" - -#include - -#include -#include -#include -#include -#include - -#include "vtkClipDataSet.h" -#include "vtkCellArray.h" -#include "vtkDoubleArray.h" -#include "vtkFloatArray.h" -#include "vtkGeometryFilter.h" -#include "vtkLookupTable.h" -#include "vtkMath.h" -#include "vtkPlane.h" -#include "vtkPlaneCollection.h" -#include "vtkPlanes.h" -#include "vtkPolyData.h" -#include "vtkPointData.h" -#include "vtkCellData.h" -#include "vtkPoints.h" -#include "vtkTriangle.h" -#include "vtkUnsignedCharArray.h" -#include "vtkUnsignedShortArray.h" -#include "vtkUnsignedIntArray.h" -#include "vtkUnstructuredGrid.h" -#include "vtkVoxel.h" - -#include "vtkClipConvexPolyData.h" -#include "vtkClipPolyData.h" -#include "vtkDensifyPolyData.h" - -#include "vtkImageResample.h" - -#include -#include // qsort() - -#include "vtkDataSetTriangleFilter.h" - -#include "vtkAbstractArray.h" // required if compiled against VTK 5.0 - -#include "vtkTessellatedBoxSource.h" -#include "vtkCleanPolyData.h" - -#include "vtkCommand.h" // for VolumeMapperRender{Start|End|Progress}Event -#include "vtkPerlinNoise.h" - -#include -#include "vtkStdString.h" - -#include "vtkShaderProgram2.h" -#include "vtkShader2.h" -#include "vtkUniformVariables.h" -#include "vtkShader2Collection.h" -#include "vtkOpenGLRenderWindow.h" -#include "vtkOpenGLError.h" - -#if defined(__APPLE__) -#include -#endif - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -class vtkUnsupportedRequiredExtensionsStringStream -{ -public: - std::ostringstream Stream; - vtkUnsupportedRequiredExtensionsStringStream() - { - } -private: - // undefined copy constructor. - vtkUnsupportedRequiredExtensionsStringStream(const - vtkUnsupportedRequiredExtensionsStringStream &other); - // undefined assignment operator. - vtkUnsupportedRequiredExtensionsStringStream &operator=(const - vtkUnsupportedRequiredExtensionsStringStream &other); -}; - -class vtkMapDataArrayTextureId -{ -public: - std::map Map; - vtkMapDataArrayTextureId() - { - } -private: - // undefined copy constructor. - vtkMapDataArrayTextureId(const vtkMapDataArrayTextureId &other); - // undefined assignment operator. - vtkMapDataArrayTextureId &operator=(const vtkMapDataArrayTextureId &other); -}; - -class vtkMapMaskTextureId -{ -public: - std::map Map; - vtkMapMaskTextureId() - { - } -private: - // undefined copy constructor. - vtkMapMaskTextureId(const vtkMapMaskTextureId &other); - // undefined assignment operator. - vtkMapMaskTextureId &operator=(const vtkMapMaskTextureId &other); -}; - -//----------------------------------------------------------------------------- -extern const char *vtkGPUVolumeRayCastMapper_CompositeFS; -extern const char *vtkGPUVolumeRayCastMapper_CompositeCroppingFS; -extern const char *vtkGPUVolumeRayCastMapper_CompositeNoCroppingFS; -extern const char *vtkGPUVolumeRayCastMapper_HeaderFS; -extern const char *vtkGPUVolumeRayCastMapper_MIPFS; -extern const char *vtkGPUVolumeRayCastMapper_MIPBinaryMaskFS; -extern const char *vtkGPUVolumeRayCastMapper_MIPFourDependentFS; -extern const char *vtkGPUVolumeRayCastMapper_MIPFourDependentCroppingFS; -extern const char *vtkGPUVolumeRayCastMapper_MIPFourDependentNoCroppingFS; -extern const char *vtkGPUVolumeRayCastMapper_MIPCroppingFS; -extern const char *vtkGPUVolumeRayCastMapper_MIPNoCroppingFS; -extern const char *vtkGPUVolumeRayCastMapper_ParallelProjectionFS; -extern const char *vtkGPUVolumeRayCastMapper_PerspectiveProjectionFS; -extern const char *vtkGPUVolumeRayCastMapper_ScaleBiasFS; -extern const char *vtkGPUVolumeRayCastMapper_MinIPFS; -extern const char *vtkGPUVolumeRayCastMapper_MinIPBinaryMaskFS; -extern const char *vtkGPUVolumeRayCastMapper_MinIPFourDependentFS; -extern const char *vtkGPUVolumeRayCastMapper_MinIPFourDependentCroppingFS; -extern const char *vtkGPUVolumeRayCastMapper_MinIPFourDependentNoCroppingFS; -extern const char *vtkGPUVolumeRayCastMapper_MinIPCroppingFS; -extern const char *vtkGPUVolumeRayCastMapper_MinIPNoCroppingFS; -extern const char *vtkGPUVolumeRayCastMapper_CompositeMaskFS; -extern const char *vtkGPUVolumeRayCastMapper_CompositeBinaryMaskFS; -extern const char *vtkGPUVolumeRayCastMapper_NoShadeFS; -extern const char *vtkGPUVolumeRayCastMapper_ShadeFS; -extern const char *vtkGPUVolumeRayCastMapper_OneComponentFS; -extern const char *vtkGPUVolumeRayCastMapper_FourComponentsFS; -extern const char *vtkGPUVolumeRayCastMapper_AdditiveFS; -extern const char *vtkGPUVolumeRayCastMapper_AdditiveCroppingFS; -extern const char *vtkGPUVolumeRayCastMapper_AdditiveNoCroppingFS; - -enum -{ - vtkOpenGLGPUVolumeRayCastMapperProjectionNotInitialized=-1, // not init - vtkOpenGLGPUVolumeRayCastMapperProjectionPerspective=0, // false - vtkOpenGLGPUVolumeRayCastMapperProjectionParallel=1 // true -}; - -enum -{ - vtkOpenGLGPUVolumeRayCastMapperMethodNotInitialized, - vtkOpenGLGPUVolumeRayCastMapperMethodMIP, - vtkOpenGLGPUVolumeRayCastMapperMethodMIPBinaryMask, - vtkOpenGLGPUVolumeRayCastMapperMethodMIPFourDependent, - vtkOpenGLGPUVolumeRayCastMapperMethodComposite, - vtkOpenGLGPUVolumeRayCastMapperMethodMinIP, - vtkOpenGLGPUVolumeRayCastMapperMethodMinIPBinaryMask, - vtkOpenGLGPUVolumeRayCastMapperMethodMinIPFourDependent, - vtkOpenGLGPUVolumeRayCastMapperMethodCompositeMask, - vtkOpenGLGPUVolumeRayCastMapperMethodCompositeBinaryMask, - vtkOpenGLGPUVolumeRayCastMapperMethodAdditive -}; - -// component implementation -enum -{ - vtkOpenGLGPUVolumeRayCastMapperComponentNotInitialized=-1, // not init - vtkOpenGLGPUVolumeRayCastMapperComponentOne=0, // false - vtkOpenGLGPUVolumeRayCastMapperComponentFour=1, // true - vtkOpenGLGPUVolumeRayCastMapperComponentNotUsed=2 // when not composite -}; - -// Shade implementation -enum -{ - vtkOpenGLGPUVolumeRayCastMapperShadeNotInitialized=-1, // not init - vtkOpenGLGPUVolumeRayCastMapperShadeNo=0, // false - vtkOpenGLGPUVolumeRayCastMapperShadeYes=1, // true - vtkOpenGLGPUVolumeRayCastMapperShadeNotUsed=2 // when not composite -}; - - -// Cropping implementation -enum -{ - vtkOpenGLGPUVolumeRayCastMapperCroppingNotInitialized, - vtkOpenGLGPUVolumeRayCastMapperCompositeCropping, - vtkOpenGLGPUVolumeRayCastMapperCompositeNoCropping, - vtkOpenGLGPUVolumeRayCastMapperMIPCropping, - vtkOpenGLGPUVolumeRayCastMapperMIPNoCropping, - vtkOpenGLGPUVolumeRayCastMapperMIPFourDependentCropping, - vtkOpenGLGPUVolumeRayCastMapperMIPFourDependentNoCropping, - vtkOpenGLGPUVolumeRayCastMapperMinIPCropping, - vtkOpenGLGPUVolumeRayCastMapperMinIPNoCropping, - vtkOpenGLGPUVolumeRayCastMapperMinIPFourDependentCropping, - vtkOpenGLGPUVolumeRayCastMapperMinIPFourDependentNoCropping, - vtkOpenGLGPUVolumeRayCastMapperAdditiveCropping, - vtkOpenGLGPUVolumeRayCastMapperAdditiveNoCropping -}; - -enum -{ - vtkOpenGLGPUVolumeRayCastMapperTextureObjectDepthMap=0, // 2d texture - vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront // 2d texture -}; - -const int vtkOpenGLGPUVolumeRayCastMapperNumberOfTextureObjects=vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+2; - -const int vtkOpenGLGPUVolumeRayCastMapperOpacityTableSize=1024; //power of two - -vtkStandardNewMacro(vtkOpenGLGPUVolumeRayCastMapper); - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -class vtkTextureTable : public vtkObject -{ -public: - bool IsLoaded()const - { - return this->Loaded; - } - - void Bind() - { - assert("pre: uptodate" && this->Loaded); - glBindTexture(GL_TEXTURE_1D,this->TextureId); - } - int ComputeTableSize(vtkPiecewiseFunction* function) - { - int const idealW = function->EstimateMinNumberOfSamples(this->LastRange[0], - this->LastRange[1]); - - return this->ComputeTableSize(idealW); - } - int ComputeTableSize(vtkColorTransferFunction* function) - { - int const idealW = function->EstimateMinNumberOfSamples(this->LastRange[0], - this->LastRange[1]); - - return this->ComputeTableSize(idealW); - } - int ComputeTableSize(vtkLookupTable* function) - { - return this->ComputeTableSize(function->GetNumberOfTableValues()); - } - -protected: - vtkTextureTable() - { - this->TextureId=0; - this->Table=0; - this->Loaded=false; - this->LastLinearInterpolation=false; - this->LastRange[0] = this->LastRange[1] = 0.0; - } - ~vtkTextureTable() VTK_OVERRIDE - { - if(this->TextureId!=0) - { - glDeleteTextures(1,&this->TextureId); - vtkOpenGLStaticCheckErrorMacro("failed at glDeleteTextures"); - this->TextureId=0; - } - delete[] this->Table; - this->Table = 0; - } - - GLuint TextureId; - vtkTimeStamp BuildTime; - float *Table; - bool Loaded; - bool LastLinearInterpolation; - double LastRange[2]; - -private: - vtkTextureTable(const vtkTextureTable&) VTK_DELETE_FUNCTION; - vtkTextureTable& operator=(const vtkTextureTable&) VTK_DELETE_FUNCTION; - - // Description: - // Queries the GL_MAX_TEXTURE_SIZE and returns either the requested idealWidth - // or the maximum supported. - // Warning: This method assumes there is an active GL context. - int ComputeTableSize(int idealWidth) - { - idealWidth = vtkMath::NearestPowerOfTwo(idealWidth); - GLint maxWidth = -1; - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxWidth); - if (maxWidth < 0) - { - vtkErrorMacro("Failed to query max texture size! using default " - << vtkOpenGLGPUVolumeRayCastMapperOpacityTableSize); - return vtkOpenGLGPUVolumeRayCastMapperOpacityTableSize; - } - - if (maxWidth >= idealWidth) - { - idealWidth = vtkMath::Max(vtkOpenGLGPUVolumeRayCastMapperOpacityTableSize, - idealWidth); - - return idealWidth; - } - - vtkWarningMacro("This OpenGL implementation does not support the required " - "texture size of " << idealWidth << ", falling back to maximum allowed, " - << maxWidth << "." << "This may cause an incorrect color table mapping."); - - return maxWidth; - } -}; - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -class vtkOpacityTable: public vtkTextureTable -{ -public: - static vtkOpacityTable* New(); - vtkTypeMacro(vtkOpacityTable, vtkTextureTable); - - // \pre the active texture is set to TEXTURE2 - void Update(vtkPiecewiseFunction *scalarOpacity, - int blendMode, - double sampleDistance, - double range[2], - double unitDistance, - bool linearInterpolation) - { - assert("pre: scalarOpacity_exists" && scalarOpacity!=0); - vtkOpenGLClearErrorMacro(); - - bool needUpdate=false; - if(this->TextureId==0) - { - glGenTextures(1,&this->TextureId); - needUpdate=true; - } - if (this->LastRange[0] != range[0] || - this->LastRange[1] != range[1]) - { - needUpdate = true; - this->LastRange[0] = range[0]; - this->LastRange[1] = range[1]; - } - glBindTexture(GL_TEXTURE_1D,this->TextureId); - if(needUpdate) - { - glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, - vtkgl::CLAMP_TO_EDGE); - } - - if(scalarOpacity->GetMTime() > this->BuildTime || - (this->LastBlendMode!=blendMode) - || (blendMode==vtkVolumeMapper::COMPOSITE_BLEND && - this->LastSampleDistance!=sampleDistance) - || needUpdate || !this->Loaded) - { - this->Loaded=false; - const int tableSize = this->ComputeTableSize(scalarOpacity); - delete[] this->Table; - this->Table = new float[tableSize]; - - scalarOpacity->GetTable(range[0],range[1],tableSize,this->Table); - - this->LastBlendMode=blendMode; - - // Correct the opacity array for the spacing between the planes if we - // are using a composite blending operation - if(blendMode==vtkVolumeMapper::COMPOSITE_BLEND) - { - float *ptr=this->Table; - double factor=sampleDistance/unitDistance; - int i=0; - while(i0.0001f) - { - *ptr=static_cast(1.0-pow(1.0-static_cast(*ptr), - factor)); - } - ++ptr; - ++i; - } - this->LastSampleDistance=sampleDistance; - } - else if (blendMode==vtkVolumeMapper::ADDITIVE_BLEND) - { - float *ptr=this->Table; - double factor=sampleDistance/unitDistance; - int i=0; - while(i0.0001f) - { - *ptr=static_cast(static_cast(*ptr)*factor); - } - ++ptr; - ++i; - } - this->LastSampleDistance=sampleDistance; - } - - glTexImage1D(GL_TEXTURE_1D,0,GL_ALPHA16, - tableSize,0, - GL_ALPHA,GL_FLOAT,this->Table); - vtkOpenGLStaticCheckErrorMacro("1d opacity texture is too large"); - this->Loaded=true; - this->BuildTime.Modified(); - } - - needUpdate=needUpdate || - this->LastLinearInterpolation!=linearInterpolation; - if(needUpdate) - { - this->LastLinearInterpolation=linearInterpolation; - GLint value; - if(linearInterpolation) - { - value=GL_LINEAR; - } - else - { - value=GL_NEAREST; - } - glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MIN_FILTER,value); - glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MAG_FILTER,value); - } - vtkOpenGLStaticCheckErrorMacro("failed after Update"); - } -protected: - vtkOpacityTable() - { - this->LastBlendMode=vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND; - this->LastSampleDistance=1.0; - } - - ~vtkOpacityTable() VTK_OVERRIDE {}; - - int LastBlendMode; - double LastSampleDistance; -private: - vtkOpacityTable(const vtkOpacityTable&) VTK_DELETE_FUNCTION; - vtkOpacityTable& operator=(const vtkOpacityTable&) VTK_DELETE_FUNCTION; -}; - -vtkStandardNewMacro(vtkOpacityTable); -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -class vtkOpacityTables -{ -public: - vtkOpacityTables(unsigned int numberOfTables) - { - this->Tables.reserve(static_cast(numberOfTables)); - for (unsigned int i = 0; i < numberOfTables; i++) - { - this->Tables.push_back(vtkOpacityTable::New()); - } - } - ~vtkOpacityTables() - { - size_t const size = this->Tables.size(); - for (size_t i = 0; i < size; i++) - { - this->Tables[i]->Delete(); - } - } - vtkOpacityTable* GetTable(size_t const i) - { - return this->Tables[i]; - } - size_t GetNumberOfTables() - { - return this->Tables.size(); - } -private: - vtkOpacityTables() VTK_DELETE_FUNCTION; - vtkOpacityTables(const vtkOpacityTables &other) VTK_DELETE_FUNCTION; - vtkOpacityTables &operator=(const vtkOpacityTables &other) VTK_DELETE_FUNCTION; - - std::vector Tables; -}; - -//----------------------------------------------------------------------------- -class vtkRGBTable: public vtkTextureTable -{ -public: - static vtkRGBTable* New(); - - // \pre the active texture is set properly. (default color, - // mask1, mask2,..) - void Update(vtkColorTransferFunction *scalarRGB, - double range[2], - bool linearInterpolation) - { - assert("pre: scalarRGB_exists" && scalarRGB!=0); - vtkOpenGLClearErrorMacro(); - - bool needUpdate=false; - if(this->TextureId==0) - { - glGenTextures(1,&this->TextureId); - needUpdate=true; - } - if (range[0] != this->LastRange[0] || range[1] != this->LastRange[1]) - { - needUpdate=true; - this->LastRange[0] = range[0]; - this->LastRange[1] = range[1]; - } - glBindTexture(GL_TEXTURE_1D,this->TextureId); - if(needUpdate) - { - glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, - vtkgl::CLAMP_TO_EDGE); - } - if(scalarRGB->GetMTime() > this->BuildTime - || needUpdate || !this->Loaded) - { - this->Loaded=false; - const int tableSize = this->ComputeTableSize(scalarRGB); - delete[] this->Table; - this->Table = new float[tableSize * 3]; - - scalarRGB->GetTable(range[0],range[1], - tableSize, - this->Table); - - glTexImage1D(GL_TEXTURE_1D,0,GL_RGB16, - tableSize,0, - GL_RGB,GL_FLOAT,this->Table); - vtkOpenGLStaticCheckErrorMacro("1d RGB texture is too large"); - this->Loaded=true; - this->BuildTime.Modified(); - } - - needUpdate=needUpdate || - this->LastLinearInterpolation!=linearInterpolation; - if(needUpdate) - { - this->LastLinearInterpolation=linearInterpolation; - GLint value; - if(linearInterpolation) - { - value=GL_LINEAR; - } - else - { - value=GL_NEAREST; - } - glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MIN_FILTER,value); - glTexParameteri(GL_TEXTURE_1D,GL_TEXTURE_MAG_FILTER,value); - } - vtkOpenGLStaticCheckErrorMacro("failed after Update"); - } - -protected: - vtkRGBTable() {}; - ~vtkRGBTable() VTK_OVERRIDE {}; - -private: - vtkRGBTable(const vtkRGBTable &other) VTK_DELETE_FUNCTION; - vtkRGBTable &operator=(const vtkRGBTable &other) VTK_DELETE_FUNCTION; -}; - -vtkStandardNewMacro(vtkRGBTable); -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -class vtkKWScalarField -{ -public: - vtkKWScalarField() - { - this->TextureId=0; - this->Loaded=false; - this->Supports_GL_ARB_texture_float=false; - this->LoadedTableRange[0]=0.0; - this->LoadedTableRange[1]=1.0; - this->LoadedExtent[0]=VTK_INT_MAX; - this->LoadedExtent[1]=VTK_INT_MIN; - this->LoadedExtent[2]=VTK_INT_MAX; - this->LoadedExtent[3]=VTK_INT_MIN; - this->LoadedExtent[4]=VTK_INT_MAX; - this->LoadedExtent[5]=VTK_INT_MIN; - } - ~vtkKWScalarField() - { - if(this->TextureId!=0) - { - glDeleteTextures(1,&this->TextureId); - vtkOpenGLStaticCheckErrorMacro("failed at glDeleteTextures"); - this->TextureId=0; - } - } - - vtkTimeStamp GetBuildTime() - { - return this->BuildTime; - } - - void Bind() - { - assert("pre: uptodate" && this->Loaded); - glBindTexture(vtkgl::TEXTURE_3D,this->TextureId); - vtkOpenGLStaticCheckErrorMacro("failed at glBindTexture"); - } - - void Update(vtkImageData *input, - int cellFlag, - int textureExtent[6], - int scalarMode, - int arrayAccessMode, - int arrayId, - const char *arrayName, - bool linearInterpolation, - double tableRange[2], - vtkIdType maxMemoryInBytes) - { - vtkOpenGLClearErrorMacro(); - - bool needUpdate=false; - bool modified=false; - if(this->TextureId==0) - { - glGenTextures(1,&this->TextureId); - needUpdate=true; - } - glBindTexture(vtkgl::TEXTURE_3D,this->TextureId); - - int obsolete=needUpdate || !this->Loaded || input->GetMTime()>this->BuildTime; - if(!obsolete) - { - obsolete=cellFlag!=this->LoadedCellFlag; - int i=0; - while(!obsolete && i<6) - { - obsolete=obsolete || this->LoadedExtent[i]>textureExtent[i]; - ++i; - obsolete=obsolete || this->LoadedExtent[i]LoadedTableRange[0]!=tableRange[0] || - this->LoadedTableRange[1]!=tableRange[1]; - } - - if(obsolete) - { - this->Loaded=false; - int dim[3]; - input->GetDimensions(dim); - - GLint internalFormat=0; - GLenum format=0; - GLenum type=0; - // shift then scale: y:=(x+shift)*scale - double shift=0.0; - double scale=1.0; - int needTypeConversion=0; - vtkDataArray *sliceArray=0; - - vtkDataArray *scalars= - vtkAbstractMapper::GetScalars(input,scalarMode,arrayAccessMode, - arrayId,arrayName, - this->LoadedCellFlag); - - // DON'T USE GetScalarType() or GetNumberOfScalarComponents() on - // ImageData as it deals only with point data... - - int scalarType=scalars->GetDataType(); - if(scalars->GetNumberOfComponents()==4) - { - // this is RGBA, unsigned char only - internalFormat=GL_RGBA16; - format=GL_RGBA; - type=GL_UNSIGNED_BYTE; - } - else - { - // input->GetNumberOfScalarComponents()==1 - switch(scalarType) - { - case VTK_FLOAT: - if(this->Supports_GL_ARB_texture_float) - { - internalFormat=vtkgl::INTENSITY16F_ARB; - } - else - { - internalFormat=GL_INTENSITY16; - } - format=GL_RED; - type=GL_FLOAT; - shift=-tableRange[0]; - scale=1/(tableRange[1]-tableRange[0]); - break; - case VTK_UNSIGNED_CHAR: - internalFormat=GL_INTENSITY8; - format=GL_RED; - type=GL_UNSIGNED_BYTE; - shift=-tableRange[0]/VTK_UNSIGNED_CHAR_MAX; - scale= - VTK_UNSIGNED_CHAR_MAX/(tableRange[1]-tableRange[0]); - break; - case VTK_SIGNED_CHAR: - internalFormat=GL_INTENSITY8; - format=GL_RED; - type=GL_BYTE; - shift=-(2*tableRange[0]+1)/VTK_UNSIGNED_CHAR_MAX; - scale=VTK_SIGNED_CHAR_MAX/(tableRange[1]-tableRange[0]); - break; - case VTK_CHAR: - // not supported - assert("check: impossible case" && 0); - break; - case VTK_BIT: - // not supported - assert("check: impossible case" && 0); - break; - case VTK_ID_TYPE: - // not supported - assert("check: impossible case" && 0); - break; - case VTK_INT: - internalFormat=GL_INTENSITY16; - format=GL_RED; - type=GL_INT; - - shift=-(2*tableRange[0]+1)/VTK_UNSIGNED_INT_MAX; - scale=VTK_INT_MAX/(tableRange[1]-tableRange[0]); - break; - case VTK_DOUBLE: -#if !defined(VTK_LEGACY_REMOVE) - case VTK___INT64: - case VTK_UNSIGNED___INT64: -#endif - case VTK_LONG: - case VTK_LONG_LONG: - case VTK_UNSIGNED_LONG: - case VTK_UNSIGNED_LONG_LONG: - needTypeConversion=1; // to float - if(this->Supports_GL_ARB_texture_float) - { - internalFormat=vtkgl::INTENSITY16F_ARB; - } - else - { - internalFormat=GL_INTENSITY16; - } - format=GL_RED; - type=GL_FLOAT; - shift=-tableRange[0]; - scale=1/(tableRange[1]-tableRange[0]); - sliceArray=vtkFloatArray::New(); - break; - case VTK_SHORT: - internalFormat=GL_INTENSITY16; - format=GL_RED; - type=GL_SHORT; - - shift=-(2*tableRange[0]+1)/VTK_UNSIGNED_SHORT_MAX; - scale=VTK_SHORT_MAX/(tableRange[1]-tableRange[0]); - break; - case VTK_STRING: - // not supported - assert("check: impossible case" && 0); - break; - case VTK_UNSIGNED_SHORT: - internalFormat=GL_INTENSITY16; - format=GL_RED; - type=GL_UNSIGNED_SHORT; - - shift=-tableRange[0]/VTK_UNSIGNED_SHORT_MAX; - scale= - VTK_UNSIGNED_SHORT_MAX/(tableRange[1]-tableRange[0]); - break; - case VTK_UNSIGNED_INT: - internalFormat=GL_INTENSITY16; - format=GL_RED; - type=GL_UNSIGNED_INT; - - shift=-tableRange[0]/VTK_UNSIGNED_INT_MAX; - scale=VTK_UNSIGNED_INT_MAX/(tableRange[1]-tableRange[0]); - break; - default: - assert("check: impossible case" && 0); - break; - } - } - - // Enough memory? - int textureSize[3]; - int i=0; - while(i<3) - { - textureSize[i]=textureExtent[2*i+1]-textureExtent[2*i]+1; - ++i; - } - - GLint width; - glGetIntegerv(vtkgl::MAX_3D_TEXTURE_SIZE,&width); - this->Loaded=textureSize[0]<=width && textureSize[1]<=width - && textureSize[2]<=width; - if(this->Loaded) - { - // so far, so good. the texture size is theorically small enough - // for OpenGL - - vtkgl::TexImage3D(vtkgl::PROXY_TEXTURE_3D,0,internalFormat, - textureSize[0],textureSize[1],textureSize[2],0, - format,type,0); - glGetTexLevelParameteriv(vtkgl::PROXY_TEXTURE_3D,0,GL_TEXTURE_WIDTH, - &width); - - this->Loaded=width!=0; - if(this->Loaded) - { - // so far, so good but some cards always succeed with a proxy texture - // let's try to actually allocate.. - - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,internalFormat,textureSize[0], - textureSize[1],textureSize[2],0,format,type,0); - GLenum errorCode=glGetError(); - this->Loaded=errorCode!=GL_OUT_OF_MEMORY; - if(this->Loaded) - { - // so far, so good, actual allocation succeeded. - if(errorCode!=GL_NO_ERROR) - { - cout<<"after try to load the texture"; - cout<<" ERROR (x"<(errorCode)); - cout<Loaded=textureSize[0]*textureSize[1]* - textureSize[2]*vtkAbstractArray::GetDataTypeSize(scalarType)* - scalars->GetNumberOfComponents()<=maxMemoryInBytes; - if(this->Loaded) - { - // OK, we consider the allocation above succeeded... - // If it actually didn't the only to fix it for the user - // is to decrease the value of this->MaxMemoryInBytes. - - // enough memory! We can load the scalars! - - double bias=shift*scale; - - // we don't clamp to edge because for the computation of the - // gradient on the border we need some external value. - glTexParameterf(vtkgl::TEXTURE_3D,vtkgl::TEXTURE_WRAP_R,vtkgl::CLAMP_TO_EDGE); - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_WRAP_S,vtkgl::CLAMP_TO_EDGE); - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_WRAP_T,vtkgl::CLAMP_TO_EDGE); - - GLfloat borderColor[4]={0.0,0.0,0.0,0.0}; - - glTexParameterfv(vtkgl::TEXTURE_3D,GL_TEXTURE_BORDER_COLOR, borderColor); - - if(needTypeConversion) - { - // Convert and send to the GPU, z-slice by z-slice. - // Allocate memory on the GPU (NULL data pointer with the right - // dimensions) - // Here we are assuming that GL_ARB_texture_non_power_of_two is - // available - glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); - - // memory allocation is already done. - - // Send the slices: - // allocate CPU memory for a slice. - sliceArray->SetNumberOfComponents(1); // FB TODO CHECK THAT - sliceArray->SetNumberOfTuples(textureSize[0]*textureSize[1]); - - void *slicePtr=sliceArray->GetVoidPointer(0); - int k=0; - int kInc=(dim[0]-cellFlag)*(dim[1]-cellFlag); - int kOffset=(textureExtent[4]*(dim[1]-cellFlag) - +textureExtent[2])*(dim[0]-cellFlag) - +textureExtent[0]; - while(kSetTuple1(jDestOffset+i, - (scalars->GetTuple1(kOffset+jOffset - +i) - +shift)*scale); - ++i; - } - ++j; - jOffset+=dim[0]-cellFlag; - jDestOffset+=textureSize[0]; - } - - // Here we are assuming that GL_ARB_texture_non_power_of_two is - // available - vtkgl::TexSubImage3D(vtkgl::TEXTURE_3D, 0, - 0,0,k, - textureSize[0],textureSize[1], - 1, // depth is 1, not 0! - format,type, slicePtr); - ++k; - kOffset+=kInc; - } - sliceArray->Delete(); - } - else - { - // One chunk of data to the GPU. - // It works for the whole volume or for a subvolume. - // Here we are assuming that GL_ARB_texture_non_power_of_two is - // available - - // make sure any previous OpenGL call is executed and will not - // be disturbed by our PixelTransfer value - glFinish(); - glPixelTransferf(GL_RED_SCALE,static_cast(scale)); - glPixelTransferf(GL_RED_BIAS,static_cast(bias)); - glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); - - if(!(textureExtent[1]-textureExtent[0]+cellFlag==dim[0])) - { - glPixelStorei(GL_UNPACK_ROW_LENGTH,dim[0]-cellFlag); - } - if(!(textureExtent[3]-textureExtent[2]+cellFlag==dim[1])) - { - glPixelStorei(vtkgl::UNPACK_IMAGE_HEIGHT_EXT, - dim[1]-cellFlag); - } - void *dataPtr=scalars->GetVoidPointer( - ((textureExtent[4]*(dim[1]-cellFlag)+textureExtent[2]) - *(dim[0]-cellFlag)+textureExtent[0]) - *scalars->GetNumberOfComponents()); - - vtkgl::TexImage3D(vtkgl::TEXTURE_3D, 0, internalFormat, - textureSize[0],textureSize[1],textureSize[2], - 0,format,type,dataPtr); - vtkOpenGLStaticCheckErrorMacro("3d texture is too large2"); - // make sure TexImage3D is executed with our PixelTransfer mode - glFinish(); - // Restore the default values. - glPixelStorei(GL_UNPACK_ROW_LENGTH,0); - glPixelStorei(vtkgl::UNPACK_IMAGE_HEIGHT_EXT,0); - glPixelTransferf(GL_RED_SCALE,1.0); - glPixelTransferf(GL_RED_BIAS,0.0); - } - this->LoadedCellFlag=cellFlag; - i=0; - while(i<6) - { - this->LoadedExtent[i]=textureExtent[i]; - ++i; - } - - double spacing[3]; - double origin[3]; - input->GetSpacing(spacing); - input->GetOrigin(origin); - int swapBounds[3]; - swapBounds[0]=(spacing[0]<0); - swapBounds[1]=(spacing[1]<0); - swapBounds[2]=(spacing[2]<0); - - if(!this->LoadedCellFlag) // loaded extents represent points - { - // slabsPoints[i]=(slabsDataSet[i] - origin[i/2]) / spacing[i/2]; - // in general, x=o+i*spacing. - // if spacing is positive min extent match the min of the - // bounding box - // and the max extent match the max of the bounding box - // if spacing is negative min extent match the max of the - // bounding box - // and the max extent match the min of the bounding box - - // if spacing is negative, we may have to rethink the equation - // between real point and texture coordinate... - this->LoadedBounds[0]=origin[0]+ - static_cast(this->LoadedExtent[0+swapBounds[0]])*spacing[0]; - this->LoadedBounds[2]=origin[1]+ - static_cast(this->LoadedExtent[2+swapBounds[1]])*spacing[1]; - this->LoadedBounds[4]=origin[2]+ - static_cast(this->LoadedExtent[4+swapBounds[2]])*spacing[2]; - this->LoadedBounds[1]=origin[0]+ - static_cast(this->LoadedExtent[1-swapBounds[0]])*spacing[0]; - this->LoadedBounds[3]=origin[1]+ - static_cast(this->LoadedExtent[3-swapBounds[1]])*spacing[1]; - this->LoadedBounds[5]=origin[2]+ - static_cast(this->LoadedExtent[5-swapBounds[2]])*spacing[2]; - - } - else // loaded extents represent cells - { - int wholeTextureExtent[6]; - input->GetExtent(wholeTextureExtent); - i=1; - while(i<6) - { - wholeTextureExtent[i]--; - i+=2; - } - - i=0; - while(i<3) - { - if(this->LoadedExtent[2*i]==wholeTextureExtent[2*i]) - { - this->LoadedBounds[2*i+swapBounds[i]]=origin[i]; - } - else - { - this->LoadedBounds[2*i+swapBounds[i]]=origin[i]+ - (static_cast(this->LoadedExtent[2*i])+0.5)*spacing[i]; - } - - if(this->LoadedExtent[2*i+1]==wholeTextureExtent[2*i+1]) - { - this->LoadedBounds[2*i+1-swapBounds[i]]=origin[i]+ - (static_cast(this->LoadedExtent[2*i+1])+1.0)*spacing[i]; - } - else - { - this->LoadedBounds[2*i+1-swapBounds[i]]=origin[i]+ - (static_cast(this->LoadedExtent[2*i+1])+0.5)*spacing[i]; - } - ++i; - } - } - this->LoadedTableRange[0]=tableRange[0]; - this->LoadedTableRange[1]=tableRange[1]; - modified=true; - } // if enough memory - else - { - } - } //load fail with out of memory - else - { - } - } // proxy ok - else - { // proxy failed - } - } - else - { - // out of therical limitationa - } - } // if obsolete - - if(this->Loaded && - (needUpdate || modified || - linearInterpolation!=this->LinearInterpolation)) - { - this->LinearInterpolation=linearInterpolation; - if(this->LinearInterpolation) - { - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_MIN_FILTER, - GL_LINEAR); - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_MAG_FILTER, - GL_LINEAR); - } - else - { - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_MIN_FILTER, - GL_NEAREST ); - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_MAG_FILTER, - GL_NEAREST ); - } - modified=true; - } - if(modified) - { - this->BuildTime.Modified(); - } - vtkOpenGLStaticCheckErrorMacro("failed after Update"); - } - - double *GetLoadedBounds() - { - assert("pre: loaded" && this->Loaded); - return this->LoadedBounds; - } - - vtkIdType *GetLoadedExtent() - { - assert("pre: loaded" && this->Loaded); - return this->LoadedExtent; - } - - int GetLoadedCellFlag() - { - assert("pre: loaded" && this->Loaded); - return this->LoadedCellFlag; - } - - bool IsLoaded() - { - return this->Loaded; - } - - bool GetSupports_GL_ARB_texture_float() - { - return this->Supports_GL_ARB_texture_float; - } - - void SetSupports_GL_ARB_texture_float(bool value) - { - this->Supports_GL_ARB_texture_float=value; - } - -protected: - GLuint TextureId; - vtkTimeStamp BuildTime; - double LoadedBounds[6]; - vtkIdType LoadedExtent[6]; - int LoadedCellFlag; - bool Loaded; - bool LinearInterpolation; - bool Supports_GL_ARB_texture_float; - double LoadedTableRange[2]; -}; - - -//----------------------------------------------------------------------------- -class vtkKWMask -{ -public: - vtkKWMask() - { - this->TextureId=0; - this->Loaded=false; - this->LoadedExtent[0]=VTK_INT_MAX; - this->LoadedExtent[1]=VTK_INT_MIN; - this->LoadedExtent[2]=VTK_INT_MAX; - this->LoadedExtent[3]=VTK_INT_MIN; - this->LoadedExtent[4]=VTK_INT_MAX; - this->LoadedExtent[5]=VTK_INT_MIN; - } - ~vtkKWMask() - { - if(this->TextureId!=0) - { - glDeleteTextures(1,&this->TextureId); - vtkOpenGLStaticCheckErrorMacro("failed at glDeleteTextures"); - this->TextureId=0; - } - } - - vtkTimeStamp GetBuildTime() - { - return this->BuildTime; - } - - // \pre vtkgl::ActiveTexture(vtkgl::TEXTURE7) has to be called first. - void Bind() - { - assert("pre: uptodate" && this->Loaded); - glBindTexture(vtkgl::TEXTURE_3D,this->TextureId); - vtkOpenGLStaticCheckErrorMacro("failed at glBindTexture"); - } - - // \pre vtkgl::ActiveTexture(vtkgl::TEXTURE7) has to be called first. - void Update(vtkImageData *input, - int cellFlag, - int textureExtent[6], - int scalarMode, - int arrayAccessMode, - int arrayId, - const char *arrayName, - vtkIdType maxMemoryInBytes) - { - vtkOpenGLClearErrorMacro(); - - bool needUpdate=false; - bool modified=false; - if(this->TextureId==0) - { - glGenTextures(1,&this->TextureId); - needUpdate=true; - } - glBindTexture(vtkgl::TEXTURE_3D,this->TextureId); - - int obsolete=needUpdate || !this->Loaded - || input->GetMTime()>this->BuildTime; - if(!obsolete) - { - obsolete=cellFlag!=this->LoadedCellFlag; - int i=0; - while(!obsolete && i<6) - { - obsolete=obsolete || this->LoadedExtent[i]>textureExtent[i]; - ++i; - obsolete=obsolete || this->LoadedExtent[i]Loaded=false; - int dim[3]; - input->GetDimensions(dim); - - vtkDataArray *scalars= - vtkAbstractMapper::GetScalars(input,scalarMode,arrayAccessMode, - arrayId,arrayName, - this->LoadedCellFlag); - - // DON'T USE GetScalarType() or GetNumberOfScalarComponents() on - // ImageData as it deals only with point data... - - int scalarType=scalars->GetDataType(); - if(scalarType!=VTK_UNSIGNED_CHAR) - { - cout <<"mask should be VTK_UNSIGNED_CHAR." << endl; - } - if(scalars->GetNumberOfComponents()!=1) - { - cout <<"mask should be a one-component scalar field." << endl; - } - - GLint internalFormat=GL_ALPHA8; - GLenum format=GL_ALPHA; - GLenum type=GL_UNSIGNED_BYTE; - - // Enough memory? - int textureSize[3]; - int i=0; - while(i<3) - { - textureSize[i]=textureExtent[2*i+1]-textureExtent[2*i]+1; - ++i; - } - - GLint width; - glGetIntegerv(vtkgl::MAX_3D_TEXTURE_SIZE,&width); - this->Loaded=textureSize[0]<=width && textureSize[1]<=width - && textureSize[2]<=width; - if(this->Loaded) - { - // so far, so good. the texture size is theorically small enough - // for OpenGL - - vtkgl::TexImage3D(vtkgl::PROXY_TEXTURE_3D,0,internalFormat, - textureSize[0],textureSize[1],textureSize[2],0, - format,type,0); - glGetTexLevelParameteriv(vtkgl::PROXY_TEXTURE_3D,0,GL_TEXTURE_WIDTH, - &width); - - this->Loaded=width!=0; - if(this->Loaded) - { - // so far, so good but some cards always succeed with a proxy texture - // let's try to actually allocate.. - - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,internalFormat,textureSize[0], - textureSize[1],textureSize[2],0,format,type,0); - GLenum errorCode=glGetError(); - this->Loaded=errorCode!=GL_OUT_OF_MEMORY; - if(this->Loaded) - { - // so far, so good, actual allocation succeeded. - if(errorCode!=GL_NO_ERROR) - { - cout<<"after try to load the texture"; - cout<<" ERROR (x"<(errorCode)); - cout<Loaded=textureSize[0]*textureSize[1]* - textureSize[2]*vtkAbstractArray::GetDataTypeSize(scalarType)* - scalars->GetNumberOfComponents()<=maxMemoryInBytes; - if(this->Loaded) - { - // OK, we consider the allocation above succeeded... - // If it actually didn't the only to fix it for the user - // is to decrease the value of this->MaxMemoryInBytes. - - // enough memory! We can load the scalars! - - // we don't clamp to edge because for the computation of the - // gradient on the border we need some external value. - glTexParameterf(vtkgl::TEXTURE_3D,vtkgl::TEXTURE_WRAP_R,vtkgl::CLAMP_TO_EDGE); - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_WRAP_S,vtkgl::CLAMP_TO_EDGE); - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_WRAP_T,vtkgl::CLAMP_TO_EDGE); - - GLfloat borderColor[4]={0.0,0.0,0.0,0.0}; - - glTexParameterfv(vtkgl::TEXTURE_3D,GL_TEXTURE_BORDER_COLOR, borderColor); - - glPixelTransferf(GL_ALPHA_SCALE,1.0); - glPixelTransferf(GL_ALPHA_BIAS,0.0); - glPixelStorei(GL_UNPACK_ALIGNMENT,1); - - if(!(textureExtent[1]-textureExtent[0]+cellFlag==dim[0])) - { - glPixelStorei(GL_UNPACK_ROW_LENGTH,dim[0]-cellFlag); - } - if(!(textureExtent[3]-textureExtent[2]+cellFlag==dim[1])) - { - glPixelStorei(vtkgl::UNPACK_IMAGE_HEIGHT_EXT, - dim[1]-cellFlag); - } - void *dataPtr=scalars->GetVoidPointer( - ((textureExtent[4]*(dim[1]-cellFlag)+textureExtent[2]) - *(dim[0]-cellFlag)+textureExtent[0]) - *scalars->GetNumberOfComponents()); - - vtkgl::TexImage3D(vtkgl::TEXTURE_3D, 0, internalFormat, - textureSize[0],textureSize[1],textureSize[2], - 0,format,type,dataPtr); - - // Restore the default values. - glPixelStorei(GL_UNPACK_ROW_LENGTH,0); - glPixelStorei(vtkgl::UNPACK_IMAGE_HEIGHT_EXT,0); - glPixelTransferf(GL_ALPHA_SCALE,1.0); - glPixelTransferf(GL_ALPHA_BIAS,0.0); - - this->LoadedCellFlag=cellFlag; - i=0; - while(i<6) - { - this->LoadedExtent[i]=textureExtent[i]; - ++i; - } - - double spacing[3]; - double origin[3]; - input->GetSpacing(spacing); - input->GetOrigin(origin); - int swapBounds[3]; - swapBounds[0]=(spacing[0]<0); - swapBounds[1]=(spacing[1]<0); - swapBounds[2]=(spacing[2]<0); - - if(!this->LoadedCellFlag) // loaded extents represent points - { - // slabsPoints[i]=(slabsDataSet[i] - origin[i/2]) / spacing[i/2]; - // in general, x=o+i*spacing. - // if spacing is positive min extent match the min of the - // bounding box - // and the max extent match the max of the bounding box - // if spacing is negative min extent match the max of the - // bounding box - // and the max extent match the min of the bounding box - - // if spacing is negative, we may have to rethink the equation - // between real point and texture coordinate... - this->LoadedBounds[0]=origin[0]+ - static_cast(this->LoadedExtent[0+swapBounds[0]])*spacing[0]; - this->LoadedBounds[2]=origin[1]+ - static_cast(this->LoadedExtent[2+swapBounds[1]])*spacing[1]; - this->LoadedBounds[4]=origin[2]+ - static_cast(this->LoadedExtent[4+swapBounds[2]])*spacing[2]; - this->LoadedBounds[1]=origin[0]+ - static_cast(this->LoadedExtent[1-swapBounds[0]])*spacing[0]; - this->LoadedBounds[3]=origin[1]+ - static_cast(this->LoadedExtent[3-swapBounds[1]])*spacing[1]; - this->LoadedBounds[5]=origin[2]+ - static_cast(this->LoadedExtent[5-swapBounds[2]])*spacing[2]; - - } - else // loaded extents represent cells - { - int wholeTextureExtent[6]; - input->GetExtent(wholeTextureExtent); - i=1; - while(i<6) - { - wholeTextureExtent[i]--; - i+=2; - } - - i=0; - while(i<3) - { - if(this->LoadedExtent[2*i]==wholeTextureExtent[2*i]) - { - this->LoadedBounds[2*i+swapBounds[i]]=origin[i]; - } - else - { - this->LoadedBounds[2*i+swapBounds[i]]=origin[i]+ - (static_cast(this->LoadedExtent[2*i])+0.5)*spacing[i]; - } - - if(this->LoadedExtent[2*i+1]==wholeTextureExtent[2*i+1]) - { - this->LoadedBounds[2*i+1-swapBounds[i]]=origin[i]+ - (static_cast(this->LoadedExtent[2*i+1])+1.0)*spacing[i]; - } - else - { - this->LoadedBounds[2*i+1-swapBounds[i]]=origin[i]+ - (static_cast(this->LoadedExtent[2*i+1])+0.5)*spacing[i]; - } - ++i; - } - } - modified=true; - } // if enough memory - else - { - } - } //load fail with out of memory - else - { - } - } // proxy ok - else - { // proxy failed - } - } - else - { - // out of therical limitationa - } - } // if obsolete - - if(this->Loaded && (needUpdate || modified)) - { - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_MIN_FILTER, - GL_NEAREST ); - glTexParameterf(vtkgl::TEXTURE_3D,GL_TEXTURE_MAG_FILTER, - GL_NEAREST ); - modified=true; - } - if(modified) - { - this->BuildTime.Modified(); - } - vtkOpenGLStaticCheckErrorMacro("failed after Update"); - } - - double *GetLoadedBounds() - { - assert("pre: loaded" && this->Loaded); - return this->LoadedBounds; - } - - vtkIdType *GetLoadedExtent() - { - assert("pre: loaded" && this->Loaded); - return this->LoadedExtent; - } - - int GetLoadedCellFlag() - { - assert("pre: loaded" && this->Loaded); - return this->LoadedCellFlag; - } - - bool IsLoaded() - { - return this->Loaded; - } - -protected: - GLuint TextureId; - vtkTimeStamp BuildTime; - double LoadedBounds[6]; - vtkIdType LoadedExtent[6]; - int LoadedCellFlag; - bool Loaded; -}; - - -//----------------------------------------------------------------------------- -// Display the status of the current framebuffer on the standard output. -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::CheckFrameBufferStatus() -{ - GLenum status; - status = vtkgl::CheckFramebufferStatusEXT(vtkgl::FRAMEBUFFER_EXT); - switch(status) - { - case 0: - cout << "call to vtkgl::CheckFramebufferStatusEXT generates an error." - << endl; - break; - case vtkgl::FRAMEBUFFER_COMPLETE_EXT: - break; - case vtkgl::FRAMEBUFFER_UNSUPPORTED_EXT: - cout << "framebuffer is unsupported" << endl; - break; - case vtkgl::FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: - cout << "framebuffer has an attachment error"<(buffer); - switch(b) - { - case GL_NONE: - ost << "GL_NONE"; - break; - case GL_FRONT_LEFT: - ost << "GL_FRONT_LEFT"; - break; - case GL_FRONT_RIGHT: - ost << "GL_FRONT_RIGHT"; - break; - case GL_BACK_LEFT: - ost << "GL_BACK_LEFT"; - break; - case GL_BACK_RIGHT: - ost << "GL_BACK_RIGHT"; - break; - case GL_FRONT: - ost << "GL_FRONT"; - break; - case GL_BACK: - ost << "GL_BACK"; - break; - case GL_LEFT: - ost << "GL_LEFT"; - break; - case GL_RIGHT: - ost << "GL_RIGHT"; - break; - case GL_FRONT_AND_BACK: - ost << "GL_FRONT_AND_BACK"; - break; - default: - glGetIntegerv(GL_AUX_BUFFERS,&size); - if(buffer>=GL_AUX0 && buffer<(GL_AUX0+size)) - { - ost << "GL_AUX" << (buffer-GL_AUX0); - } - else - { - glGetIntegerv(vtkgl::MAX_COLOR_ATTACHMENTS_EXT,&size); - if(static_cast(buffer)>=vtkgl::COLOR_ATTACHMENT0_EXT && - static_cast(buffer)< - (vtkgl::COLOR_ATTACHMENT0_EXT+static_cast(size))) - { - ost << "GL_COLOR_ATTACHMENT" - << (static_cast(buffer)-vtkgl::COLOR_ATTACHMENT0_EXT) - << "_EXT"; - } - else - { - ost << "unknown color buffer type=0x"<(value); - - vtkStdString s; - GLenum i=0; - while(iBufferToString(static_cast(value)); - cout << "draw buffer " << i << "=" << s << endl; - ++i; - } - - glGetIntegerv(GL_READ_BUFFER,&value); - s=this->BufferToString(static_cast(value)); - cout << "read buffer=" << s << endl; -} - -// ---------------------------------------------------------------------------- -// Description: -// Display all the attachments of the current framebuffer object. -// ---------------------------------------------------------------------------- -// -// ---------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::DisplayFrameBufferAttachments() -{ - GLint framebufferBinding; - glGetIntegerv(vtkgl::FRAMEBUFFER_BINDING_EXT,&framebufferBinding); - this->PrintError("after getting FRAMEBUFFER_BINDING_EXT"); - if(framebufferBinding==0) - { - cout<<"Current framebuffer is bind to the system one"<(value); - this->PrintError("after getting MAX_COLOR_ATTACHMENTS_EXT"); - GLenum i=0; - while(iDisplayFrameBufferAttachment(vtkgl::COLOR_ATTACHMENT0_EXT+i); - ++i; - } - cout<<"depth attachement :"<DisplayFrameBufferAttachment(vtkgl::DEPTH_ATTACHMENT_EXT); - cout<<"stencil attachement :"<DisplayFrameBufferAttachment(vtkgl::STENCIL_ATTACHMENT_EXT); - } -} - -// ---------------------------------------------------------------------------- -// Description: -// Display a given attachment for the current framebuffer object. -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::DisplayFrameBufferAttachment( - unsigned int uattachment) -{ - GLenum attachment=static_cast(uattachment); - - GLint params; - vtkgl::GetFramebufferAttachmentParameterivEXT( - vtkgl::FRAMEBUFFER_EXT,attachment, - vtkgl::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT,¶ms); - - this->PrintError("after getting FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT"); - switch(params) - { - case GL_NONE: - cout<<" this attachment is empty"<PrintError("after getting FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT"); - cout<<" this attachment is a texture with name: "<PrintError( - "after getting FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT"); - cout<<" its mipmap level is: "<PrintError( - "after getting FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT"); - if(params==0) - { - cout<<" this is not a cube map texture."<PrintError( - "after getting FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT"); - if(params==0) - { - cout<<" this is not 3D texture."<PrintError("after getting FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT"); - cout<<" this attachment is a renderbuffer with name: "<(params)); - this->PrintError( - "after getting binding the current RENDERBUFFER_EXT to params"); - - vtkgl::GetRenderbufferParameterivEXT(vtkgl::RENDERBUFFER_EXT, - vtkgl::RENDERBUFFER_WIDTH_EXT, - ¶ms); - this->PrintError("after getting RENDERBUFFER_WIDTH_EXT"); - cout<<" renderbuffer width="<PrintError("after getting RENDERBUFFER_HEIGHT_EXT"); - cout<<" renderbuffer height="<PrintError("after getting RENDERBUFFER_INTERNAL_FORMAT_EXT"); - - cout<<" renderbuffer internal format=0x"<< hex<PrintError("after getting RENDERBUFFER_RED_SIZE_EXT"); - cout<<" renderbuffer actual resolution for the red component="<PrintError("after getting RENDERBUFFER_GREEN_SIZE_EXT"); - cout<<" renderbuffer actual resolution for the green component="<PrintError("after getting RENDERBUFFER_BLUE_SIZE_EXT"); - cout<<" renderbuffer actual resolution for the blue component="<PrintError("after getting RENDERBUFFER_ALPHA_SIZE_EXT"); - cout<<" renderbuffer actual resolution for the alpha component="<PrintError("after getting RENDERBUFFER_DEPTH_SIZE_EXT"); - cout<<" renderbuffer actual resolution for the depth component="<PrintError("after getting RENDERBUFFER_STENCIL_SIZE_EXT"); - cout<<" renderbuffer actual resolution for the stencil component=" - <(errorCode)) - { - case GL_NO_ERROR: - result="No error"; - break; - case GL_INVALID_ENUM: - result="Invalid enum"; - break; - case GL_INVALID_VALUE: - result="Invalid value"; - break; - case GL_INVALID_OPERATION: - result="Invalid operation"; - break; - case GL_STACK_OVERFLOW: - result="stack overflow"; - break; - case GL_STACK_UNDERFLOW: - result="stack underflow"; - break; - case GL_OUT_OF_MEMORY: - result="out of memory"; - break; - case vtkgl::TABLE_TOO_LARGE: - // GL_ARB_imaging - result="Table too large"; - break; - case vtkgl::INVALID_FRAMEBUFFER_OPERATION_EXT: - // GL_EXT_framebuffer_object, 310 - result="invalid framebuffer operation ext"; - break; - case vtkgl::TEXTURE_TOO_LARGE_EXT: - // GL_EXT_texture - result="Texture too large"; - break; - default: - result="unknown error"; - } - assert("post: result_exists" && result!=0); - return result; -} - -//----------------------------------------------------------------------------- -// Display headerMessage on the standard output and the last OpenGL error -// message if any. -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::PrintError(const char *headerMessage) -{ - GLenum errorCode=glGetError(); - if(errorCode!=GL_NO_ERROR) - { - if ( headerMessage ) - { - cout<(errorCode)); - cout<UnsupportedRequiredExtensions=0; - this->OpenGLObjectsCreated=0; - this->LoadExtensionsSucceeded=0; - this->NumberOfFrameBuffers=0; - - // up to 2 frame buffer 2D textures (left/right) - // 1 dataset 3D texture - // 1 colormap 1D texture - // 1 opacitymap 1d texture - // 1 grabbed depth buffer 2d texture - int i=0; - while(iTextureObjects[i]=0; - ++i; - } - - this->DepthRenderBufferObject=0; - this->FrameBufferObject=0; - - for ( int j = 0; j < 8; j++ ) - { - for (i = 0; i < 3; i++ ) - { - this->BoundingBox[j][i] = 0.0; - } - } - - this->LastSize[0]=0; - this->LastSize[1]=0; - - this->ReductionFactor = 1.0; - - this->Supports_GL_ARB_texture_float=0; - this->SupportsPixelBufferObjects=0; - - i=0; - while(i<3) - { - this->TempMatrix[i]=vtkMatrix4x4::New(); - ++i; - } - - this->ErrorLine=0; - this->ErrorColumn=0; - this->ErrorString=0; - - this->LastParallelProjection= - vtkOpenGLGPUVolumeRayCastMapperProjectionNotInitialized; - this->LastRayCastMethod= - vtkOpenGLGPUVolumeRayCastMapperMethodNotInitialized; - this->LastCroppingMode= - vtkOpenGLGPUVolumeRayCastMapperCroppingNotInitialized; - this->LastComponent= - vtkOpenGLGPUVolumeRayCastMapperComponentNotInitialized; - this->LastShade=vtkOpenGLGPUVolumeRayCastMapperShadeNotInitialized; - - this->ClippedBoundingBox = NULL; - - this->SmallInput = NULL; - - this->MaxValueFrameBuffer=0; - this->MaxValueFrameBuffer2=0; - this->ReducedSize[0]=0; - this->ReducedSize[1]=0; - - this->NumberOfCroppingRegions=0; - - this->PolyDataBoundingBox=0; - this->Planes=0; - this->NearPlane=0; - this->Clip=0; - this->Densify=0; - this->InvVolumeMatrix=vtkMatrix4x4::New(); - - this->SavedFrameBuffer=0; - - this->BoxSource=0; - - this->NoiseTexture=0; - this->NoiseTextureSize=0; - this->NoiseTextureId=0; - - this->IgnoreSampleDistancePerPixel=true; - - this->ScalarsTextures=new vtkMapDataArrayTextureId; - this->MaskTextures=new vtkMapMaskTextureId; - - this->RGBTable=0; - this->Mask1RGBTable=0; - this->Mask2RGBTable=0; - this->OpacityTables=0; - - this->CurrentScalar=0; - this->CurrentMask=0; - - this->ActualSampleDistance=1.0; - this->LastProgressEventTime=0.0; // date in seconds - - this->PreserveOrientation=true; - - this->Program=0; - this->Main=0; - this->Projection=0; - this->Trace=0; - this->CroppingShader=0; - this->Component=0; - this->Shade=0; - this->ScaleBiasProgram=0; -} - -//----------------------------------------------------------------------------- -// Destruct a vtkOpenGLGPUVolumeRayCastMapper - clean up any memory used -//----------------------------------------------------------------------------- -vtkOpenGLGPUVolumeRayCastMapper::~vtkOpenGLGPUVolumeRayCastMapper() -{ - delete this->UnsupportedRequiredExtensions; - - int i=0; - while(i<3) - { - this->TempMatrix[i]->Delete(); - this->TempMatrix[i]=0; - ++i; - } - - delete[] this->ErrorString; - - if ( this->SmallInput ) - { - this->SmallInput->UnRegister(this); - } - - if(this->PolyDataBoundingBox!=0) - { - this->PolyDataBoundingBox->UnRegister(this); - this->PolyDataBoundingBox=0; - } - if(this->Planes!=0) - { - this->Planes->UnRegister(this); - this->Planes=0; - } - if(this->NearPlane!=0) - { - this->NearPlane->UnRegister(this); - this->NearPlane=0; - } - if(this->Clip!=0) - { - this->Clip->UnRegister(this); - this->Clip=0; - } - if(this->Densify!=0) - { - this->Densify->UnRegister(this); - this->Densify=0; - } - - if(this->BoxSource!=0) - { - this->BoxSource->UnRegister(this); - this->BoxSource=0; - } - this->InvVolumeMatrix->UnRegister(this); - this->InvVolumeMatrix=0; - - delete[] this->NoiseTexture; - delete this->ScalarsTextures; - delete this->MaskTextures; - - if(this->Program!=0) - { - this->Program->Delete(); - } - if(this->Main!=0) - { - this->Main->Delete(); - } - if(this->Projection!=0) - { - this->Projection->Delete(); - } - if(this->Trace!=0) - { - this->Trace->Delete(); - } - if(this->CroppingShader!=0) - { - this->CroppingShader->Delete(); - } - if(this->Component!=0) - { - this->Component->Delete(); - } - if(this->Shade!=0) - { - this->Shade->Delete(); - } - if(this->ScaleBiasProgram!=0) - { - this->ScaleBiasProgram->Delete(); - } -} - -//----------------------------------------------------------------------------- -// Based on hardware and properties, we may or may not be able to -// render using 3D texture mapping. This indicates if 3D texture -// mapping is supported by the hardware, and if the other extensions -// necessary to support the specific properties are available. -// -//----------------------------------------------------------------------------- -int vtkOpenGLGPUVolumeRayCastMapper::IsRenderSupported( - vtkRenderWindow *window, - vtkVolumeProperty *vtkNotUsed(property)) -{ - window->MakeCurrent(); - if(!this->LoadExtensionsSucceeded) - { - this->LoadExtensions(window); - } - if(!this->LoadExtensionsSucceeded) - { - vtkDebugMacro( - "The following OpenGL extensions are required but not supported: " - << (this->UnsupportedRequiredExtensions->Stream.str()).c_str()); - return 0; - } - return 1; -} - -//----------------------------------------------------------------------------- -// Return if the required OpenGL extension `extensionName' is supported. -// If not, its name is added to the string of unsupported but required -// extensions. -// \pre extensions_exist: extensions!=0 -// \pre extensionName_exists: extensionName!=0 -//----------------------------------------------------------------------------- -int vtkOpenGLGPUVolumeRayCastMapper::TestRequiredExtension( - vtkOpenGLExtensionManager *extensions, - const char *extensionName) -{ - assert("pre: extensions_exist" && extensions!=0); - assert("pre: extensionName_exists" && extensionName!=0); - int result=extensions->ExtensionSupported(extensionName); - - if(!result) - { - if(this->LoadExtensionsSucceeded) - { - this->UnsupportedRequiredExtensions->Stream<LoadExtensionsSucceeded=0; - } - else - { - this->UnsupportedRequiredExtensions->Stream<<", "<LoadExtensionsSucceeded will be set to 0 or 1 -// - this->UnsupportedRequiredExtensions will have a message indicating -// any failure codes -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::LoadExtensions( - vtkRenderWindow *window) -{ - // We may already have a string stream for the unsupported extensions - // from the last time this method was called. If so, delete it. - delete this->UnsupportedRequiredExtensions; - - // Create a string stream to hold the unsupported extensions so we can - // report something meaningful back - this->UnsupportedRequiredExtensions = - new vtkUnsupportedRequiredExtensionsStringStream; - - // Assume success - this->LoadExtensionsSucceeded=1; - - // get the extension manager - vtkOpenGLRenderWindow *context = vtkOpenGLRenderWindow::SafeDownCast(window); - if (!context) - { - this->UnsupportedRequiredExtensions->Stream<< - " Disabled because context is not a vtkOpenGLRederWindow."; - this->LoadExtensionsSucceeded=0; - return; - } - vtkOpenGLExtensionManager *extensions = context->GetExtensionManager(); - - // mesa notes: - // 8.0.0 -- missing some required extensions - // 8.0.5 -- tests pass but there are invalid enum opengl errors reported (mesa bug) - // 9.1.3 & 9.1.4 w/ OS Mesa -- GPURayCastCompositeShadeMask fails (mesa bug?) test disabled - // 9.2.0 w/llvmpipe -- tests pass cleanly - if ( (extensions->DriverIsMesa() - && !(extensions->DriverGLRendererIsOSMesa() && extensions->DriverVersionAtLeast(9))) - && !extensions->GetIgnoreDriverBugs("Mesa FBO bugs")) - { - this->UnsupportedRequiredExtensions->Stream<< - " Disabled because of Mesa FBO bugs."; - this->LoadExtensionsSucceeded=0; - } - - // GL_ARB_draw_buffers requires OpenGL 1.3, so we must have OpenGL 1.3 - // We don't need to check for some extensions that become part of OpenGL - // core after 1.3. Among them: - // - texture_3d is in core OpenGL since 1.2 - // - texture_edge_clamp is in core OpenGL since 1.2 - // (GL_SGIS_texture_edge_clamp or GL_EXT_texture_edge_clamp (nVidia) ) - // - multitexture is in core OpenGL since 1.3 - - int supports_GL_1_3=extensions->ExtensionSupported("GL_VERSION_1_3"); - int supports_GL_2_0=0; - - // No 1.3 support - give up - if(!supports_GL_1_3) - { - this->LoadExtensionsSucceeded=0; - this->UnsupportedRequiredExtensions->Stream<< - " OpenGL 1.3 is required but not supported"; - return; - } - - // Check for 2.0 support - supports_GL_2_0=extensions->ExtensionSupported("GL_VERSION_2_0"); - - // Some extensions that are supported in 2.0, but if we don't - // have 2.0 we'll need to check further - int supports_shading_language_100 = 1; - int supports_shader_objects = 1; - int supports_fragment_shader = 1; - int supports_texture_non_power_of_two = 1; - int supports_draw_buffers = 1; - if(!supports_GL_2_0) - { - supports_shading_language_100= - extensions->ExtensionSupported("GL_ARB_shading_language_100"); - supports_shader_objects= - extensions->ExtensionSupported("GL_ARB_shader_objects"); - supports_fragment_shader= - extensions->ExtensionSupported("GL_ARB_fragment_shader"); - supports_texture_non_power_of_two= - extensions->ExtensionSupported("GL_ARB_texture_non_power_of_two"); - supports_draw_buffers= - extensions->ExtensionSupported("GL_ARB_draw_buffers"); - } - - // We have to check for framebuffer objects - int supports_GL_EXT_framebuffer_object= - extensions->ExtensionSupported("GL_EXT_framebuffer_object" ); - - // Find out if we have OpenGL 1.4 support - int supports_GL_1_4=extensions->ExtensionSupported("GL_VERSION_1_4"); - - // Find out if we have the depth texture ARB extension - int supports_GL_ARB_depth_texture= - extensions->ExtensionSupported("GL_ARB_depth_texture"); - - // Depth textures are support if we either have OpenGL 1.4 - // or if the depth texture ARB extension is supported - int supports_depth_texture = - supports_GL_1_4 || supports_GL_ARB_depth_texture; - - // Now start adding messages to the UnsupportedRequiredExtensions string - // Log message if shading language 100 is not supported - if(!supports_shading_language_100) - { - this->UnsupportedRequiredExtensions->Stream<< - " shading_language_100 (or OpenGL 2.0) is required but not supported"; - this->LoadExtensionsSucceeded=0; - } - else - { - // We can query the GLSL version, we need >=1.20 - const char *glsl_version= - reinterpret_cast(glGetString(vtkgl::SHADING_LANGUAGE_VERSION)); - int glslMajor, glslMinor; - std::istringstream ist(glsl_version); - ist >> glslMajor; - char c; - ist.get(c); // '.' - ist >> glslMinor; -//sscanf(version, "%d.%d", &glslMajor, &glslMinor); - if(glslMajor<1 || (glslMajor==1 && glslMinor<20)) - { - this->LoadExtensionsSucceeded=0; - } - } - - // Log message if shader objects are not supported - if(!supports_shader_objects) - { - this->UnsupportedRequiredExtensions->Stream<< - " shader_objects (or OpenGL 2.0) is required but not supported"; - this->LoadExtensionsSucceeded=0; - } - - // Log message if fragment shaders are not supported - if(!supports_fragment_shader) - { - this->UnsupportedRequiredExtensions->Stream<< - " fragment_shader (or OpenGL 2.0) is required but not supported"; - this->LoadExtensionsSucceeded=0; - } - - // Log message if non power of two textures are not supported - if(!supports_texture_non_power_of_two) - { - this->UnsupportedRequiredExtensions->Stream<< - " texture_non_power_of_two (or OpenGL 2.0) is required but not " - << "supported"; - this->LoadExtensionsSucceeded=0; - } - - // Log message if draw buffers are not supported - if(!supports_draw_buffers) - { - this->UnsupportedRequiredExtensions->Stream<< - " draw_buffers (or OpenGL 2.0) is required but not supported"; - this->LoadExtensionsSucceeded=0; - } - - // Log message if depth textures are not supported - if(!supports_depth_texture) - { - this->UnsupportedRequiredExtensions->Stream<< - " depth_texture (or OpenGL 1.4) is required but not supported"; - this->LoadExtensionsSucceeded=0; - } - - // Log message if framebuffer objects are not supported - if(!supports_GL_EXT_framebuffer_object) - { - this->UnsupportedRequiredExtensions->Stream<< - " framebuffer_object is required but not supported"; - this->LoadExtensionsSucceeded=0; - } - - // Have we succeeded so far? If not, just return. - if(!this->LoadExtensionsSucceeded) - { - return; - } - - // Now start loading the extensions - // First load all 1.2 and 1.3 extensions (we know we - // support at least up to 1.3) - extensions->LoadExtension("GL_VERSION_1_2"); - extensions->LoadExtension("GL_VERSION_1_3"); - - // Load the 2.0 extensions if supported - if(supports_GL_2_0) - { - extensions->LoadExtension("GL_VERSION_2_0"); - } - // Otherwise, we'll need to specifically load the - // shader objects, fragment shader, and draw buffers - // extensions - else - { - extensions->LoadCorePromotedExtension("GL_ARB_shader_objects"); - extensions->LoadCorePromotedExtension("GL_ARB_fragment_shader"); - extensions->LoadCorePromotedExtension("GL_ARB_draw_buffers"); - } - - // Load the framebuffer object extension - extensions->LoadExtension("GL_EXT_framebuffer_object"); - - // Optional extension (does not fail if not present) - // Load it if supported which will allow us to store - // textures as floats - this->Supports_GL_ARB_texture_float= - extensions->ExtensionSupported("GL_ARB_texture_float" ); - if(this->Supports_GL_ARB_texture_float) - { - extensions->LoadExtension( "GL_ARB_texture_float" ); - } - - // Optional extension (does not fail if not present) - // Used to minimize memory footprint when loading large 3D textures - // of scalars. - // VBO or 1.5 is required by PBO or 2.1 - int supports_GL_1_5=extensions->ExtensionSupported("GL_VERSION_1_5"); - int supports_vertex_buffer_object=supports_GL_1_5 || - extensions->ExtensionSupported("GL_ARB_vertex_buffer_object"); - int supports_GL_2_1=extensions->ExtensionSupported("GL_VERSION_2_1"); - this->SupportsPixelBufferObjects=supports_vertex_buffer_object && - (supports_GL_2_1 || - extensions->ExtensionSupported("GL_ARB_pixel_buffer_object")); - - if(this->SupportsPixelBufferObjects) - { - if(supports_GL_1_5) - { - extensions->LoadExtension("GL_VERSION_1_5"); - } - else - { - extensions->LoadCorePromotedExtension("GL_ARB_vertex_buffer_object"); - } - if(supports_GL_2_1) - { - extensions->LoadExtension("GL_VERSION_2_1"); - } - else - { - extensions->LoadCorePromotedExtension("GL_ARB_pixel_buffer_object"); - } - } - - // Ultimate test. Some old cards support OpenGL 2.0 but not while - // statements in a fragment shader (example: nVidia GeForce FX 5200) - // It does not fail when compiling each shader source but at linking - // stage because the parser underneath only check for syntax during - // compilation and the actual native code generation happens during - // the linking stage. - this->NumberOfCroppingRegions=1; - this->BuildProgram(window,1, - vtkOpenGLGPUVolumeRayCastMapperMethodComposite, - vtkOpenGLGPUVolumeRayCastMapperShadeNo, - vtkOpenGLGPUVolumeRayCastMapperComponentOne); - - this->Program->SetPrintErrors(false); - this->Program->Build(); - this->Program->SetPrintErrors(true); - - if(this->Program->GetLastBuildStatus()!=VTK_SHADER_PROGRAM2_LINK_SUCCEEDED) - { - this->LoadExtensionsSucceeded=0; - this->UnsupportedRequiredExtensions->Stream<< - " this card does not support while statements in fragment shaders."; - } - - this->Program->ReleaseGraphicsResources(); - if(this->LastComponent!= - vtkOpenGLGPUVolumeRayCastMapperComponentNotInitialized) - { - this->Program->GetShaders()->RemoveItem(this->Component); - } - if(this->LastShade!= - vtkOpenGLGPUVolumeRayCastMapperShadeNotInitialized) - { - this->Program->GetShaders()->RemoveItem(this->Shade); - } - - this->LastParallelProjection= - vtkOpenGLGPUVolumeRayCastMapperProjectionNotInitialized; - this->LastRayCastMethod= - vtkOpenGLGPUVolumeRayCastMapperMethodNotInitialized; - this->LastCroppingMode= - vtkOpenGLGPUVolumeRayCastMapperCroppingNotInitialized; - this->LastComponent= - vtkOpenGLGPUVolumeRayCastMapperComponentNotInitialized; - this->LastShade=vtkOpenGLGPUVolumeRayCastMapperShadeNotInitialized; -} - -//----------------------------------------------------------------------------- -// Delete OpenGL objects. -// \post done: this->OpenGLObjectsCreated==0 -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::ReleaseGraphicsResources( - vtkWindow *window) -{ - if(this->OpenGLObjectsCreated) - { - window->MakeCurrent(); - vtkOpenGLClearErrorMacro(); - this->LastSize[0]=0; - this->LastSize[1]=0; - GLuint frameBufferObject=static_cast(this->FrameBufferObject); - vtkgl::DeleteFramebuffersEXT(1,&frameBufferObject); - GLuint depthRenderBufferObject= - static_cast(this->DepthRenderBufferObject); - vtkgl::DeleteRenderbuffersEXT(1,&depthRenderBufferObject); - GLuint textureObjects[vtkOpenGLGPUVolumeRayCastMapperNumberOfTextureObjects]; - int i=0; - while(i<(vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+this->NumberOfFrameBuffers)) - { - textureObjects[i]=static_cast(this->TextureObjects[i]); - ++i; - } - glDeleteTextures(vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+this->NumberOfFrameBuffers,textureObjects); - - if(this->MaxValueFrameBuffer!=0) - { - GLuint maxValueFrameBuffer= - static_cast(this->MaxValueFrameBuffer); - glDeleteTextures(1,&maxValueFrameBuffer); - this->MaxValueFrameBuffer=0; - } - if(this->MaxValueFrameBuffer2!=0) - { - GLuint maxValueFrameBuffer2= - static_cast(this->MaxValueFrameBuffer2); - glDeleteTextures(1,&maxValueFrameBuffer2); - this->MaxValueFrameBuffer2=0; - } - this->LastParallelProjection= - vtkOpenGLGPUVolumeRayCastMapperProjectionNotInitialized; - this->LastRayCastMethod= - vtkOpenGLGPUVolumeRayCastMapperMethodNotInitialized; - this->LastCroppingMode= - vtkOpenGLGPUVolumeRayCastMapperCroppingNotInitialized; - this->LastComponent= - vtkOpenGLGPUVolumeRayCastMapperComponentNotInitialized; - this->LastShade=vtkOpenGLGPUVolumeRayCastMapperShadeNotInitialized; - this->OpenGLObjectsCreated=0; - vtkOpenGLCheckErrorMacro("failed during ReleaseGraphicsResources"); - } - - if(this->NoiseTextureId!=0) - { - window->MakeCurrent(); - vtkOpenGLClearErrorMacro(); - GLuint noiseTextureObjects=static_cast(this->NoiseTextureId); - glDeleteTextures(1,&noiseTextureObjects); - this->NoiseTextureId=0; - vtkOpenGLCheckErrorMacro("failed during ReleaseGraphicsResources"); - } - - if(this->ScalarsTextures!=0) - { - if(!this->ScalarsTextures->Map.empty()) - { - std::map::iterator it=this->ScalarsTextures->Map.begin(); - while(it!=this->ScalarsTextures->Map.end()) - { - vtkKWScalarField *texture=(*it).second; - delete texture; - ++it; - } - this->ScalarsTextures->Map.clear(); - } - } - - if(this->MaskTextures!=0) - { - if(!this->MaskTextures->Map.empty()) - { - std::map::iterator it=this->MaskTextures->Map.begin(); - while(it!=this->MaskTextures->Map.end()) - { - vtkKWMask *texture=(*it).second; - delete texture; - ++it; - } - this->MaskTextures->Map.clear(); - } - } - - if (this->RGBTable) - { - this->RGBTable->Delete(); - this->RGBTable = NULL; - } - - if (this->Mask1RGBTable) - { - this->Mask1RGBTable->Delete(); - this->Mask1RGBTable = NULL; - } - - if (this->Mask2RGBTable) - { - this->Mask2RGBTable->Delete(); - this->Mask2RGBTable = NULL; - } - - delete this->OpacityTables; - this->OpacityTables=0; - - if(this->Program!=0) - { - this->Program->ReleaseGraphicsResources(); - } - if(this->Main!=0) - { - this->Main->ReleaseGraphicsResources(); - } - if(this->Projection!=0) - { - this->Projection->ReleaseGraphicsResources(); - } - if(this->Trace!=0) - { - this->Trace->ReleaseGraphicsResources(); - } - if(this->CroppingShader!=0) - { - this->CroppingShader->ReleaseGraphicsResources(); - } - if(this->Component!=0) - { - this->Component->ReleaseGraphicsResources(); - } - if(this->Shade!=0) - { - this->Shade->ReleaseGraphicsResources(); - } - if(this->ScaleBiasProgram!=0) - { - this->ScaleBiasProgram->ReleaseGraphicsResources(); - } -} - -//----------------------------------------------------------------------------- -// Create OpenGL objects such as textures, buffers and fragment program Ids. -// It only registers Ids, there is no actual initialization of textures or -// fragment program. -// -// Pre-conditions: -// This method assumes that this->LoadedExtensionsSucceeded is 1. -// -// Post-conditions: -// When this method completes successfully, this->OpenGLObjectsCreated -// will be 1. -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::CreateOpenGLObjects(vtkRenderer *ren) -{ - vtkOpenGLClearErrorMacro(); - - GLint value; - glGetIntegerv(vtkgl::FRAMEBUFFER_BINDING_EXT,&value); - GLuint savedFrameBuffer=static_cast(value); - - if ( !this->OpenGLObjectsCreated ) - { - // Initialize only if the objects haven't been created yet. - - // We need only two color buffers (ping-pong) - this->NumberOfFrameBuffers=2; - - GLuint frameBufferObject; - GLuint depthRenderBufferObject; - - - // TODO: clean this up! - // 2*Frame buffers(2d textures)+colorMap (1d texture) +dataset (3d texture) - // + opacitymap (1d texture) + grabbed depthMap (2d texture) - GLuint textureObjects[vtkOpenGLGPUVolumeRayCastMapperNumberOfTextureObjects]; - - // Create the various objects we will need - one frame buffer - // which will contain a render buffer for depth and a texture - // for color. - vtkgl::GenFramebuffersEXT(1, &frameBufferObject); // color - vtkgl::GenRenderbuffersEXT(1, &depthRenderBufferObject); // depth - int i=0; - while(i<( vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+this->NumberOfFrameBuffers)) - { - textureObjects[i]=0; - ++i; - } - - // Frame buffers(2d textures)+colorMap (1d texture) +dataset (3d texture) - // + opacity (1d texture)+grabbed depth buffer (2d texture) - glGenTextures(vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+this->NumberOfFrameBuffers,textureObjects); - // Color buffers - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT,frameBufferObject); - i = 0; - while(i < this->NumberOfFrameBuffers) - { - glBindTexture(GL_TEXTURE_2D,textureObjects[vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+i]); - ++i; - } - - // Save GL objects by static casting to standard C types. GL* types - // are not allowed in VTK header files. - this->FrameBufferObject=static_cast(frameBufferObject); - this->DepthRenderBufferObject=static_cast(depthRenderBufferObject); - i=0; - while(i<(vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+this->NumberOfFrameBuffers)) - { - this->TextureObjects[i]=static_cast(textureObjects[i]); - ++i; - } - - this->OpenGLObjectsCreated=1; - - } // endif OpenGLObjectsCreated - - int size[2]; - int i=0; - - ren->GetTiledSize(&size[0],&size[1]); - this->SizeChanged = this->LastSize[0]!=size[0] || this->LastSize[1]!=size[1]; - - GLenum errorCode=glGetError(); - while(i NumberOfFrameBuffers && errorCode==GL_NO_ERROR) - { - if (this->SizeChanged) - { - glBindTexture(GL_TEXTURE_2D,static_cast(this->TextureObjects[vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+i])); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - // Here we are assuming that GL_ARB_texture_non_power_of_two is available - if(this->Supports_GL_ARB_texture_float) - { - glTexImage2D(GL_TEXTURE_2D,0,vtkgl::RGBA16F_ARB,size[0],size[1], - 0, GL_RGBA, GL_FLOAT, NULL ); - } - else - { - glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA16,size[0],size[1], - 0, GL_RGBA, GL_FLOAT, NULL ); - } - } - - errorCode=glGetError(); - ++i; - } - - if (this->SizeChanged) - { - if(errorCode==GL_NO_ERROR) - { - // grabbed depth buffer - glBindTexture(GL_TEXTURE_2D,static_cast(this->TextureObjects[vtkOpenGLGPUVolumeRayCastMapperTextureObjectDepthMap])); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameteri(GL_TEXTURE_2D, vtkgl::DEPTH_TEXTURE_MODE, GL_LUMINANCE); - glTexImage2D(GL_TEXTURE_2D, 0, vtkgl::DEPTH_COMPONENT32, size[0],size[1], - 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL ); - - // Set up the depth render buffer - - GLint savedFrameBuffer2; - glGetIntegerv(vtkgl::FRAMEBUFFER_BINDING_EXT,&savedFrameBuffer2); - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT, - static_cast(this->FrameBufferObject)); - vtkgl::BindRenderbufferEXT( - vtkgl::RENDERBUFFER_EXT, - static_cast(this->DepthRenderBufferObject)); - vtkgl::RenderbufferStorageEXT(vtkgl::RENDERBUFFER_EXT, - vtkgl::DEPTH_COMPONENT24,size[0],size[1]); - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT, - static_cast(savedFrameBuffer2)); - errorCode=glGetError(); - if(errorCode==GL_NO_ERROR) - { - this->LastSize[0]=size[0]; - this->LastSize[1]=size[1]; - } - } - } - - - // Bind the Frame buffer object and then attach 2D texture to the FBO - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT, - static_cast(this->FrameBufferObject)); - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D, - static_cast(this->TextureObjects[vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront]), - 0); - - // Depth buffer - vtkgl::BindRenderbufferEXT(vtkgl::RENDERBUFFER_EXT, - static_cast(this->DepthRenderBufferObject)); - - vtkgl::FramebufferRenderbufferEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::DEPTH_ATTACHMENT_EXT, - vtkgl::RENDERBUFFER_EXT, - static_cast(this->DepthRenderBufferObject)); - - // Restore default frame buffer. - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT,savedFrameBuffer); - - vtkOpenGLCheckErrorMacro("failed after CreateOpenGLObjects"); -} - - -//----------------------------------------------------------------------------- -// Allocate memory on the GPU for the framebuffers according to the size of -// the window or reallocate if the size has changed. Return true if -// allocation succeeded. -// \pre ren_exists: ren!=0 -// \pre opengl_objects_created: this->OpenGLObjectsCreated -// \post right_size: LastSize[]=window size. -//----------------------------------------------------------------------------- -int vtkOpenGLGPUVolumeRayCastMapper::AllocateFrameBuffers(vtkRenderer *ren) -{ - assert("pre: ren_exists" && ren!=0); - assert("pre: opengl_objects_created" && this->OpenGLObjectsCreated); - - vtkOpenGLClearErrorMacro(); - - int result=1; - int size[2]; - ren->GetTiledSize(&size[0],&size[1]); - - const bool accumulativeBlendMode = - (this->BlendMode==vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND || - this->BlendMode==vtkGPUVolumeRayCastMapper::MINIMUM_INTENSITY_BLEND || - this->BlendMode==vtkGPUVolumeRayCastMapper::ADDITIVE_BLEND); - - const bool needNewMaxValueBuffer = - (this->MaxValueFrameBuffer == 0) && accumulativeBlendMode; - - GLint value; - glGetIntegerv(vtkgl::FRAMEBUFFER_BINDING_EXT,&value); - GLuint savedFrameBuffer=static_cast(value); - - if(needNewMaxValueBuffer) - { - // blend mode changed and need max value buffer. - - // create and bind second color buffer (we use only the red component - // to store the max scalar). We can't use a one component color buffer - // because all color buffer have to have the same format. - - // max scalar frame buffer - GLuint maxValueFrameBuffer; - glGenTextures(1,&maxValueFrameBuffer); - this->MaxValueFrameBuffer= - static_cast(maxValueFrameBuffer); - - // max scalar frame buffer2 - GLuint maxValueFrameBuffer2; - glGenTextures(1,&maxValueFrameBuffer2); - this->MaxValueFrameBuffer2= - static_cast(maxValueFrameBuffer2); - } - else - { - if (this->MaxValueFrameBuffer && !accumulativeBlendMode) - { - // blend mode changed and does not need max value buffer anymore. - - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT, - static_cast(this->FrameBufferObject)); - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT+1, - GL_TEXTURE_2D,0,0); // not scalar buffer - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT,savedFrameBuffer); - - GLuint maxValueFrameBuffer= - static_cast(this->MaxValueFrameBuffer); - glDeleteTextures(1,&maxValueFrameBuffer); - this->MaxValueFrameBuffer=0; - - GLuint maxValueFrameBuffer2= - static_cast(this->MaxValueFrameBuffer2); - glDeleteTextures(1,&maxValueFrameBuffer2); - this->MaxValueFrameBuffer2=0; - } - } - - if (accumulativeBlendMode && (this->SizeChanged || needNewMaxValueBuffer)) - { - // max scalar frame buffer - GLuint maxValueFrameBuffer=static_cast(this->MaxValueFrameBuffer); - glBindTexture(GL_TEXTURE_2D,maxValueFrameBuffer); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - // Here we are assuming that GL_ARB_texture_non_power_of_two is available - if(this->Supports_GL_ARB_texture_float) - { - glTexImage2D(GL_TEXTURE_2D,0,vtkgl::RGBA16F_ARB,size[0],size[1], - 0, GL_RGBA, GL_FLOAT, NULL ); - } - else - { - glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA16,size[0],size[1], - 0, GL_RGBA, GL_FLOAT, NULL ); - } - - - // Bind and attach here (after the size has been set, or ATI will cry), - // then restore default buffer. - vtkgl::BindFramebufferEXT( - vtkgl::FRAMEBUFFER_EXT,static_cast(this->FrameBufferObject)); - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT+1, - GL_TEXTURE_2D,maxValueFrameBuffer,0); - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT, - static_cast(savedFrameBuffer)); - - - // max scalar frame buffer 2 - GLuint maxValueFrameBuffer2=static_cast(this->MaxValueFrameBuffer2); - glBindTexture(GL_TEXTURE_2D,maxValueFrameBuffer2); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - // Here we are assuming that GL_ARB_texture_non_power_of_two is available - if(this->Supports_GL_ARB_texture_float) - { - glTexImage2D(GL_TEXTURE_2D,0,vtkgl::RGBA16F_ARB,size[0],size[1], - 0, GL_RGBA, GL_FLOAT, NULL ); - } - else - { - glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA16,size[0],size[1], - 0, GL_RGBA, GL_FLOAT, NULL ); - } - } - - vtkOpenGLCheckErrorMacro("failed after AllocateFrameBuffers"); - return result; -} - - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::GetTextureFormat( - vtkImageData *input, - unsigned int *internalFormat, - unsigned int *format, - unsigned int *type, - int *componentSize) -{ - *internalFormat=0; - *format=0; - *type=0; - *componentSize=0; - - vtkDataArray *scalars=this->GetScalars(input,this->ScalarMode, - this->ArrayAccessMode, - this->ArrayId, - this->ArrayName, - this->CellFlag); - - int scalarType=scalars->GetDataType(); - int components=scalars->GetNumberOfComponents(); - *componentSize=vtkAbstractArray::GetDataTypeSize(scalarType)*components; - - if(components==4) - { - // this is RGBA, unsigned char only - *internalFormat=GL_RGBA16; - *format=GL_RGBA; - *type=GL_UNSIGNED_BYTE; - } - else - { - // components==1 - switch(scalarType) - { - case VTK_FLOAT: - if(this->Supports_GL_ARB_texture_float) - { - *internalFormat=vtkgl::INTENSITY16F_ARB; - } - else - { - *internalFormat=GL_INTENSITY16; - } - *format=GL_RED; - *type=GL_FLOAT; - break; - case VTK_UNSIGNED_CHAR: - *internalFormat=GL_INTENSITY8; - *format=GL_RED; - *type=GL_UNSIGNED_BYTE; - break; - case VTK_SIGNED_CHAR: - *internalFormat=GL_INTENSITY8; - *format=GL_RED; - *type=GL_BYTE; - break; - case VTK_CHAR: - // not supported - assert("check: impossible case" && 0); - break; - case VTK_BIT: - // not supported - assert("check: impossible case" && 0); - break; - case VTK_ID_TYPE: - // not supported - assert("check: impossible case" && 0); - break; - case VTK_INT: - *internalFormat=GL_INTENSITY16; - *format=GL_RED; - *type=GL_INT; - break; - case VTK_DOUBLE: - case VTK_LONG: - case VTK_LONG_LONG: -#if !defined(VTK_LEGACY_REMOVE) - case VTK___INT64: - case VTK_UNSIGNED___INT64: -#endif - case VTK_UNSIGNED_LONG: - case VTK_UNSIGNED_LONG_LONG: - if(this->Supports_GL_ARB_texture_float) - { - *internalFormat=vtkgl::INTENSITY16F_ARB; - } - else - { - *internalFormat=GL_INTENSITY16; - } - *format=GL_RED; - *type=GL_FLOAT; - break; - case VTK_SHORT: - *internalFormat=GL_INTENSITY16; - *format=GL_RED; - *type=GL_SHORT; - break; - case VTK_STRING: - // not supported - assert("check: impossible case" && 0); - break; - case VTK_UNSIGNED_SHORT: - *internalFormat=GL_INTENSITY16; - *format=GL_RED; - *type=GL_UNSIGNED_SHORT; - break; - case VTK_UNSIGNED_INT: - *internalFormat=GL_INTENSITY16; - *format=GL_RED; - *type=GL_UNSIGNED_INT; - break; - default: - assert("check: impossible case" && 0); - break; - } - } -} - -//----------------------------------------------------------------------------- -// Assuming the textureSize[3] is less of equal to the maximum size of an -// OpenGL 3D texture, try to see if the texture can fit on the card. -//----------------------------------------------------------------------------- -bool vtkOpenGLGPUVolumeRayCastMapper::TestLoadingScalar( - unsigned int internalFormat, - unsigned int format, - unsigned int type, - int textureSize[3], - int componentSize) -{ - // componentSize=vtkAbstractArray::GetDataTypeSize(scalarType)*input->GetNumberOfScalarComponents() - - bool result; - - vtkgl::TexImage3D(vtkgl::PROXY_TEXTURE_3D,0, - static_cast(internalFormat), - textureSize[0],textureSize[1],textureSize[2],0, - format, - type,0); - GLint width; - glGetTexLevelParameteriv(vtkgl::PROXY_TEXTURE_3D,0,GL_TEXTURE_WIDTH, - &width); - - result=width!=0; - if(result) - { - // so far, so good but some cards always succeed with a proxy texture - // let's try to actually allocate.. - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,static_cast(internalFormat), - textureSize[0], - textureSize[1],textureSize[2],0, - format, - type,0); - GLenum errorCode=glGetError(); - result=errorCode!=GL_OUT_OF_MEMORY; - if(result) - { - if(errorCode!=GL_NO_ERROR) - { - cout<<"after try to load the texture"; - cout<<" ERROR (x"<(errorCode)); - cout<(this->MaxMemoryInBytes)*this->MaxMemoryFraction; - } - } - return result; -} - -//----------------------------------------------------------------------------- -// Load the scalar field (one or four component scalar field), cell or point -// based for a given subextent of the whole extent (can be the whole extent) -// as a 3D texture on the GPU. -// Extents are expressed in point if the cell flag is false or in cells of -// the cell flag is true. -// It returns true if it succeeded, false if there is not enough memory on -// the GPU. -// If succeeded, it updates the LoadedExtent, LoadedBounds, LoadedCellFlag -// and LoadedTime. It also succeed if the scalar field is already loaded -// (ie since last load, input has not changed and cell flag has not changed -// and requested texture extents are enclosed in the loaded extent). -// \pre input_exists: input!=0 -// \pre valid_point_extent: (this->CellFlag || -// (textureExtent[0]CellFlag || -// (textureExtent[0]<=textureExtent[1] && -// textureExtent[2]<=textureExtent[3] && -// textureExtent[4]<=textureExtent[5]))) -//----------------------------------------------------------------------------- -int vtkOpenGLGPUVolumeRayCastMapper::LoadScalarField(vtkImageData *input, - vtkImageData *maskInput, - int textureExtent[6], - vtkVolume *volume) -{ - assert("pre: input_exists" && input!=0); - assert("pre: valid_point_extent" && (this->CellFlag || - (textureExtent[0]CellFlag || - (textureExtent[0]<=textureExtent[1] && - textureExtent[2]<=textureExtent[3] && - textureExtent[4]<=textureExtent[5]))); - - vtkOpenGLClearErrorMacro(); - - int result=1; // succeeded - - // make sure we rebind our texture object to texture0 even if we don't have - // to load the data themselves because the binding might be changed by - // another mapper between two rendering calls. - - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - - // Find the texture. - std::map::iterator it= - this->ScalarsTextures->Map.find(input); - - - vtkKWScalarField *texture; - if(it==this->ScalarsTextures->Map.end()) - { - texture=new vtkKWScalarField; - this->ScalarsTextures->Map[input]=texture; - texture->SetSupports_GL_ARB_texture_float(this->Supports_GL_ARB_texture_float==1); - } - else - { - texture=(*it).second; - } - - texture->Update(input,this->CellFlag,textureExtent,this->ScalarMode, - this->ArrayAccessMode, - this->ArrayId, - this->ArrayName, - volume->GetProperty()->GetInterpolationType() - ==VTK_LINEAR_INTERPOLATION, - this->TableRange, - static_cast(static_cast(this->MaxMemoryInBytes)*this->MaxMemoryFraction)); - - result=texture->IsLoaded(); - this->CurrentScalar=texture; - - - // Mask - if(maskInput!=0) - { - vtkgl::ActiveTexture(vtkgl::TEXTURE7); - - // Find the texture. - std::map::iterator it2= - this->MaskTextures->Map.find(maskInput); - - - vtkKWMask *mask; - if(it2==this->MaskTextures->Map.end()) - { - mask=new vtkKWMask; - this->MaskTextures->Map[maskInput]=mask; - } - else - { - mask=(*it2).second; - } - - mask->Update(maskInput,this->CellFlag,textureExtent,this->ScalarMode, - this->ArrayAccessMode, - this->ArrayId, - this->ArrayName, - static_cast(static_cast(this->MaxMemoryInBytes)*this->MaxMemoryFraction)); - - result=result && mask->IsLoaded(); - this->CurrentMask=mask; - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - } - - vtkOpenGLCheckErrorMacro("failed after LoadScalarField"); - - return result; -} - -//----------------------------------------------------------------------------- -// Allocate memory and load color table on the GPU or -// reload it if the transfer function changed. -// \pre vol_exists: vol!=0 -// \pre valid_numberOfScalarComponents: numberOfScalarComponents==1 || numberOfScalarComponents==4 -//----------------------------------------------------------------------------- -int vtkOpenGLGPUVolumeRayCastMapper::UpdateColorTransferFunction( - vtkVolume *vol, - int numberOfScalarComponents) -{ - assert("pre: vol_exists" && vol!=0); - assert("pre: valid_numberOfScalarComponents" && - (numberOfScalarComponents==1 || numberOfScalarComponents==4)); - - vtkOpenGLClearErrorMacro(); - - // Build the colormap in a 1D texture. - - // 1D RGB-texture=mapping from scalar values to color values - // build the table - - if(numberOfScalarComponents==1) - { - vtkVolumeProperty *volumeProperty=vol->GetProperty(); - vtkColorTransferFunction *colorTransferFunction=volumeProperty->GetRGBTransferFunction(0); - - vtkgl::ActiveTexture(vtkgl::TEXTURE1); - - this->RGBTable->Update( - colorTransferFunction,this->TableRange, - volumeProperty->GetInterpolationType()==VTK_LINEAR_INTERPOLATION); - // Restore default - vtkgl::ActiveTexture( vtkgl::TEXTURE0); - } - - if (this->MaskInput != 0 && this->MaskType == LabelMapMaskType) - { - vtkVolumeProperty *volumeProperty=vol->GetProperty(); - vtkColorTransferFunction *c=volumeProperty->GetRGBTransferFunction(1); - - vtkgl::ActiveTexture(vtkgl::TEXTURE8); - this->Mask1RGBTable->Update(c,this->TableRange,false); - - c=volumeProperty->GetRGBTransferFunction(2); - vtkgl::ActiveTexture(vtkgl::TEXTURE9); - this->Mask2RGBTable->Update(c,this->TableRange,false); - - // Restore default - vtkgl::ActiveTexture( vtkgl::TEXTURE0); - } - - vtkOpenGLCheckErrorMacro("failed after UpdateColorTransferFunction"); - return 1; -} - -//----------------------------------------------------------------------------- -// Allocate memory and load opacity table on the GPU or -// reload it if the transfert function changed. -// \pre vol_exists: vol!=0 -// \pre valid_numberOfScalarComponents: numberOfScalarComponents==1 || numberOfScalarComponents==4 -//----------------------------------------------------------------------------- -int vtkOpenGLGPUVolumeRayCastMapper::UpdateOpacityTransferFunction( - vtkVolume *vol, - int numberOfScalarComponents, - unsigned int level) -{ - assert("pre: vol_exists" && vol!=0); - assert("pre: valid_numberOfScalarComponents" && - (numberOfScalarComponents==1 || numberOfScalarComponents==4)); - - vtkOpenGLClearErrorMacro(); - - (void)numberOfScalarComponents; // remove warning in release mode. - - vtkVolumeProperty *volumeProperty=vol->GetProperty(); - vtkPiecewiseFunction *scalarOpacity=volumeProperty->GetScalarOpacity(); - - vtkgl::ActiveTexture( vtkgl::TEXTURE2); //stay here - this->OpacityTables->GetTable(level)->Update( - scalarOpacity,this->BlendMode, - this->ActualSampleDistance, - this->TableRange, - volumeProperty->GetScalarOpacityUnitDistance(0), - volumeProperty->GetInterpolationType()==VTK_LINEAR_INTERPOLATION); - // Restore default active texture - vtkgl::ActiveTexture( vtkgl::TEXTURE0); - - vtkOpenGLCheckErrorMacro("failed after UpdateOpacityTransferFunction"); - - return 1; -} - -//----------------------------------------------------------------------------- -// Prepare rendering in the offscreen framebuffer. -// \pre ren_exists: ren!=0 -// \pre vol_exists: vol!=0 -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::SetupRender(vtkRenderer *ren, - vtkVolume *vol) -{ - assert("pre: ren_exists" && ren!=0); - assert("pre: vol_exists" && vol!=0); - - vtkOpenGLClearErrorMacro(); - - int lowerLeft[2]; - int usize, vsize; - - ren->GetTiledSizeAndOrigin(&usize,&vsize,lowerLeft,lowerLeft+1); - - usize = static_cast(usize*this->ReductionFactor); - vsize = static_cast(vsize*this->ReductionFactor); - - this->ReducedSize[0]=usize; - this->ReducedSize[1]=vsize; - - // the FBO has the size of the renderer (not the renderwindow), - // we always starts at 0,0. - glViewport(0,0, usize, vsize); - glEnable( GL_SCISSOR_TEST ); // scissor on the FBO, on the reduced part. - glScissor(0,0, usize, vsize); - glClearColor(0.0, 0.0, 0.0, 0.0); // maxvalue is 1 - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - //double aspect[2]; - //ren->ComputeAspect(); - //ren->GetAspect(aspect); - //double aspect2[2]; - //ren->vtkViewport::ComputeAspect(); - //ren->vtkViewport::GetAspect(aspect2); - //double aspectModification = aspect[0]*aspect2[1]/(aspect[1]*aspect2[0]); - - //vtkCamera *cam = ren->GetActiveCamera(); - //glMatrixMode( GL_PROJECTION); - //if(usize && vsize) - // { - // this->TempMatrix[0]->DeepCopy(cam->GetProjectionTransformMatrix( - // aspectModification*usize/vsize, -1,1)); - // this->TempMatrix[0]->Transpose(); - // glLoadMatrixd(this->TempMatrix[0]->Element[0]); - // } - //else - // { - // glLoadIdentity(); - - // } - - // push the model view matrix onto the stack, make sure we - // adjust the mode first - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - this->TempMatrix[0]->DeepCopy(vol->GetMatrix()); - this->TempMatrix[0]->Transpose(); - - // insert camera view transformation - glMultMatrixd(this->TempMatrix[0]->Element[0]); - glShadeModel(GL_SMOOTH); - glDisable( GL_LIGHTING); - glEnable (GL_CULL_FACE); - glDisable(GL_DEPTH_TEST); - glDisable(GL_BLEND); // very important, otherwise the first image looks dark. - - vtkOpenGLCheckErrorMacro("failed after SetupRender"); -} - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::DebugDisplayBox(vtkPolyData *box) -{ - vtkPoints *points=box->GetPoints(); - vtkCellArray *polys=box->GetPolys(); - cout<<"npts="<GetNumberOfPoints()<GetNumberOfPoints()) - { - double coords[3]; - points->GetPoint(pointId,coords); - cout<<"pointId="<GetMatrix( this->InvVolumeMatrix ); - this->InvVolumeMatrix->Invert(); - // Normals should be transformed using the transpose of the - // invert of InvVolumeMatrix. - vtkMatrix4x4::Transpose(vol->GetMatrix(),this->TempMatrix[0]); - - if(this->BoxSource==0) - { - this->BoxSource=vtkTessellatedBoxSource::New(); - } - this->BoxSource->SetBounds(worldBounds); - this->BoxSource->SetLevel(0); - this->BoxSource->QuadsOn(); - - if(this->Planes==0) - { - this->Planes=vtkPlaneCollection::New(); - } - this->Planes->RemoveAllItems(); - - vtkCamera *cam = ren->GetActiveCamera(); - double camWorldRange[2]; - double camWorldPos[4]; - double camFocalWorldPoint[4]; - double camWorldDirection[4]; - double camPos[4]; - double camPlaneNormal[4]; - - cam->GetPosition(camWorldPos); - camWorldPos[3] = 1.0; - this->InvVolumeMatrix->MultiplyPoint( camWorldPos, camPos ); - if ( camPos[3] ) - { - camPos[0] /= camPos[3]; - camPos[1] /= camPos[3]; - camPos[2] /= camPos[3]; - } - - cam->GetFocalPoint(camFocalWorldPoint); - camFocalWorldPoint[3]=1.0; - - // The range (near/far) must also be transformed - // into the local coordinate system. - camWorldDirection[0] = camFocalWorldPoint[0] - camWorldPos[0]; - camWorldDirection[1] = camFocalWorldPoint[1] - camWorldPos[1]; - camWorldDirection[2] = camFocalWorldPoint[2] - camWorldPos[2]; - camWorldDirection[3] = 1.0; - - // Compute the normalized near plane normal - this->TempMatrix[0]->MultiplyPoint( camWorldDirection, camPlaneNormal ); - - vtkMath::Normalize(camWorldDirection); - vtkMath::Normalize(camPlaneNormal); - - double camNearWorldPoint[4]; - double camFarWorldPoint[4]; - double camNearPoint[4]; - double camFarPoint[4]; - - cam->GetClippingRange(camWorldRange); - camNearWorldPoint[0] = camWorldPos[0] + camWorldRange[0]*camWorldDirection[0]; - camNearWorldPoint[1] = camWorldPos[1] + camWorldRange[0]*camWorldDirection[1]; - camNearWorldPoint[2] = camWorldPos[2] + camWorldRange[0]*camWorldDirection[2]; - camNearWorldPoint[3] = 1.; - - camFarWorldPoint[0] = camWorldPos[0] + camWorldRange[1]*camWorldDirection[0]; - camFarWorldPoint[1] = camWorldPos[1] + camWorldRange[1]*camWorldDirection[1]; - camFarWorldPoint[2] = camWorldPos[2] + camWorldRange[1]*camWorldDirection[2]; - camFarWorldPoint[3] = 1.; - - this->InvVolumeMatrix->MultiplyPoint( camNearWorldPoint, camNearPoint ); - if (camNearPoint[3]!=0.0) - { - camNearPoint[0] /= camNearPoint[3]; - camNearPoint[1] /= camNearPoint[3]; - camNearPoint[2] /= camNearPoint[3]; - } - - this->InvVolumeMatrix->MultiplyPoint( camFarWorldPoint, camFarPoint ); - if (camFarPoint[3]!=0.0) - { - camFarPoint[0] /= camFarPoint[3]; - camFarPoint[1] /= camFarPoint[3]; - camFarPoint[2] /= camFarPoint[3]; - } - - - if(this->NearPlane==0) - { - this->NearPlane= vtkPlane::New(); - } - - // We add an offset to the near plane to avoid hardware clipping of the - // near plane due to floating-point precision. - // camPlaneNormal is a unit vector, if the offset is larger than the - // distance between near and far point, it will not work, in this case we - // pick a fraction of the near-far distance. - double distNearFar= - sqrt(vtkMath::Distance2BetweenPoints(camNearPoint,camFarPoint)); - double offset=0.001; // some arbitrary small value. - if(offset>=distNearFar) - { - offset=distNearFar/1000.0; - } - - camNearPoint[0]+=camPlaneNormal[0]*offset; - camNearPoint[1]+=camPlaneNormal[1]*offset; - camNearPoint[2]+=camPlaneNormal[2]*offset; - - - - this->NearPlane->SetOrigin( camNearPoint ); - this->NearPlane->SetNormal( camPlaneNormal ); - this->Planes->AddItem(this->NearPlane); - - if ( this->ClippingPlanes ) - { - this->ClippingPlanes->InitTraversal(); - vtkPlane *plane; - while ( (plane = this->ClippingPlanes->GetNextItem()) ) - { - // Planes are in world coordinates, we need to - // convert them in local coordinates - double planeOrigin[4], planeNormal[4];//, planeP1[4]; - plane->GetOrigin(planeOrigin); - planeOrigin[3] = 1.; - plane->GetNormal(planeNormal); - planeNormal[3] = 1.; - this->InvVolumeMatrix->MultiplyPoint(planeOrigin, planeOrigin); - if( planeOrigin[3]) - { - planeOrigin[0] /= planeOrigin[3]; - planeOrigin[1] /= planeOrigin[3]; - planeOrigin[2] /= planeOrigin[3]; - } - this->TempMatrix[0]->MultiplyPoint(planeNormal, planeNormal); - vtkMath::Normalize(planeNormal); - vtkPlane* localPlane = vtkPlane::New(); - localPlane->SetOrigin(planeOrigin); - localPlane->SetNormal(planeNormal); - this->Planes->AddItem(localPlane); - localPlane->Delete(); - } - } - - if(this->Clip==0) - { - this->Clip=vtkClipConvexPolyData::New(); - this->Clip->SetInputConnection(this->BoxSource->GetOutputPort()); - this->Clip->SetPlanes( this->Planes ); - } - - this->Clip->Update(); - - if(this->Densify==0) - { - this->Densify=vtkDensifyPolyData::New(); - this->Densify->SetInputConnection(this->Clip->GetOutputPort()); - this->Densify->SetNumberOfSubdivisions(2); - } - this->Densify->Update(); - this->ClippedBoundingBox = this->Densify->GetOutput(); -} - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -int vtkOpenGLGPUVolumeRayCastMapper::RenderClippedBoundingBox( - int tcoordFlag, - size_t currentBlock, - size_t numberOfBlocks, - vtkRenderWindow *renWin ) -{ - assert("pre: valid_currentBlock" && currentBlockClippedBoundingBox->GetPoints(); - vtkCellArray *polys = this->ClippedBoundingBox->GetPolys(); - - vtkIdType npts; - vtkIdType *pts; - - vtkIdType i, j; - - double center[3] = {0,0,0}; - - // First compute center point - npts = points->GetNumberOfPoints(); - for ( i = 0; i < npts; i++ ) - { - double pt[3]; - points->GetPoint( i, pt ); - for ( j = 0; j < 3; j++ ) - { - center[j] += pt[j]; - } - } - - if(npts>0) - { - center[0]/=static_cast(npts); - center[1]/=static_cast(npts); - center[2]/=static_cast(npts); - } - - double *loadedBounds=0; - vtkIdType *loadedExtent=0; - - if ( tcoordFlag ) - { - loadedBounds=this->CurrentScalar->GetLoadedBounds(); - loadedExtent=this->CurrentScalar->GetLoadedExtent(); - } - - double *spacing=this->GetInput()->GetSpacing(); - double spacingSign[3]; - i=0; - while(i<3) - { - if(spacing[i]<0) - { - spacingSign[i]=-1.0; - } - else - { - spacingSign[i]=1.0; - } - ++i; - } - - // make it double for the ratio of the progress. - int polyId=0; - double polyCount=static_cast(polys->GetNumberOfCells()); - polys->InitTraversal(); - int abort=0; - while ( !abort && polys->GetNextCell(npts, pts) ) - { - vtkIdType start, end, inc; - - // Need to have at least a triangle - if ( npts > 2 ) - { - // Check the cross product of the first two - // vectors dotted with the vector from the - // center to the second point. Is it positive or - // negative? - - double p1[3], p2[3], p3[3]; - double v3[3], v4[3]; - - points->GetPoint(pts[0], p1 ); - points->GetPoint(pts[1], p2 ); - points->GetPoint(pts[2], p3 ); - - vtkTriangle::ComputeNormal(p1, p2, p3, v3); - - v4[0] = p2[0] - center[0]; - v4[1] = p2[1] - center[1]; - v4[2] = p2[2] - center[2]; - vtkMath::Normalize(v4); - - double dot = vtkMath::Dot( v3, v4 ); - if(!this->PreserveOrientation) - { - dot=-dot; - } - if(dot >= -0.000001) - { - start = 0; - end = npts; - inc = 1; - } - else - { - start = npts-1; - end = -1; - inc = -1; - } - - glBegin( GL_TRIANGLE_FAN ); // GL_POLYGON -> GL_TRIANGLE_FAN - - double vert[3]; - double tcoord[3]; - for ( i = start; i != end; i += inc ) - { - points->GetPoint(pts[i], vert); - if ( tcoordFlag ) - { - for ( j = 0; j < 3; j++ ) - { - // loaded bounds take both cell data and point date cases into - // account - if(this->CellFlag) // texcoords between 0 and 1. More complex - // depends on the loaded texture - { - tcoord[j] = spacingSign[j]*(vert[j] - loadedBounds[j*2]) / - (loadedBounds[j*2+1] - loadedBounds[j*2]); - } - else // texcoords between 1/2N and 1-1/2N. - { - double tmp; // between 0 and 1 - tmp = spacingSign[j]*(vert[j] - loadedBounds[j*2]) / - (loadedBounds[j*2+1] - loadedBounds[j*2]); - double delta=static_cast( - loadedExtent[j*2+1]-loadedExtent[j*2]+1); - tcoord[j]=(tmp*(delta-1)+0.5)/delta; - } - } - vtkgl::MultiTexCoord3dv(vtkgl::TEXTURE0, tcoord); - } - glVertex3dv(vert); - } - glEnd(); - - } - if(tcoordFlag) - { - // otherwise, we are rendering back face to initialize the zbuffer. - if (!this->GeneratingCanonicalView && this->ReportProgress) - { - glFinish(); - // Only invoke an event at most one every second. - double currentTime=vtkTimerLog::GetUniversalTime(); - if(currentTime - this->LastProgressEventTime > 1.0) - { - double progress=(static_cast(currentBlock)+polyId/polyCount)/ - static_cast(numberOfBlocks); - this->InvokeEvent(vtkCommand::VolumeMapperRenderProgressEvent, - &progress); - renWin->MakeCurrent(); - this->LastProgressEventTime = currentTime; - } - } - abort=renWin->CheckAbortStatus(); - } - ++polyId; - } - - vtkOpenGLCheckErrorMacro("failed after RenderClippedBoundingBox"); - return abort; -} - -// ---------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::CopyFBOToTexture() -{ - vtkOpenGLClearErrorMacro(); - // in OpenGL copy texture to texture does not exist but - // framebuffer to texture exists (and our FB is an FBO). - // we have to copy and not just to switch color textures because the - // colorbuffer has to accumulate color or values step after step. - // Switching would not work because two different steps can draw different - // polygons that don't overlap - vtkgl::ActiveTexture(vtkgl::TEXTURE4); - glBindTexture( - GL_TEXTURE_2D, - this->TextureObjects[ - vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+1]); - - glReadBuffer(vtkgl::COLOR_ATTACHMENT0_EXT); - glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,this->ReducedSize[0], - this->ReducedSize[1]); - if(this->BlendMode==vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND - || this->BlendMode==vtkGPUVolumeRayCastMapper::MINIMUM_INTENSITY_BLEND - || this->BlendMode==vtkGPUVolumeRayCastMapper::ADDITIVE_BLEND) - { - vtkgl::ActiveTexture(vtkgl::TEXTURE5); - glBindTexture(GL_TEXTURE_2D,this->MaxValueFrameBuffer2); - glReadBuffer(vtkgl::COLOR_ATTACHMENT0_EXT+1); - glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,this->ReducedSize[0], - this->ReducedSize[1]); - } - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - // reset the readbuffer to keep os mesa happy - // during CheckFrameBufferStatus - glReadBuffer(vtkgl::COLOR_ATTACHMENT0_EXT); - vtkOpenGLCheckErrorMacro("failed after CopyFBOToTexture"); -} - -//----------------------------------------------------------------------------- -// Restore OpenGL state after rendering of the dataset. -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::CleanupRender() -{ - glPopMatrix(); - glDisable(GL_CULL_FACE); - vtkOpenGLCheckErrorMacro("failed after CleanupRender"); -} - -//----------------------------------------------------------------------------- -// Build the fragment shader program that scale and bias a texture -// for window/level purpose. -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::BuildScaleBiasProgram(vtkRenderWindow *w) -{ - if(this->ScaleBiasProgram==0) - { - this->ScaleBiasProgram=vtkShaderProgram2::New(); - this->ScaleBiasProgram->SetContext( - static_cast(w)); - vtkShader2Collection *shaders=this->ScaleBiasProgram->GetShaders(); - - vtkShader2 *s=vtkShader2::New(); - s->SetType(VTK_SHADER_TYPE_FRAGMENT); - s->SetSourceCode(vtkGPUVolumeRayCastMapper_ScaleBiasFS); - shaders->AddItem(s); - s->Delete(); - } -} - -//----------------------------------------------------------------------------- -// Render the offscreen buffer to the screen. -// \pre ren_exists: ren!=0 -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::RenderTextureToScreen(vtkRenderer *ren) -{ - assert("pre: ren_exists" && ren!=0); - - vtkOpenGLClearErrorMacro(); - - if ( this->GeneratingCanonicalView ) - { - // We just need to copy of the data, not render it - glBindTexture(GL_TEXTURE_2D, - this->TextureObjects[ - vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront]); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); - glPixelStorei( GL_PACK_ALIGNMENT, 1 ); - - unsigned char *outPtr = static_cast(this->CanonicalViewImageData->GetScalarPointer()); - glGetTexImage( GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, outPtr ); - return; - } - - int lowerLeft[2]; - int usize, vsize; - ren->GetTiledSizeAndOrigin(&usize,&vsize,lowerLeft,lowerLeft+1); - glViewport(lowerLeft[0],lowerLeft[1], usize, vsize); - glEnable( GL_SCISSOR_TEST ); - glScissor(lowerLeft[0],lowerLeft[1], usize, vsize); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(0.0, usize, 0.0, vsize, -1.0, 1.0 ); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - glBindTexture(GL_TEXTURE_2D, - this->TextureObjects[vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront]); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - glEnable(GL_BLEND); - glBlendFunc( GL_ONE,GL_ONE_MINUS_SRC_ALPHA); - - // As we use replace mode, we don't need to set the color value. - - glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE); - - glDisable(GL_DEPTH_TEST); - - double xOffset = 1.0 / usize; - double yOffset = 1.0 / vsize; - - glDepthMask(GL_FALSE); - - double scale=1.0/this->FinalColorWindow; - double bias=0.5-this->FinalColorLevel/this->FinalColorWindow; - - if(scale!=1.0 || bias!=0.0) - { - this->BuildScaleBiasProgram(ren->GetRenderWindow()); - vtkUniformVariables *v=this->ScaleBiasProgram->GetUniformVariables(); - int ivalue=0; - v->SetUniformi("frameBufferTexture",1,&ivalue); - float fvalue=static_cast(scale); - v->SetUniformf("scale",1,&fvalue); - fvalue=static_cast(bias); - v->SetUniformf("bias",1,&fvalue); - this->ScaleBiasProgram->Use(); - } - else - { - glEnable(GL_TEXTURE_2D); // fixed pipeline - } - - glBegin(GL_QUADS); - glTexCoord2f(static_cast(xOffset),static_cast(yOffset)); - glVertex2f(0.0,0.0); - glTexCoord2f(static_cast(this->ReductionFactor-xOffset), - static_cast(yOffset)); - glVertex2f(static_cast(usize),0.0); - glTexCoord2f(static_cast(this->ReductionFactor-xOffset), - static_cast(this->ReductionFactor-yOffset)); - glVertex2f(static_cast(usize),static_cast(vsize)); - glTexCoord2f(static_cast(xOffset), - static_cast(this->ReductionFactor-yOffset)); - glVertex2f(0.0,static_cast(vsize)); - glEnd(); - - // Restore the default mode. Used in overlay. - glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); - - if(scale!=1.0 || bias!=0.0) - { - this->ScaleBiasProgram->Restore(); - } - else - { - glDisable(GL_TEXTURE_2D); - } - - glDepthMask(GL_TRUE); - - glDisable(GL_BLEND); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - - vtkOpenGLCheckErrorMacro("failed after RenderTextureToScreen"); -} - -//----------------------------------------------------------------------------- -// Update the reduction factor of the render viewport (this->ReductionFactor) -// according to the time spent in seconds to render the previous frame -// (this->TimeToDraw) and a time in seconds allocated to render the next -// frame (allocatedTime). -// \pre valid_current_reduction_range: this->ReductionFactor>0.0 && this->ReductionFactor<=1.0 -// \pre positive_TimeToDraw: this->TimeToDraw>=0.0 -// \pre positive_time: allocatedTime>0.0 -// \post valid_new_reduction_range: this->ReductionFactor>0.0 && this->ReductionFactor<=1.0 -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::ComputeReductionFactor( - double allocatedTime) -{ - assert("pre: valid_current_reduction_range" && this->ReductionFactor>0.0 - && this->ReductionFactor<=1.0); - assert("pre: positive_TimeToDraw" && this->TimeToDraw>=0.0); - assert("pre: positive_time" && allocatedTime>0.0); - - if ( this->GeneratingCanonicalView ) - { - this->ReductionFactor = 1.0; - return; - } - - if ( !this->AutoAdjustSampleDistances ) - { - this->ReductionFactor = 1.0 / this->ImageSampleDistance; - return; - } - - if ( this->TimeToDraw ) - { - double oldFactor = this->ReductionFactor; - - double timeToDraw; - if (allocatedTime < 1.0) - { - timeToDraw = this->SmallTimeToDraw; - if ( timeToDraw == 0.0 ) - { - timeToDraw = this->BigTimeToDraw/3.0; - } - } - else - { - timeToDraw = this->BigTimeToDraw; - } - - if ( timeToDraw == 0.0 ) - { - timeToDraw = 10.0; - } - - double fullTime = timeToDraw / this->ReductionFactor; - double newFactor = allocatedTime / fullTime; - - if ( oldFactor == 1.0 || - newFactor / oldFactor > 1.3 || - newFactor / oldFactor < .95 ) - { - - this->ReductionFactor = (newFactor+oldFactor)/2.0; - - this->ReductionFactor = (this->ReductionFactor > 5.0)?(1.00):(this->ReductionFactor); - this->ReductionFactor = (this->ReductionFactor > 1.0)?(0.99):(this->ReductionFactor); - this->ReductionFactor = (this->ReductionFactor < 0.1)?(0.10):(this->ReductionFactor); - - if ( 1.0/this->ReductionFactor > this->MaximumImageSampleDistance ) - { - this->ReductionFactor = 1.0 / this->MaximumImageSampleDistance; - } - if ( 1.0/this->ReductionFactor < this->MinimumImageSampleDistance ) - { - this->ReductionFactor = 1.0 / this->MinimumImageSampleDistance; - } - } - } - else - { - this->ReductionFactor = 1.0; - } - - assert("post: valid_new_reduction_range" && this->ReductionFactor>0.0 - && this->ReductionFactor<=1.0); -} - -//----------------------------------------------------------------------------- -// Rendering initialization including making the context current, loading -// necessary extensions, allocating frame buffers, updating transfer function, -// computing clipping regions, and building the fragment shader. -// -// Pre-conditions: -// - ren != NULL -// - vol != NULL -// - ren->GetRenderWindow() != NULL -// - 1 <= numberOfScalarComponents <= 4 -// - numberOfLevels >= 1 -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::PreRender(vtkRenderer *ren, - vtkVolume *vol, - double datasetBounds[6], - double scalarRange[2], - int numberOfScalarComponents, - unsigned int numberOfLevels) -{ - // make sure our window is the current OpenGL context. - ren->GetRenderWindow()->MakeCurrent(); - vtkOpenGLClearErrorMacro(); - - // If we haven't already succeeded in loading the extensions, - // try to load them - if(!this->LoadExtensionsSucceeded) - { - this->LoadExtensions(ren->GetRenderWindow()); - } - - // If we can't load the necessary extensions, provide - // feedback on why it failed. - if(!this->LoadExtensionsSucceeded) - { - vtkErrorMacro( - "Rendering failed because the following OpenGL extensions " - "are required but not supported: " << - (this->UnsupportedRequiredExtensions->Stream.str()).c_str()); - return; - } - - // Create the OpenGL object that we need - this->CreateOpenGLObjects(ren); - - // Compute the reduction factor that may be necessary to get - // the interactive rendering rate that we want - this->ComputeReductionFactor(vol->GetAllocatedRenderTime()); - - // Allocate the frame buffers - if(!this->AllocateFrameBuffers(ren)) - { - vtkErrorMacro("Not enough GPU memory to create a framebuffer."); - return; - } - - // Save the scalar range - this is what we will use for the range - // of the transfer functions - this->TableRange[0]=scalarRange[0]; - this->TableRange[1]=scalarRange[1]; - - - if(this->RGBTable == NULL) - { - this->RGBTable = vtkRGBTable::New(); - } - - if (this->MaskInput != NULL && this->MaskType == LabelMapMaskType) - { - if(this->Mask1RGBTable == NULL) - { - this->Mask1RGBTable = vtkRGBTable::New(); - } - if(this->Mask2RGBTable == NULL) - { - this->Mask2RGBTable = vtkRGBTable::New(); - } - } - - // Update the color transfer function - this->UpdateColorTransferFunction(vol,numberOfScalarComponents); - - // Update the noise texture that will be used to jitter rays to - // reduce alliasing artifacts - this->UpdateNoiseTexture(); - - // We are going to change the blending mode and blending function - - // so lets push here so we can pop later - glPushAttrib(GL_COLOR_BUFFER_BIT); - - // If this is the canonical view - we don't want to intermix so we'll just - // start by clearing the z buffer. - if ( this->GeneratingCanonicalView ) - { - glClearColor(0.0, 0.0, 0.0, 0.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - } - - // See if the volume transform is orientation-preserving - vtkMatrix4x4 *m=vol->GetMatrix(); - double det=vtkMath::Determinant3x3( - m->GetElement(0,0),m->GetElement(0,1),m->GetElement(0,2), - m->GetElement(1,0),m->GetElement(1,1),m->GetElement(1,2), - m->GetElement(2,0),m->GetElement(2,1),m->GetElement(2,2)); - - this->PreserveOrientation=det>0; - - // If we have clipping planes, render the back faces of the clipped - // bounding box of the whole dataset to set the zbuffer. - if(this->ClippingPlanes && this->ClippingPlanes->GetNumberOfItems()!=0) - { - // push the model view matrix onto the stack, make sure we - // adjust the mode first - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - this->TempMatrix[0]->DeepCopy(vol->GetMatrix()); - this->TempMatrix[0]->Transpose(); - glMultMatrixd(this->TempMatrix[0]->Element[0]); - this->ClipBoundingBox(ren,datasetBounds,vol); - glEnable (GL_CULL_FACE); - glCullFace (GL_FRONT); - glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); - glDisable(GL_ALPHA_TEST); - this->RenderClippedBoundingBox(0,0,1,ren->GetRenderWindow()); - glDisable (GL_CULL_FACE); - glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); - //glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - } - // Check if everything is OK - this->CheckFrameBufferStatus(); - - // Intermixed geometry: Grab the depth buffer into a texture - - int size[2]; - int lowerLeft[2]; - ren->GetTiledSizeAndOrigin(size,size+1,lowerLeft,lowerLeft+1); - - vtkgl::ActiveTexture(vtkgl::TEXTURE3); - glBindTexture(GL_TEXTURE_2D, - static_cast( - this->TextureObjects[ - vtkOpenGLGPUVolumeRayCastMapperTextureObjectDepthMap])); - glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,lowerLeft[0],lowerLeft[1],size[0], - size[1]); - - - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - - int parallelProjection=ren->GetActiveCamera()->GetParallelProjection(); - - // initialize variables to prevent compiler warnings. - int rayCastMethod=vtkOpenGLGPUVolumeRayCastMapperMethodMIP; - int shadeMethod=vtkOpenGLGPUVolumeRayCastMapperShadeNotUsed; - int componentMethod=vtkOpenGLGPUVolumeRayCastMapperComponentNotUsed; - - if(this->GetBlendMode()!=vtkVolumeMapper::COMPOSITE_BLEND && - this->GetBlendMode()!=vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND && - this->GetBlendMode()!=vtkVolumeMapper::MINIMUM_INTENSITY_BLEND && - this->GetBlendMode()!=vtkVolumeMapper::ADDITIVE_BLEND) - { - vtkErrorMacro(<< "Selected blend mode not supported. " - << "Only Composite, MIP, MinIP and additive modes " - << "are supported by this implementation."); - return; - } - - switch(this->BlendMode) - { - case vtkVolumeMapper::COMPOSITE_BLEND: - switch(numberOfScalarComponents) - { - case 1: - componentMethod=vtkOpenGLGPUVolumeRayCastMapperComponentOne; - break; - case 4: - componentMethod=vtkOpenGLGPUVolumeRayCastMapperComponentFour; - break; - default: - assert("check: impossible case" && false); - break; - } - - // If we are using a mask to limit the volume rendering to or blend using a - // label map mask.. - rayCastMethod = this->MaskInput ? - (this->MaskType == vtkGPUVolumeRayCastMapper::BinaryMaskType ? - vtkOpenGLGPUVolumeRayCastMapperMethodCompositeBinaryMask : - vtkOpenGLGPUVolumeRayCastMapperMethodCompositeMask) : - vtkOpenGLGPUVolumeRayCastMapperMethodComposite; - - if ( vol->GetProperty()->GetShade() ) - { - shadeMethod=vtkOpenGLGPUVolumeRayCastMapperShadeYes; - } - else - { - shadeMethod=vtkOpenGLGPUVolumeRayCastMapperShadeNo; - //cout<<"program is composite"<MaskInput && this->MaskType == - vtkGPUVolumeRayCastMapper::BinaryMaskType) ? - vtkOpenGLGPUVolumeRayCastMapperMethodMIPBinaryMask : - vtkOpenGLGPUVolumeRayCastMapperMethodMIP; - break; - case 4: - rayCastMethod= - vtkOpenGLGPUVolumeRayCastMapperMethodMIPFourDependent; - break; - default: - assert("check: impossible case" && false); - break; - } - break; - case vtkGPUVolumeRayCastMapper::MINIMUM_INTENSITY_BLEND: - shadeMethod=vtkOpenGLGPUVolumeRayCastMapperShadeNotUsed; - componentMethod=vtkOpenGLGPUVolumeRayCastMapperComponentNotUsed; - switch(numberOfScalarComponents) - { - case 1: - rayCastMethod= (this->MaskInput && this->MaskType == - vtkGPUVolumeRayCastMapper::BinaryMaskType) ? - vtkOpenGLGPUVolumeRayCastMapperMethodMinIPBinaryMask : - vtkOpenGLGPUVolumeRayCastMapperMethodMinIP; - break; - case 4: - rayCastMethod= - vtkOpenGLGPUVolumeRayCastMapperMethodMinIPFourDependent; - break; - default: - assert("check: impossible case" && false); - break; - } - break; - case vtkGPUVolumeRayCastMapper::ADDITIVE_BLEND: - shadeMethod=vtkOpenGLGPUVolumeRayCastMapperShadeNotUsed; - componentMethod=vtkOpenGLGPUVolumeRayCastMapperComponentNotUsed; - switch(numberOfScalarComponents) - { - case 1: - rayCastMethod=vtkOpenGLGPUVolumeRayCastMapperMethodAdditive; - break; - default: - assert("check: impossible case" && false); - break; - } - break; - default: - assert("check: impossible case" && 0); - rayCastMethod=0; - break; - } - - this->ComputeNumberOfCroppingRegions(); // TODO AMR vs single block - if(this->AMRMode) - { - NumberOfCroppingRegions=2; // >1, means use do compositing between blocks - } - this->BuildProgram(ren->GetRenderWindow(), - parallelProjection,rayCastMethod,shadeMethod, - componentMethod); - - vtkUniformVariables *v=this->Program->GetUniformVariables(); - - // for active texture 0, dataset - - if(numberOfScalarComponents==1) - { - // colortable - vtkgl::ActiveTexture(vtkgl::TEXTURE1); - this->RGBTable->Bind(); - - if (this->MaskInput != 0 && this->MaskType == LabelMapMaskType) - { - vtkgl::ActiveTexture(vtkgl::TEXTURE8); - this->Mask1RGBTable->Bind(); - vtkgl::ActiveTexture(vtkgl::TEXTURE9); - this->Mask2RGBTable->Bind(); - } - } - - float fvalue[2]; - int ivalue=0; - v->SetUniformi("dataSetTexture",1,&ivalue); - - if(this->MaskInput!=0) - { - // Make the mask texture available on texture unit 7 - ivalue=7; - v->SetUniformi("maskTexture",1,&ivalue); - } - - if(numberOfScalarComponents==1 && - this->BlendMode!=vtkGPUVolumeRayCastMapper::ADDITIVE_BLEND) - { - ivalue=1; - v->SetUniformi("colorTexture",1,&ivalue); - - if (this->MaskInput != 0 && this->MaskType == LabelMapMaskType) - { - ivalue=8; - v->SetUniformi("mask1ColorTexture",1,&ivalue); - - ivalue=9; - v->SetUniformi("mask2ColorTexture",1,&ivalue); - - fvalue[0]=static_cast(this->MaskBlendFactor); - v->SetUniformf("maskBlendFactor",1,fvalue); - } - - } - - ivalue=2; - v->SetUniformi("opacityTexture",1,&ivalue); - - // depthtexture - vtkgl::ActiveTexture(vtkgl::TEXTURE3); - glBindTexture(GL_TEXTURE_2D,static_cast(this->TextureObjects[vtkOpenGLGPUVolumeRayCastMapperTextureObjectDepthMap])); - - ivalue=3; - v->SetUniformi("depthTexture",1,&ivalue); - - // noise texture - vtkgl::ActiveTexture(vtkgl::TEXTURE6); - glBindTexture(GL_TEXTURE_2D,static_cast(this->NoiseTextureId)); - - ivalue=6; - v->SetUniformi("noiseTexture",1,&ivalue); - - this->CheckFrameBufferStatus(); - - if(this->NumberOfCroppingRegions>1) - { - // framebuffer texture - if(rayCastMethod!=vtkOpenGLGPUVolumeRayCastMapperMethodMIP - && rayCastMethod!=vtkOpenGLGPUVolumeRayCastMapperMethodMinIP - && rayCastMethod!=vtkOpenGLGPUVolumeRayCastMapperMethodAdditive) - { - vtkgl::ActiveTexture(vtkgl::TEXTURE4); - glBindTexture(GL_TEXTURE_2D,static_cast(this->TextureObjects[vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront])); - - ivalue=4; - v->SetUniformi("frameBufferTexture",1,&ivalue); - } - this->CheckFrameBufferStatus(); - - // max scalar value framebuffer texture - if(this->BlendMode==vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND - || this->BlendMode==vtkGPUVolumeRayCastMapper::MINIMUM_INTENSITY_BLEND - || this->BlendMode==vtkGPUVolumeRayCastMapper::ADDITIVE_BLEND) - { - vtkgl::ActiveTexture(vtkgl::TEXTURE5); - glBindTexture(GL_TEXTURE_2D,static_cast(this->MaxValueFrameBuffer2)); - - ivalue=5; - v->SetUniformi("scalarBufferTexture",1,&ivalue); - } - } - - this->CheckFrameBufferStatus(); - - fvalue[0]=static_cast(lowerLeft[0]); - fvalue[1]=static_cast(lowerLeft[1]); - v->SetUniformf("windowLowerLeftCorner",2,fvalue); - - fvalue[0]=static_cast(1.0/size[0]); - fvalue[1]=static_cast(1.0/size[1]); - v->SetUniformf("invOriginalWindowSize",2,fvalue); - - size[0] = static_cast(size[0]*this->ReductionFactor); - size[1] = static_cast(size[1]*this->ReductionFactor); - - fvalue[0]=static_cast(1.0/size[0]); - fvalue[1]=static_cast(1.0/size[1]); - v->SetUniformf("invWindowSize",2,fvalue); - vtkOpenGLCheckErrorMacro("after uniforms for textures"); - - - this->CheckFrameBufferStatus(); - - GLint savedFrameBuffer; - glGetIntegerv(vtkgl::FRAMEBUFFER_BINDING_EXT,&savedFrameBuffer); - this->SavedFrameBuffer=static_cast(savedFrameBuffer); - - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT, - static_cast(this->FrameBufferObject)); - - GLenum buffer[4]; - buffer[0] = vtkgl::COLOR_ATTACHMENT0_EXT; - if(this->NumberOfCroppingRegions>1 && - this->BlendMode==vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND) - { - // max scalar frame buffer - buffer[1] = vtkgl::COLOR_ATTACHMENT1_EXT; - } - else - { - buffer[1] = GL_NONE; - } - - vtkgl::DrawBuffers(2,buffer); - - this->CheckFrameBufferStatus(); - - // Use by the composite+shade program - double shininess=vol->GetProperty()->GetSpecularPower(); - if(shininess>128.0) - { - shininess=128.0; // upper limit for the OpenGL shininess. - } - glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,static_cast(shininess)); - - glDisable(GL_COLOR_MATERIAL); // other mapper may have enable that. - - GLfloat values[4]; - values[3]=1.0; - - values[0]=0.0; - values[1]=values[0]; - values[2]=values[0]; - glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,values); - - values[0]=static_cast(vol->GetProperty()->GetAmbient()); - values[1]=values[0]; - values[2]=values[0]; - glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,values); - - values[0]=static_cast(vol->GetProperty()->GetDiffuse()); - values[1]=values[0]; - values[2]=values[0]; - glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,values); - values[0]=static_cast(vol->GetProperty()->GetSpecular()); - values[1]=values[0]; - values[2]=values[0]; - glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,values); - -// cout << "pingpong=" << this->PingPongFlag << endl; - - // To initialize the second color buffer - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT, - GL_TEXTURE_2D, - this->TextureObjects[vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront], - 0); - - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT+1, - GL_TEXTURE_2D, - this->TextureObjects[vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+1], - 0); - buffer[0] = vtkgl::COLOR_ATTACHMENT0_EXT; - buffer[1] = vtkgl::COLOR_ATTACHMENT1_EXT; - vtkgl::DrawBuffers(2,buffer); - -// cout << "check before setup" << endl; - this->CheckFrameBufferStatus(); - this->SetupRender(ren,vol); - - // restore in case of composite with no cropping or streaming. - buffer[0] = vtkgl::COLOR_ATTACHMENT0_EXT; - buffer[1] = GL_NONE; - vtkgl::DrawBuffers(2,buffer); - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT+1, - GL_TEXTURE_2D,0,0); -// cout << "check after color init" << endl; - this->CheckFrameBufferStatus(); - - if(this->NumberOfCroppingRegions>1 && - (this->BlendMode==vtkGPUVolumeRayCastMapper::MINIMUM_INTENSITY_BLEND - || this->BlendMode==vtkGPUVolumeRayCastMapper::MAXIMUM_INTENSITY_BLEND - || this->BlendMode==vtkGPUVolumeRayCastMapper::ADDITIVE_BLEND)) - { -// cout << "this->MaxValueFrameBuffer="<< this->MaxValueFrameBuffer <MaxValueFrameBuffer2="<< this->MaxValueFrameBuffer2 <MaxValueFrameBuffer,0); - - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT+1, - GL_TEXTURE_2D, - this->MaxValueFrameBuffer2,0); - - buffer[0] = vtkgl::COLOR_ATTACHMENT0_EXT; - buffer[1] = vtkgl::COLOR_ATTACHMENT1_EXT; - vtkgl::DrawBuffers(2,buffer); - - if(this->BlendMode==vtkGPUVolumeRayCastMapper::MINIMUM_INTENSITY_BLEND) - { - glClearColor(1.0, 0.0, 0.0, 0.0); - } - else - { - // for MAXIMUM_INTENSITY_BLEND and for ADDITIVE_BLEND - glClearColor(0.0, 0.0, 0.0, 0.0); - } -// cout << "check before clear on max" << endl; - this->CheckFrameBufferStatus(); - glClear(GL_COLOR_BUFFER_BIT); - } - - if(this->NumberOfCroppingRegions>1) - { - // color buffer target in the color attachement 0 - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT, - GL_TEXTURE_2D, - this->TextureObjects[vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront], - 0); - - // color buffer input is on texture unit 4. - vtkgl::ActiveTexture(vtkgl::TEXTURE4); - glBindTexture(GL_TEXTURE_2D,this->TextureObjects[vtkOpenGLGPUVolumeRayCastMapperTextureObjectFrameBufferLeftFront+1]); - - if(this->BlendMode==vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND - || this->BlendMode==vtkGPUVolumeRayCastMapper::MINIMUM_INTENSITY_BLEND - || this->BlendMode==vtkGPUVolumeRayCastMapper::ADDITIVE_BLEND ) - { - // max buffer target in the color attachment 1 - vtkgl::FramebufferTexture2DEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT+1, - GL_TEXTURE_2D, - this->MaxValueFrameBuffer,0); - - // max buffer input is on texture unit 5. - vtkgl::ActiveTexture(vtkgl::TEXTURE5); - glBindTexture(GL_TEXTURE_2D,this->MaxValueFrameBuffer2); - } - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - } - - this->CheckFrameBufferStatus(); - - if(this->OpacityTables!=0 && - this->OpacityTables->GetNumberOfTables()!=numberOfLevels) - { - delete this->OpacityTables; - this->OpacityTables=0; - } - if(this->OpacityTables==0) - { - this->OpacityTables=new vtkOpacityTables(numberOfLevels); - } - - this->Program->Use(); - - // debug code - // DO NOT REMOVE the following commented line - if(!this->Program->IsValid()) - { - vtkErrorMacro(<Program->GetLastValidateLog()); -// this->Program->PrintActiveUniformVariablesOnCout(); - } - - glCullFace (GL_BACK); - // otherwise, we are rendering back face to initialize the zbuffer. - - - if(!this->GeneratingCanonicalView && this->ReportProgress) - { - // initialize the time to avoid a progress event at the beginning. - this->LastProgressEventTime=vtkTimerLog::GetUniversalTime(); - } - - vtkOpenGLCheckErrorMacro("failed after PreRender"); -} - -//----------------------------------------------------------------------------- -// Compute how each axis of a cell is projected on the viewport in pixel. -// This requires to have information about the camera and about the volume. -// It set the value of IgnoreSampleDistancePerPixel to true in case of -// degenerated case (axes aligned with the view). -//----------------------------------------------------------------------------- -double vtkOpenGLGPUVolumeRayCastMapper::ComputeMinimalSampleDistancePerPixel( - vtkRenderer *renderer, - vtkVolume *volume) -{ - // For each of the 3 directions of a cell, compute the step in z - // (world coordinate, not eye/camera coordinate) - // to go to the next pixel in x. - // Same for the next pixel in y. - // Keep the minimum of both zstep - // Then keep the minimum for the 3 directions. - - // in case of either the numerator or the denominator of each ratio is 0. - this->IgnoreSampleDistancePerPixel=true; - double result=0.0; - - vtkMatrix4x4* worldToDataset=volume->GetMatrix(); - vtkCamera* camera=renderer->GetActiveCamera(); - vtkMatrix4x4* eyeToWorld=camera->GetViewTransformMatrix(); - vtkMatrix4x4* eyeToDataset=vtkMatrix4x4::New(); - vtkMatrix4x4::Multiply4x4(eyeToWorld,worldToDataset,eyeToDataset); - - int usize; - int vsize; - renderer->GetTiledSize(&usize,&vsize); - vtkMatrix4x4* viewportToEye = camera->GetProjectionTransformMatrix( - usize/static_cast(vsize),0.0,1.0); - - double volBounds[6]; - this->GetInput()->GetBounds(volBounds); - int dims[3]; - this->GetInput()->GetDimensions(dims); - - double v0[4]; - v0[0]=volBounds[0]; - v0[1]=volBounds[2]; - v0[2]=volBounds[4]; - v0[3]=1.0; - - double w0[4]; - eyeToDataset->MultiplyPoint(v0,w0); - - double z0; - if(w0[3] != 0.0) - { - z0 = w0[2] / w0[3]; - } - else - { - z0 = 0.0; - vtkGenericWarningMacro( "eyeToWorld transformation has some projective component." ); - } - - double p0[4]; - viewportToEye->MultiplyPoint(w0,p0); - p0[0]/=p0[3]; - p0[1]/=p0[3]; - p0[2]/=p0[3]; - - bool inFrustum=p0[0]>=-1.0 && p0[0]<=1.0 && p0[1]>=-1.0 && p0[1]<=1.0 && p0[2]>=-1.0 && p0[2]<=1.0; - - if(inFrustum) - { - int dim=0; - while(dim<3) - { - double v1[4]; - int coord=0; - while(coord<3) - { - if(coord==dim) - { - v1[coord]=volBounds[2*coord+1]; - } - else - { - v1[coord]=volBounds[2*coord]; // same as v0[coord]; - } - ++coord; - } - v1[3]=1.0; - - double w1[4]; - eyeToDataset->MultiplyPoint(v1,w1); - double z1; - - if(w1[3]!=0.0) - { - z1=w1[2]/w1[3]; - } - else - { - z1=0.0; - vtkGenericWarningMacro( "eyeToWorld transformation has some projective component." ); - } - - - double p1[4]; - viewportToEye->MultiplyPoint(w1,p1); - p1[0]/=p1[3]; - p1[1]/=p1[3]; - p1[2]/=p1[3]; - - inFrustum=p1[0]>=-1.0 && p1[0]<=1.0 && p1[1]>=-1.0 && p1[1]<=1.0 && p1[2]>=-1.0 && p1[2]<=1.0; - - if(inFrustum) - { - double dx=fabs(p1[0]-p0[0]); - double dy=fabs(p1[1]-p0[1]); - double dz=fabs(z1-z0); - dz=dz/(dims[dim]-1); - dx=dx/(dims[dim]-1)*usize; - dy=dy/(dims[dim]-1)*vsize; - - if(dz!=0.0) - { - if(dx!=0.0) - { - double d=dz/dx; - if(!this->IgnoreSampleDistancePerPixel) - { - if(result>d) - { - result=d; - } - } - else - { - this->IgnoreSampleDistancePerPixel=false; - result=d; - } - } - - if(dy!=0.0) - { - double d=dz/dy; - if(!this->IgnoreSampleDistancePerPixel) - { - if(result>d) - { - result=d; - } - } - else - { - this->IgnoreSampleDistancePerPixel=false; - result=d; - } - } - - } - } - ++dim; - } - } - - eyeToDataset->Delete(); - - if(this->IgnoreSampleDistancePerPixel) - { - // cout<<"ignore SampleDistancePerPixel"<ValidateProgram(); - - if(!this->Cropping) - { - this->RenderWholeVolume(ren,vol); - } - else - { - this->ClipCroppingRegionPlanes(); - this->RenderRegions(ren,vol); - } - vtkOpenGLCheckErrorMacro("after render"); -} - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::PostRender( - vtkRenderer *ren, - int numberOfScalarComponents) -{ - vtkOpenGLClearErrorMacro(); - if(this->NumberOfCroppingRegions>1) - { - if(this->BlendMode==vtkVolumeMapper::MAXIMUM_INTENSITY_BLEND - || this->BlendMode==vtkGPUVolumeRayCastMapper::MINIMUM_INTENSITY_BLEND - || this->BlendMode==vtkGPUVolumeRayCastMapper::ADDITIVE_BLEND) - { - vtkgl::ActiveTexture( vtkgl::TEXTURE5 ); - glBindTexture(GL_TEXTURE_2D,0); - } - - if(this->LastRayCastMethod!=vtkOpenGLGPUVolumeRayCastMapperMethodMIP - && this->LastRayCastMethod!=vtkOpenGLGPUVolumeRayCastMapperMethodMinIP - && this->LastRayCastMethod!=vtkOpenGLGPUVolumeRayCastMapperMethodAdditive) - { - vtkgl::ActiveTexture( vtkgl::TEXTURE4 ); - glBindTexture(GL_TEXTURE_2D,0); - } - } - - // noisetexture - vtkgl::ActiveTexture(vtkgl::TEXTURE6); - glBindTexture(GL_TEXTURE_2D,0); - - // depthtexture - vtkgl::ActiveTexture(vtkgl::TEXTURE3); - glBindTexture(GL_TEXTURE_2D,0); - - // opacity - vtkgl::ActiveTexture(vtkgl::TEXTURE2); - glBindTexture(GL_TEXTURE_1D,0); - - if(numberOfScalarComponents==1) - { - vtkgl::ActiveTexture(vtkgl::TEXTURE1); - glBindTexture(GL_TEXTURE_1D,0); - } - - - // mask, if any - if(this->MaskInput!=0) - { - vtkgl::ActiveTexture(vtkgl::TEXTURE7); - glBindTexture(vtkgl::TEXTURE_3D_EXT,0); - } - - // back to active texture 0. - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - glBindTexture(vtkgl::TEXTURE_3D_EXT,0); - - this->Program->Restore(); - - this->CleanupRender(); - - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT, - static_cast(this->SavedFrameBuffer)); - this->SavedFrameBuffer=0; - - // Undo the viewport change we made to reduce resolution - int size[2]; - int lowerLeft[2]; - ren->GetTiledSizeAndOrigin(size,size+1,lowerLeft,lowerLeft+1); - glViewport(lowerLeft[0],lowerLeft[1], size[0], size[1]); - glEnable( GL_SCISSOR_TEST ); - glScissor(lowerLeft[0],lowerLeft[1], size[0], size[1]); - - // Render the texture to the screen - this copies the offscreen buffer - // onto the screen as a texture mapped polygon - this->RenderTextureToScreen(ren); - - glEnable(GL_DEPTH_TEST); - - glPopAttrib(); // restore the blending mode and function - - glFinish(); - - vtkOpenGLCheckErrorMacro("failed after PostRender"); -} - -//----------------------------------------------------------------------------- -// The main render method called from the superclass -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::GPURender(vtkRenderer *ren, - vtkVolume *vol) -{ - // We've already checked that we have input - vtkImageData *input = this->GetTransformedInput(); - - // Get the bounds of this data - double bounds[6]; - this->GetBounds(bounds); - - // Get the scalar range. First we have to get the scalars. - double range[2]; - vtkDataArray *scalars=this->GetScalars(input,this->ScalarMode, - this->ArrayAccessMode, - this->ArrayId,this->ArrayName, - this->CellFlag); - - // How many components are there? - int numberOfScalarComponents=scalars->GetNumberOfComponents(); - - // If it is just one, then get the range from the scalars - if(numberOfScalarComponents==1) - { - // Warning: here, we ignore the blank cells. - scalars->GetRange(range); - } - // If it is 3, then use the 4th component's range since that is - // the component that will be passed through the scalar opacity - // transfer function to look up opacity - else - { - // Note that we've already checked data type and we know this is - // unsigned char - scalars->GetRange(range,3); - } - - // The rendering work has been broken into 3 stages to support AMR - // volume rendering in blocks. Here we are simply rendering the - // whole volume as one block. Note that if the volume is too big - // to fix into texture memory, it will be streamed through in the - // RenderBlock method. - - this->PreRender(ren,vol,bounds,range,numberOfScalarComponents,1); - if(this->LoadExtensionsSucceeded) - { - this->RenderBlock(ren,vol,0); - this->PostRender(ren,numberOfScalarComponents); - } - - // If this isn't a canonical view render, then update the progress to - // 1 because we are done. - if (!this->GeneratingCanonicalView ) - { - double progress=1.0; - this->InvokeEvent(vtkCommand::VolumeMapperRenderProgressEvent,&progress); - ren->GetRenderWindow()->MakeCurrent(); - } -} - - -//----------------------------------------------------------------------------- -// Render a the whole volume. -// \pre this->ProgramShader!=0 and is linked. -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::RenderWholeVolume(vtkRenderer *ren, - vtkVolume *vol) -{ - double volBounds[6]; - this->GetTransformedInput()->GetBounds(volBounds); - this->RenderSubVolume(ren,volBounds,vol); -} - - -//----------------------------------------------------------------------------- -// Sort regions from front to back. -//----------------------------------------------------------------------------- -class vtkRegionDistance2 -{ -public: - size_t Id; // 0<=Id<27 - // square distance between camera center to region center: >=0 - double Distance2; -}; - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -extern "C" int vtkRegionComparisonFunction(const void *x, - const void *y) -{ - double dx=static_cast(x)->Distance2; - double dy=static_cast(y)->Distance2; - - int result; - if(dxdy) - { - result=1; - } - else - { - result=0; - } - } - return result; -} - -//----------------------------------------------------------------------------- -// Render a subvolume. -// \pre this->ProgramShader!=0 and is linked. -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::RenderRegions(vtkRenderer *ren, - vtkVolume *vol) -{ - double bounds[27][6]; - double distance2[27]; - - double camPos[4]; - ren->GetActiveCamera()->GetPosition(camPos); - - double volBounds[6]; - this->GetInput()->GetBounds(volBounds); - - - // Pass camera through inverse volume matrix - // so that we are in the same coordinate system - vol->GetMatrix( this->InvVolumeMatrix ); - camPos[3] = 1.0; - this->InvVolumeMatrix->Invert(); - this->InvVolumeMatrix->MultiplyPoint( camPos, camPos ); - if ( camPos[3] ) - { - camPos[0] /= camPos[3]; - camPos[1] /= camPos[3]; - camPos[2] /= camPos[3]; - } - - // These are the region limits for x (first four), y (next four) and - // z (last four). The first region limit is the lower bound for - // that axis, the next two are the region planes along that axis, and - // the final one in the upper bound for that axis. - double limit[12]; - size_t i; - for ( i = 0; i < 3; i++ ) - { - limit[i*4 ] = volBounds[i*2]; - limit[i*4+1] = this->ClippedCroppingRegionPlanes[i*2]; - limit[i*4+2] = this->ClippedCroppingRegionPlanes[i*2+1]; - limit[i*4+3] = volBounds[i*2+1]; - } - - // For each of the 27 possible regions, find out if it is enabled, - // and if so, compute the bounds and the distance from the camera - // to the center of the region. - size_t numRegions = 0; - size_t region; - for ( region = 0; region < 27; region++ ) - { - int regionFlag = 1<CroppingRegionFlags & regionFlag ) - { - // what is the coordinate in the 3x3x3 grid - size_t loc[3]; - loc[0] = region%3; - loc[1] = (region/3)%3; - loc[2] = (region/9)%3; - - // make sure the cropping region is not empty NEW - // otherwise, we skip the region. - if((limit[loc[0]]!=limit[loc[0]+1]) - && (limit[loc[1]+4]!=limit[loc[1]+5]) - && (limit[loc[2]+8]!=limit[loc[2]+9])) - { - // compute the bounds and center - double center[3]; - for ( i = 0; i < 3; i++ ) - { - bounds[numRegions][i*2 ] = limit[4*i+loc[i]]; - bounds[numRegions][i*2+1] = limit[4*i+loc[i]+1]; - center[i]=(bounds[numRegions][i*2]+bounds[numRegions][i*2+1])*0.5; - } - - // compute the distance squared to the center - distance2[numRegions] = - (camPos[0]-center[0])*(camPos[0]-center[0]) + - (camPos[1]-center[1])*(camPos[1]-center[1]) + - (camPos[2]-center[2])*(camPos[2]-center[2]); - - // we've added one region - numRegions++; - } - } - } - vtkRegionDistance2 regions[27]; - - i=0; - while(iNumberOfCroppingRegions>=0); -} - -//----------------------------------------------------------------------------- -// slabsDataSet are position of the slabs in dataset coordinates. -// slabsPoints are position of the slabs in points coordinates. -// For instance, slabsDataSet[0] is the position of the plane bounding the slab -// on the left of x axis of the dataset. slabsPoints[0]=0.3 means that -// this plane lies between point 0 and point 1 along the x-axis. -// There is no clamping/clipping according to the dataset bounds so, -// slabsPoints can be negative or excess the number of points along the -// corresponding axis. -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::SlabsFromDatasetToIndex( - double slabsDataSet[6], - double slabsPoints[6]) -{ - double *spacing=this->GetInput()->GetSpacing(); - double origin[3]; - - // take spacing sign into account - const double *bds = this->GetInput()->GetBounds(); - origin[0] = bds[0]; - origin[1] = bds[2]; - origin[2] = bds[4]; - - int i=0; - while(i<6) - { - slabsPoints[i]=(slabsDataSet[i] - origin[i/2]) / spacing[i/2]; - ++i; - } -} - -//----------------------------------------------------------------------------- -// slabsDataSet are position of the slabs in dataset coordinates. -// slabsPoints are position of the slabs in points coordinates. -// For instance, slabsDataSet[0] is the position of the plane bounding the slab -// on the left of x axis of the dataset. slabsPoints[0]=0.3 means that -// this plane lies between point 0 and point 1 along the x-axis. -// There is no clamping/clipping according to the dataset bounds so, -// slabsPoints can be negative or excess the number of points along the -// corresponding axis. -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::SlabsFromIndexToDataset( - double slabsPoints[6], - double slabsDataSet[6]) -{ - double *spacing=this->GetInput()->GetSpacing(); - double origin[3]; - - // take spacing sign into account - const double *bds = this->GetInput()->GetBounds(); - origin[0] = bds[0]; - origin[1] = bds[2]; - origin[2] = bds[4]; - - int i=0; - while(i<6) - { - slabsDataSet[i]=slabsPoints[i]*spacing[i/2]+origin[i/2]; - ++i; - } -} - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -class vtkStreamBlock -{ -public: - double Bounds[6]; - double Extent[6]; -}; - -//----------------------------------------------------------------------------- -// Render a subvolume. bounds are in world coordinates. -// \pre this->ProgramShader!=0 and is linked. -//----------------------------------------------------------------------------- -int vtkOpenGLGPUVolumeRayCastMapper::RenderSubVolume(vtkRenderer *ren, - double bounds[6], - vtkVolume *volume) -{ - vtkOpenGLClearErrorMacro(); - - // Time to load scalar field - size_t i; - int wholeTextureExtent[6]; - this->GetTransformedInput()->GetExtent(wholeTextureExtent); - if(this->CellFlag) - { - i=1; - while(i<6) - { - wholeTextureExtent[i]--; - i+=2; - } - } - - // 1. Found out the extent of the subvolume - double realExtent[6]; - int subvolumeTextureExtent[6]; - - this->SlabsFromDatasetToIndex(bounds,realExtent); - - if(this->CellFlag) // 3D texture are celldata - { - // texture extents are expressed in cells in this case - i=0; - while(i<6) - { - subvolumeTextureExtent[i]=vtkMath::Floor(realExtent[i]-0.5); - ++i; - subvolumeTextureExtent[i]=vtkMath::Floor(realExtent[i]-0.5)+1; - ++i; - } - } - else - { - // texture extents are expressed in points in this case - i=0; - while(i<6) - { - subvolumeTextureExtent[i]=vtkMath::Floor(realExtent[i]); - ++i; - subvolumeTextureExtent[i]=vtkMath::Floor(realExtent[i])+1; // used to not have +1 - ++i; - } - } - - i=0; - while(i<6) - { - assert("check: wholeTextureExtent" && wholeTextureExtent[i]==0); - if(subvolumeTextureExtent[i]wholeTextureExtent[i]) - { - subvolumeTextureExtent[i]=wholeTextureExtent[i]; - } - ++i; - } - - assert("check: subvolume_inside_wholevolume" && - subvolumeTextureExtent[0]>=wholeTextureExtent[0] - && subvolumeTextureExtent[1]<=wholeTextureExtent[1] - && subvolumeTextureExtent[2]>=wholeTextureExtent[2] - && subvolumeTextureExtent[3]<=wholeTextureExtent[3] - && subvolumeTextureExtent[4]>=wholeTextureExtent[4] - && subvolumeTextureExtent[5]<=wholeTextureExtent[5]); - - // 2. Is this subvolume already on the GPU? - // ie are the extent of the subvolume inside the loaded extent? - - - // Find the texture (and mask). - std::map::iterator it= - this->ScalarsTextures->Map.find(this->GetTransformedInput()); - vtkKWScalarField *texture; - if(it==this->ScalarsTextures->Map.end()) - { - texture=0; - } - else - { - texture=(*it).second; - } - - vtkKWMask *mask=0; - if(this->MaskInput!=0) - { - std::map::iterator it2= - this->MaskTextures->Map.find(this->MaskInput); - if(it2==this->MaskTextures->Map.end()) - { - mask=0; - } - else - { - mask=(*it2).second; - } - } - - int loaded = - texture!=0 && - texture->IsLoaded() && - this->GetTransformedInput()->GetMTime()<=texture->GetBuildTime() && - (this->GetMaskInput() ? this->GetMaskInput()->GetMTime() <= texture->GetBuildTime() : true) && - texture->GetLoadedCellFlag()==this->CellFlag; - - - vtkIdType *loadedExtent; - - if(loaded) - { - loadedExtent=texture->GetLoadedExtent(); - i=0; - while(loaded && i<6) - { - loaded=loaded && loadedExtent[i]<=subvolumeTextureExtent[i]; - ++i; - loaded=loaded && loadedExtent[i]>=subvolumeTextureExtent[i]; - ++i; - } - } - - if(loaded) - { - this->CurrentScalar=texture; - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - this->CurrentScalar->Bind(); - - vtkgl::ActiveTexture(vtkgl::TEXTURE7); - this->CurrentMask=mask; - if(this->CurrentMask!=0) - { - this->CurrentMask->Bind(); - } - } - - if(!loaded) - { - // 3. Not loaded: try to load the whole dataset - if(!this->LoadScalarField(this->GetTransformedInput(),this->MaskInput,wholeTextureExtent,volume)) - { - // 4. loading the whole dataset failed: try to load the subvolume - if(!this->LoadScalarField(this->GetTransformedInput(),this->MaskInput, subvolumeTextureExtent, - volume)) - { - // 5. loading the subvolume failed: stream the subvolume - // 5.1 do zslabs first, if too large then cut with x or y with the - // largest dimension. order of zlabs depends on sign of spacing[2] - - unsigned int internalFormat; - unsigned int format; - unsigned int type; - int componentSize; - this->GetTextureFormat(this->GetInput(),&internalFormat,&format,&type, - &componentSize); - - // Enough memory? - int originalTextureSize[3]; - int textureSize[3]; - i=0; - while(i<3) - { - textureSize[i]=subvolumeTextureExtent[2*i+1]-subvolumeTextureExtent[2*i]+1; - originalTextureSize[i]=textureSize[i]; - ++i; - } - - // Make sure loading did not fail because of theorical limits - - GLint width; - glGetIntegerv(vtkgl::MAX_3D_TEXTURE_SIZE,&width); - - int clippedXY=0; - int clippedZ=0; - - if(textureSize[0]>width) - { - textureSize[0]=width; - clippedXY=1; - } - if(textureSize[1]>width) - { - textureSize[1]=width; - clippedXY=1; - } - if(textureSize[2]>width) - { - textureSize[2]=width; - clippedZ=1; - } - - int minSize; - if(this->CellFlag) - { - minSize=1; - } - else - { - minSize=2; - } - - if(clippedXY) - { - // We cannot expect to first divide as z-slabs because it is already - // clipped in another dimension. From now, just divide in the largest - // dimension. - bool foundSize=false; - while(!foundSize && textureSize[0]>=minSize - && textureSize[1]>=minSize) - { - foundSize=this->TestLoadingScalar(internalFormat,format,type, - textureSize,componentSize); - if(!foundSize) - { - int maxDim=0; - if(textureSize[1]>textureSize[0]) - { - maxDim=1; - } - if(textureSize[2]>textureSize[maxDim]) - { - maxDim=2; - } - textureSize[maxDim]>>=1; // /=2 - } - } - } - else - { - // we are in cropping mode, it will be slow anyway. the case we want - // to optimize is stream the all scalar field. With that in mine, - // it is better to first try to send z-slabs. If even a minimal - // z-slab is too big, we have to divide by x or y dimensions. In - // this case, it will be slow and we can choose to keep blocks as - // square as possible by dividing by the largest dimension at each - // iteration. - - if(!clippedZ) - { - // we start by subdividing only if we did not already clipped - // the z dimension according to the theorical limits. - textureSize[2]>>=1; // /=2 - } - - bool foundSize=false; - while(!foundSize && textureSize[2]>=minSize) - { - foundSize=this->TestLoadingScalar(internalFormat,format,type, - textureSize,componentSize); - if(!foundSize) - { - textureSize[2]>>=1; // /=2 - } - } - if(!foundSize) - { - textureSize[2]=minSize; - if(textureSize[0]>textureSize[1]) - { - textureSize[0]>>=1; // /=2 - } - else - { - textureSize[1]>>=1; // /=2 - } - while(!foundSize && textureSize[0]>=minSize - && textureSize[1]>=minSize) - { - foundSize=this->TestLoadingScalar(internalFormat,format,type, - textureSize,componentSize); - if(!foundSize) - { - if(textureSize[0]>textureSize[1]) - { - textureSize[0]>>=1; // /=2 - } - else - { - textureSize[1]>>=1; // /=2 - } - } - } - } - if(!foundSize) - { - vtkErrorMacro( - <<"No memory left on the GPU even for a minimal block."); - return 1; // abort - } - } - - // except for the last bound. - // front to back ordering - - // Pass camera through inverse volume matrix - // so that we are in the same coordinate system - double camPos[4]; - vtkCamera *cam = ren->GetActiveCamera(); - cam->GetPosition(camPos); - volume->GetMatrix( this->InvVolumeMatrix ); - camPos[3] = 1.0; - this->InvVolumeMatrix->Invert(); - this->InvVolumeMatrix->MultiplyPoint( camPos, camPos ); - if ( camPos[3] ) - { - camPos[0] /= camPos[3]; - camPos[1] /= camPos[3]; - camPos[2] /= camPos[3]; - } - - - // 5.2 iterate of each stream of the subvolume and render it: - - // point scalar: on the first block, the first point is not shared - - // blockExtent is always expressed in point, not in texture - // extent. - size_t remainder[3]; - i=0; - while(i<3) - { - remainder[i]=static_cast( - (originalTextureSize[i]-textureSize[i])%(textureSize[i]-1)); - if(remainder[i]>0) - { - remainder[i]=1; - } - ++i; - } - - size_t counts[3]; - - counts[0]=static_cast((originalTextureSize[0]-textureSize[0]) - /(textureSize[0]-1)); - counts[0]+=remainder[0]+1; - counts[1]=static_cast((originalTextureSize[1]-textureSize[1]) - /(textureSize[1]-1)); - counts[1]+=remainder[1]+1; - counts[2]=static_cast((originalTextureSize[2]-textureSize[2]) - /(textureSize[2]-1)); - counts[2]+=remainder[2]+1; - - size_t count=counts[0]*counts[1]*counts[2]; - - double blockExtent[6]; - vtkStreamBlock *blocks=new vtkStreamBlock[count]; - vtkRegionDistance2 *sortedBlocks=new vtkRegionDistance2[count]; - - // iterate over z,y,x - size_t blockId=0; - - size_t zIndex=0; - blockExtent[4]=realExtent[4]; - blockExtent[5]=vtkMath::Floor(blockExtent[4])+textureSize[2]; - if(!this->CellFlag) - { - blockExtent[5]--; - } - if(blockExtent[5]>realExtent[5]) - { - blockExtent[5]=realExtent[5]; - } - while(zIndexCellFlag) - { - blockExtent[3]--; - } - if(blockExtent[3]>realExtent[3]) - { - blockExtent[3]=realExtent[3]; - } - size_t yIndex=0; - while(yIndexCellFlag) - { - blockExtent[1]--; - } - if(blockExtent[1]>realExtent[1]) - { - blockExtent[1]=realExtent[1]; - } - size_t xIndex=0; - while(xIndexSlabsFromIndexToDataset(blockExtent,blockBounds); - - // compute the bounds and center - double center[3]; - i=0; - while(i<3) - { - center[i]=(blockBounds[i*2]+blockBounds[i*2+1])*0.5; - ++i; - } - - // compute the distance squared to the center - double distance2=(camPos[0]-center[0])*(camPos[0]-center[0])+ - (camPos[1]-center[1])*(camPos[1]-center[1]) + - (camPos[2]-center[2])*(camPos[2]-center[2]); - - i=0; - while(i<6) - { - blocks[blockId].Bounds[i]=blockBounds[i]; - blocks[blockId].Extent[i]=blockExtent[i]; - ++i; - } - - sortedBlocks[blockId].Id=blockId; - sortedBlocks[blockId].Distance2=distance2; - - ++blockId; - - blockExtent[0]=blockExtent[1]; - blockExtent[1]=blockExtent[0]+textureSize[0]; - if(!this->CellFlag) - { - blockExtent[1]--; - } - if(blockExtent[1]>realExtent[1]) - { - blockExtent[1]=realExtent[1]; - } - ++xIndex; - } // while x - - blockExtent[2]=blockExtent[3]; - blockExtent[3]=blockExtent[2]+textureSize[1]; - if(!this->CellFlag) - { - blockExtent[3]--; - } - if(blockExtent[3]>realExtent[3]) - { - blockExtent[3]=realExtent[3]; - } - ++yIndex; - } // while y - - - blockExtent[4]=blockExtent[5]; - blockExtent[5]=blockExtent[4]+textureSize[2]; - if(!this->CellFlag) - { - blockExtent[5]--; - } - if(blockExtent[5]>realExtent[5]) - { - blockExtent[5]=realExtent[5]; - } - ++zIndex; - } // while z - - assert("check: valid_number_of_blocks" && blockId==count); - - qsort(sortedBlocks,static_cast(count), - sizeof(vtkRegionDistance2), - vtkRegionComparisonFunction); - - // loop over all blocks we need to render - i=0; - int abort=0; - while(!abort && i < count) // 1) //count) - { - size_t k=sortedBlocks[i].Id; - - int blockTextureExtent[6]; - int j; - if(this->CellFlag) // 3D texture are celldata - { - // texture extents are expressed in cells in this case - j=0; - while(j<6) - { - blockTextureExtent[j]=vtkMath::Floor(blocks[k].Extent[j]); - ++j; - } - } - else - { - // texture extents are expressed in points in this case - j=0; - while(j<6) - { - blockTextureExtent[j]=vtkMath::Floor(blocks[k].Extent[j]); - ++j; - blockTextureExtent[j]=vtkMath::Floor(blocks[k].Extent[j]); - if(blockTextureExtent[j]LoadScalarField(this->GetInput(),this->MaskInput, blockTextureExtent, - volume)) - { - cout<<"Loading the streamed block FAILED!!!!!"<CurrentScalar->GetLoadedExtent(); - - float lowBounds[3]; - float highBounds[3]; - if(!this->CurrentScalar->GetLoadedCellFlag()) // points - { - j=0; - while(j<3) - { - double delta= - static_cast(loadedExtent[j*2+1]-loadedExtent[j*2]); - lowBounds[j]=static_cast((blocks[k].Extent[j*2]-static_cast(loadedExtent[j*2]))/delta); - highBounds[j]=static_cast((blocks[k].Extent[j*2+1]-static_cast(loadedExtent[j*2]))/delta); - ++j; - } - } - else // cells - { - j=0; - while(j<3) - { - double delta= - static_cast(loadedExtent[j*2+1]-loadedExtent[j*2]); - lowBounds[j]=static_cast((blocks[k].Extent[j*2]-0.5-static_cast(loadedExtent[j*2]))/delta); - highBounds[j]=static_cast((blocks[k].Extent[j*2+1]-0.5-static_cast(loadedExtent[j*2]))/delta); - ++j; - } - } - - - - - // bounds have to be normalized. There are used in the shader - // as bounds to a value used to sample a texture. - - assert("check: positive_low_bounds0" && lowBounds[0]>=0.0); - assert("check: positive_low_bounds1" && lowBounds[1]>=0.0); - assert("check: positive_low_bounds2" && lowBounds[2]>=0.0); - - assert("check: increasing_bounds0" && lowBounds[0]<=highBounds[0]); - assert("check: increasing_bounds1" && lowBounds[1]<=highBounds[1]); - assert("check: increasing_bounds2" && lowBounds[2]<=highBounds[2]); - assert("check: high_bounds0_less_than1" && highBounds[0]<=1.0); - assert("check: high_bounds1_less_than1" && highBounds[1]<=1.0); - assert("check: high_bounds2_less_than1" && highBounds[2]<=1.0); - - vtkUniformVariables *v=this->Program->GetUniformVariables(); - v->SetUniformf("lowBounds",3,lowBounds); - v->SetUniformf("highBounds",3,highBounds); - - // other sub-volume rendering code - this->LoadProjectionParameters(ren,volume); - this->ClipBoundingBox(ren,blocks[k].Bounds,volume); - - this->Program->SendUniforms(); - abort=this->RenderClippedBoundingBox(1,i,count,ren->GetRenderWindow()); - if (!abort) - { - this->CopyFBOToTexture(); - } - - ++i; - } - - delete[] blocks; - delete[] sortedBlocks; - return abort; - } - } - } - - loadedExtent=this->CurrentScalar->GetLoadedExtent(); - - // low bounds and high bounds are in texture coordinates. - float lowBounds[3]; - float highBounds[3]; - if(!this->CurrentScalar->GetLoadedCellFlag()) // points - { - i=0; - while(i<3) - { - double delta= - static_cast(loadedExtent[i*2+1]-loadedExtent[i*2]+1); - lowBounds[i]=static_cast((realExtent[i*2]+0.5-static_cast(loadedExtent[i*2]))/delta); - highBounds[i]=static_cast((realExtent[i*2+1]+0.5-static_cast(loadedExtent[i*2]))/delta); - ++i; - } - } - else // cells - { - i=0; - while(i<3) - { - double delta= - static_cast(loadedExtent[i*2+1]-loadedExtent[i*2]+1); - - // this->LoadedExtent[i*2]==0, texcoord starts at 0, if realExtent==0 - // otherwise, texcoord start at 1/2N - // this->LoadedExtent[i*2]==wholeTextureExtent[i*2+1], texcoord stops at 1, if realExtent==wholeTextureExtent[i*2+1]+1 - // otherwise it stop at 1-1/2N - // N is the number of texels in the loadedtexture not the number of - // texels in the whole texture. - - lowBounds[i]=static_cast((realExtent[i*2]-static_cast(loadedExtent[i*2]))/delta); - highBounds[i]=static_cast((realExtent[i*2+1]-static_cast(loadedExtent[i*2]))/delta); - ++i; - } - } - - assert("check: positive_low_bounds0" && lowBounds[0]>=0.0); - assert("check: positive_low_bounds1" && lowBounds[1]>=0.0); - assert("check: positive_low_bounds2" && lowBounds[2]>=0.0); - - assert("check: increasing_bounds0" && lowBounds[0]<=highBounds[0]); - assert("check: increasing_bounds1" && lowBounds[1]<=highBounds[1]); - assert("check: increasing_bounds2" && lowBounds[2]<=highBounds[2]); - assert("check: high_bounds0_less_than1" && highBounds[0]<=1.0); - assert("check: high_bounds1_less_than1" && highBounds[1]<=1.0); - assert("check: high_bounds2_less_than1" && highBounds[2]<=1.0); - - vtkUniformVariables *v=this->Program->GetUniformVariables(); - v->SetUniformf("lowBounds",3,lowBounds); - v->SetUniformf("highBounds",3,highBounds); - - // other sub-volume rendering code - this->LoadProjectionParameters(ren,volume); - this->ClipBoundingBox(ren,bounds,volume); - this->Program->SendUniforms(); - int abort=this->RenderClippedBoundingBox(1,0,1,ren->GetRenderWindow()); - if (!abort) - { - this->CopyFBOToTexture(); - } - vtkOpenGLCheckErrorMacro("failed after RenderSubVolume"); - return abort; -} - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::LoadProjectionParameters( - vtkRenderer *ren, - vtkVolume *vol) -{ - vtkMatrix4x4 *worldToDataset=vol->GetMatrix(); - vtkMatrix4x4 *datasetToWorld=this->TempMatrix[0]; - vtkMatrix4x4::Invert(worldToDataset,datasetToWorld); - - double *bounds=this->CurrentScalar->GetLoadedBounds(); - - double delta[3]; - int i=0; - while(i<3) - { - delta[i]=bounds[2*i+1]-bounds[2*i]; - ++i; - } - - // worldToTexture matrix is needed - - // Compute change-of-coordinate matrix from world space to texture space. - vtkMatrix4x4 *worldToTexture=this->TempMatrix[2]; - vtkMatrix4x4 *datasetToTexture=this->TempMatrix[1]; - - // Set the matrix - datasetToTexture->Zero(); - datasetToTexture->SetElement(0,0,delta[0]); - datasetToTexture->SetElement(1,1,delta[1]); - datasetToTexture->SetElement(2,2,delta[2]); - datasetToTexture->SetElement(3,3,1.0); - datasetToTexture->SetElement(0,3,bounds[0]); - datasetToTexture->SetElement(1,3,bounds[2]); - datasetToTexture->SetElement(2,3,bounds[4]); - - // worldToTexture=worldToDataSet*dataSetToTexture - vtkMatrix4x4::Multiply4x4(worldToDataset,datasetToTexture,worldToTexture); - - // NEW - int parallelProjection=ren->GetActiveCamera()->GetParallelProjection(); - -// cout << "actualSampleDistance=" << this->ActualSampleDistance << endl; - - vtkUniformVariables *v=this->Program->GetUniformVariables(); - float fvalues[3]; - - if(parallelProjection) - { - // Unit vector of the direction of projection in world space. - double dirWorld[4]; - double dir[4]; - ren->GetActiveCamera()->GetDirectionOfProjection(dirWorld); - dirWorld[3]=0.0; - - // direction in dataset space. - datasetToWorld->MultiplyPoint(dirWorld,dir); - - // incremental vector: - // direction in texture space times sample distance in world space. - i=0; - while(i<3) - { - dir[i]=dir[i]*this->ActualSampleDistance/delta[i]; - fvalues[i]=static_cast(dir[i]); - ++i; - } - v->SetUniformf("parallelRayDirection",3,fvalues); - //cout<<"rayDir="<GetActiveCamera()->GetPosition(cameraPosWorld); - cameraPosWorld[3]=1.0; // we use homogeneous coordinates. - - datasetToWorld->MultiplyPoint(cameraPosWorld,cameraPosDataset); - - // From homogeneous to cartesian coordinates. - if(cameraPosDataset[3]!=1.0) - { - double ratio=1/cameraPosDataset[3]; - cameraPosDataset[0]*=ratio; - cameraPosDataset[1]*=ratio; - cameraPosDataset[2]*=ratio; - } - - double *spacing=this->GetInput()->GetSpacing(); - double spacingSign[3]; - i=0; - while(i<3) - { - if(spacing[i]<0) - { - spacingSign[i]=-1.0; - } - else - { - spacingSign[i]=1.0; - } - ++i; - } - - if(this->CellFlag) - { - i=0; - while(i<3) - { - cameraPosTexture[i] = spacingSign[i]*(cameraPosDataset[i]-bounds[i*2])/delta[i]; - ++i; - } - } - else - { - // Initial fix by APGX (Gianluca Arcidiacono) - // http://www.vtk.org/pipermail/vtkusers/2010-August/110978.html - // VTKEdge Bug 8549 - - vtkIdType *loadedExtent=this->CurrentScalar->GetLoadedExtent(); - i=0; - while(i<3) - { - double tmp; // between 0 and 1 - tmp = spacingSign[i]*(cameraPosDataset[i] - bounds[i*2]) / delta[i]; - double delta2=static_cast( - loadedExtent[i*2+1]-loadedExtent[i*2]+1); - cameraPosTexture[i]=(tmp*(delta2-1)+0.5)/delta2; - ++i; - } - } - - // Only make sense for the vectorial part of the homogeneous matrix. - // coefMatrix=transposeWorldToTexture*worldToTexture - // we re-cycle the datasetToWorld pointer with a different name - vtkMatrix4x4 *transposeWorldToTexture=this->TempMatrix[1]; - // transposeWorldToTexture={^t}worldToTexture - vtkMatrix4x4::Transpose(worldToTexture,transposeWorldToTexture); - - vtkMatrix4x4 *coefMatrix=this->TempMatrix[1]; - vtkMatrix4x4::Multiply4x4(transposeWorldToTexture,worldToTexture, - coefMatrix); - - fvalues[0]=static_cast(cameraPosTexture[0]); - fvalues[1]=static_cast(cameraPosTexture[1]); - fvalues[2]=static_cast(cameraPosTexture[2]); - v->SetUniformf("cameraPosition",3,fvalues); - - fvalues[0]=this->ActualSampleDistance; - v->SetUniformf("sampleDistance",1,fvalues); - - fvalues[0]=static_cast(coefMatrix->GetElement(0,0)); - fvalues[1]=static_cast(coefMatrix->GetElement(1,1)); - fvalues[2]=static_cast(coefMatrix->GetElement(2,2)); - v->SetUniformf("matrix1",3,fvalues); - - fvalues[0]=static_cast(2*coefMatrix->GetElement(0,1)); - fvalues[1]=static_cast(2*coefMatrix->GetElement(1,2)); - fvalues[2]=static_cast(2*coefMatrix->GetElement(0,2)); - v->SetUniformf("matrix2",3,fvalues); - } - - // Change-of-coordinate matrix from Eye space to texture space. - vtkMatrix4x4 *eyeToTexture=this->TempMatrix[1]; - vtkMatrix4x4 *eyeToWorld=ren->GetActiveCamera()->GetViewTransformMatrix(); - - vtkMatrix4x4::Multiply4x4(eyeToWorld,worldToTexture,eyeToTexture); - - GLfloat matrix[16];// used sometimes as 3x3, sometimes as 4x4. - int index; - int column; - int row; - - int shadeMethod=this->LastShade; - - if(shadeMethod==vtkOpenGLGPUVolumeRayCastMapperShadeYes) - { - index=0; - column=0; - while(column<3) - { - row=0; - while(row<3) - { -// cout << "index=" << index << " row*4+column=" << row*4+column << endl; - matrix[index]=static_cast(eyeToTexture->Element[row][column]); - ++index; - ++row; - } - ++column; - } - v->SetUniformMatrix("eyeToTexture3",3,3,matrix); - - index=0; - column=0; - while(column<4) - { - row=0; - while(row<4) - { -// cout << "index=" << index << " row*4+column=" << row*4+column << endl; - matrix[index]=static_cast(eyeToTexture->Element[row][column]); - ++index; - ++row; - } - ++column; - } - v->SetUniformMatrix("eyeToTexture4",4,4,matrix); - } - - eyeToTexture->Invert(); - - index=0; - column=0; - while(column<4) - { - row=0; - while(row<4) - { -// cout << "index=" << index << " row*4+column=" << row*4+column << endl; - matrix[index]=static_cast(eyeToTexture->Element[row][column]); - ++index; - ++row; - } - ++column; - } - - v->SetUniformMatrix("textureToEye",4,4,matrix); - - if(shadeMethod==vtkOpenGLGPUVolumeRayCastMapperShadeYes) - { - eyeToTexture->Transpose(); - - index=0; - column=0; - while(column<3) - { - row=0; - while(row<3) - { -// cout << "index=" << index << " row*4+column=" << row*4+column << endl; - matrix[index]=static_cast(eyeToTexture->Element[row][column]); - ++index; - ++row; - } - ++column; - } - v->SetUniformMatrix("transposeTextureToEye",3,3,matrix); - - float cellScale[3]; // 1/(2*Step) - float cellStep[3]; // Step - - vtkIdType *loadedExtent=this->CurrentScalar->GetLoadedExtent(); - cellScale[0]=static_cast(static_cast( - loadedExtent[1]-loadedExtent[0])*0.5); - cellScale[1]=static_cast(static_cast( - loadedExtent[3]-loadedExtent[2])*0.5); - cellScale[2]=static_cast(static_cast( - loadedExtent[5]-loadedExtent[4])*0.5); - cellStep[0]=static_cast(1.0/static_cast( - loadedExtent[1]-loadedExtent[0])); - cellStep[1]=static_cast(1.0/static_cast( - loadedExtent[3]-loadedExtent[2])); - cellStep[2]=static_cast(1.0/static_cast( - loadedExtent[5]-loadedExtent[4])); - - v->SetUniformf("cellScale",3,cellScale); - v->SetUniformf("cellStep",3,cellStep); - } -} - -//----------------------------------------------------------------------------- -// Concatenate the header string, projection type code and method to the -// final fragment code in this->FragmentCode. -// \pre valid_raycastMethod: raycastMethod>= -// vtkOpenGLGPUVolumeRayCastMapperMethodMIP && -// raycastMethod<=vtkOpenGLGPUVolumeRayCastMapperMethodMinIPFourDependent -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::BuildProgram(vtkRenderWindow *w, - int parallelProjection, - int raycastMethod, - int shadeMethod, - int componentMethod) -{ - - assert("pre: valid_raycastMethod" && - raycastMethod>= vtkOpenGLGPUVolumeRayCastMapperMethodMIP - && raycastMethod<=vtkOpenGLGPUVolumeRayCastMapperMethodAdditive); - - if(this->Program==0) - { - this->Program=vtkShaderProgram2::New(); - this->Program->SetContext(static_cast(w)); - } - - vtkShader2Collection *shaders=this->Program->GetShaders(); - - if(this->Main==0) - { - this->Main=vtkShader2::New(); - this->Main->SetType(VTK_SHADER_TYPE_FRAGMENT); - this->Main->SetSourceCode(vtkGPUVolumeRayCastMapper_HeaderFS); -// this->Main->SetSourceCode(vtkGPUVolumeRayCastMapper_DebugFS); - shaders->AddItem(this->Main); - } - if(this->Projection==0) - { - this->Projection=vtkShader2::New(); - this->Projection->SetType(VTK_SHADER_TYPE_FRAGMENT); - // SourceCode is postponed. - shaders->AddItem(this->Projection); - } - if(this->Trace==0) - { - this->Trace=vtkShader2::New(); - this->Trace->SetType(VTK_SHADER_TYPE_FRAGMENT); - // SourceCode is postponed. - shaders->AddItem(this->Trace); - } - if(this->CroppingShader==0) - { - this->CroppingShader=vtkShader2::New(); - this->CroppingShader->SetType(VTK_SHADER_TYPE_FRAGMENT); - // SourceCode is postponed. - shaders->AddItem(this->CroppingShader); - } - if(this->Component==0) - { - this->Component=vtkShader2::New(); - this->Component->SetType(VTK_SHADER_TYPE_FRAGMENT); - // SourceCode is postponed. - // addition to collection is postponed. - } - if(this->Shade==0) - { - this->Shade=vtkShader2::New(); - this->Shade->SetType(VTK_SHADER_TYPE_FRAGMENT); - // SourceCode is postponed. - // addition to collection is postponed. - } - -// cout<<"projection="<Trace->SetSourceCode(methodCode); - } - - // update cropping method - int croppingMode; - switch(raycastMethod) - { - case vtkOpenGLGPUVolumeRayCastMapperMethodMIP: - case vtkOpenGLGPUVolumeRayCastMapperMethodMIPBinaryMask: - if(this->NumberOfCroppingRegions>1) - { - croppingMode=vtkOpenGLGPUVolumeRayCastMapperMIPCropping; - } - else - { - croppingMode=vtkOpenGLGPUVolumeRayCastMapperMIPNoCropping; - } - break; - case vtkOpenGLGPUVolumeRayCastMapperMethodMIPFourDependent: - if(this->NumberOfCroppingRegions>1) - { - croppingMode=vtkOpenGLGPUVolumeRayCastMapperMIPFourDependentCropping; - } - else - { - croppingMode= - vtkOpenGLGPUVolumeRayCastMapperMIPFourDependentNoCropping; - } - break; - case vtkOpenGLGPUVolumeRayCastMapperMethodMinIP: - case vtkOpenGLGPUVolumeRayCastMapperMethodMinIPBinaryMask: - if(this->NumberOfCroppingRegions>1) - { - croppingMode=vtkOpenGLGPUVolumeRayCastMapperMinIPCropping; - } - else - { - croppingMode=vtkOpenGLGPUVolumeRayCastMapperMinIPNoCropping; - } - break; - case vtkOpenGLGPUVolumeRayCastMapperMethodMinIPFourDependent: - if(this->NumberOfCroppingRegions>1) - { - croppingMode=vtkOpenGLGPUVolumeRayCastMapperMinIPFourDependentCropping; - } - else - { - croppingMode= - vtkOpenGLGPUVolumeRayCastMapperMinIPFourDependentNoCropping; - } - break; - case vtkOpenGLGPUVolumeRayCastMapperMethodAdditive: - if(this->NumberOfCroppingRegions>1) - { - croppingMode=vtkOpenGLGPUVolumeRayCastMapperAdditiveCropping; - } - else - { - croppingMode=vtkOpenGLGPUVolumeRayCastMapperAdditiveNoCropping; - } - break; - default: - if(this->NumberOfCroppingRegions>1) - { - croppingMode=vtkOpenGLGPUVolumeRayCastMapperCompositeCropping; - } - else - { - croppingMode=vtkOpenGLGPUVolumeRayCastMapperCompositeNoCropping; - } - break; - } - -// cout<<"croppingMode="<LastCroppingMode) - { - this->LastCroppingMode=croppingMode; - const char *croppingCode; - switch(croppingMode) - { - case vtkOpenGLGPUVolumeRayCastMapperMIPCropping: - croppingCode=vtkGPUVolumeRayCastMapper_MIPCroppingFS; - break; - case vtkOpenGLGPUVolumeRayCastMapperMIPNoCropping: - croppingCode=vtkGPUVolumeRayCastMapper_MIPNoCroppingFS; - break; - case vtkOpenGLGPUVolumeRayCastMapperMIPFourDependentCropping: - croppingCode=vtkGPUVolumeRayCastMapper_MIPFourDependentCroppingFS; - break; - case vtkOpenGLGPUVolumeRayCastMapperMIPFourDependentNoCropping: - croppingCode=vtkGPUVolumeRayCastMapper_MIPFourDependentNoCroppingFS; - break; - case vtkOpenGLGPUVolumeRayCastMapperCompositeCropping: - croppingCode=vtkGPUVolumeRayCastMapper_CompositeCroppingFS; - break; - case vtkOpenGLGPUVolumeRayCastMapperCompositeNoCropping: - croppingCode=vtkGPUVolumeRayCastMapper_CompositeNoCroppingFS; - break; - case vtkOpenGLGPUVolumeRayCastMapperMinIPCropping: - croppingCode=vtkGPUVolumeRayCastMapper_MinIPCroppingFS; - break; - case vtkOpenGLGPUVolumeRayCastMapperMinIPNoCropping: - croppingCode=vtkGPUVolumeRayCastMapper_MinIPNoCroppingFS; - break; - case vtkOpenGLGPUVolumeRayCastMapperMinIPFourDependentCropping: - croppingCode=vtkGPUVolumeRayCastMapper_MinIPFourDependentCroppingFS; - break; - case vtkOpenGLGPUVolumeRayCastMapperMinIPFourDependentNoCropping: - croppingCode=vtkGPUVolumeRayCastMapper_MinIPFourDependentNoCroppingFS; - break; - case vtkOpenGLGPUVolumeRayCastMapperAdditiveCropping: - croppingCode=vtkGPUVolumeRayCastMapper_AdditiveCroppingFS; - break; - case vtkOpenGLGPUVolumeRayCastMapperAdditiveNoCropping: - croppingCode=vtkGPUVolumeRayCastMapper_AdditiveNoCroppingFS; - break; - default: - assert("check: impossible case" && 0); - croppingCode=0; // to avoid warning - break; - } - this->CroppingShader->SetSourceCode(croppingCode); - } - - if(componentMethod!=this->LastComponent) - { - if(shadeMethod==vtkOpenGLGPUVolumeRayCastMapperComponentNotUsed) - { - if(this->LastComponent!= - vtkOpenGLGPUVolumeRayCastMapperComponentNotInitialized) - { - shaders->RemoveItem(this->Component); - } - } - else - { - if(this->LastComponent== - vtkOpenGLGPUVolumeRayCastMapperComponentNotInitialized || - this->LastComponent== - vtkOpenGLGPUVolumeRayCastMapperComponentNotUsed) - { - shaders->AddItem(this->Component); - } - const char *componentCode; - if(componentMethod==vtkOpenGLGPUVolumeRayCastMapperComponentOne) - { - componentCode=vtkGPUVolumeRayCastMapper_OneComponentFS; - } - else - { - componentCode=vtkGPUVolumeRayCastMapper_FourComponentsFS; - } - this->Component->SetSourceCode(componentCode); - } - this->LastComponent=componentMethod; - } - - if(shadeMethod!=this->LastShade) - { - if(shadeMethod==vtkOpenGLGPUVolumeRayCastMapperShadeNotUsed) - { - if(this->LastShade!= - vtkOpenGLGPUVolumeRayCastMapperShadeNotInitialized) - { - shaders->RemoveItem(this->Shade); - } - } - else - { - if(this->LastShade==vtkOpenGLGPUVolumeRayCastMapperShadeNotInitialized - || this->LastShade==vtkOpenGLGPUVolumeRayCastMapperShadeNotUsed) - { - shaders->AddItem(this->Shade); - } - const char *shadeCode; - if(shadeMethod==vtkOpenGLGPUVolumeRayCastMapperShadeYes) - { - shadeCode=vtkGPUVolumeRayCastMapper_ShadeFS; - } - else - { - shadeCode=vtkGPUVolumeRayCastMapper_NoShadeFS; - } - this->Shade->SetSourceCode(shadeCode); - } - this->LastShade=shadeMethod; - } -} - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -const char *vtkOpenGLGPUVolumeRayCastMapper::GetEnabledString( - unsigned char value) -{ - if(value) - { - return "enabled"; - } - else - { - return "disabled"; - } -} - -//----------------------------------------------------------------------------- -// Display current OpenGL state -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::GetOpenGLState() -{ - cout<<"lighting:"<GetEnabledString(glIsEnabled(GL_LIGHTING))<GetEnabledString(glIsEnabled(GL_LIGHTING))<(value); - cout<<"active texture is "<<(activeTexture-vtkgl::TEXTURE0)<(value); - - cout<<"light\t| status\t| ambient\t| diffuse\t| specular\t| position\t| spot direction\t| spot exponent\t| spot cutoff\t| k0\t| k1\t| k2"<=0 -// \post valid_result: result>=x -//----------------------------------------------------------------------------- -int vtkOpenGLGPUVolumeRayCastMapper::PowerOfTwoGreaterOrEqual(int x) -{ - assert("pre: positive_x" && x>=0); - - int result=1; - while(result=x); - return result; -} - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::UpdateNoiseTexture() -{ - vtkOpenGLClearErrorMacro(); - - if(this->NoiseTextureId==0) - { - GLuint noiseTextureObject; - glGenTextures(1,&noiseTextureObject); - this->NoiseTextureId=static_cast(noiseTextureObject); - vtkgl::ActiveTexture(vtkgl::TEXTURE6); - glBindTexture(GL_TEXTURE_2D,noiseTextureObject); - - GLsizei size=128; // 1024; // Power of two value - GLint maxSize; - const float factor=0.1f; -// const float factor=1.0f; - const float amplitude=0.5f*factor; // something positive. - // amplitude=0.5. noise between -0.5 +0.5. add some +0.5 shift. - - glGetIntegerv(GL_MAX_TEXTURE_SIZE,&maxSize); - if(size>maxSize) - { - size=maxSize; - } - if(this->NoiseTexture!=0 && this->NoiseTextureSize!=size) - { - delete[] this->NoiseTexture; - this->NoiseTexture=0; - } - if(this->NoiseTexture==0) - { - this->NoiseTexture=new float[size*size]; - this->NoiseTextureSize=size; - vtkPerlinNoise *noiseGenerator=vtkPerlinNoise::New(); - noiseGenerator->SetFrequency(size,1.0,1.0); - noiseGenerator->SetPhase(0.0,0.0,0.0); - noiseGenerator->SetAmplitude(amplitude); - int j=0; - while(jNoiseTexture[j*size+i]=0.0; //amplitude+static_cast(noiseGenerator->EvaluateFunction(i,j,0.0)); - ++i; - } - ++j; - } - noiseGenerator->Delete(); - } - glTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE,size,size,0,GL_RED,GL_FLOAT, - this->NoiseTexture); - - glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); - GLfloat borderColor[4]={0.0,0.0,0.0,0.0}; - glTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_BORDER_COLOR,borderColor); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - } - - vtkOpenGLCheckErrorMacro("failed after UpdateNoiseTexture"); -} - -// ---------------------------------------------------------------------------- -// Description: -// Return how much the dataset has to be reduced in each dimension to -// fit on the GPU. If the value is 1.0, there is no need to reduce the -// dataset. -// \pre the calling thread has a current OpenGL context. -// \pre mapper_supported: IsRenderSupported(renderer->GetRenderWindow(),0) -// The computation is based on hardware limits (3D texture indexable size) -// and MaxMemoryInBytes. -// \post valid_i_ratio: ratio[0]>0 && ratio[0]<=1.0 -// \post valid_j_ratio: ratio[1]>0 && ratio[1]<=1.0 -// \post valid_k_ratio: ratio[2]>0 && ratio[2]<=1.0 -void vtkOpenGLGPUVolumeRayCastMapper::GetReductionRatio(double ratio[3]) -{ - // Compute texture size - int i; - int wholeTextureExtent[6]; - this->GetInput()->GetExtent(wholeTextureExtent); - - // To ensure this->CellFlag is initialized. - vtkDataArray *scalars=this->GetScalars(this->GetInput(),this->ScalarMode, - this->ArrayAccessMode, - this->ArrayId, - this->ArrayName, - this->CellFlag); - - if(this->CellFlag) // if we deal with cell data - { - i=1; - while(i<6) - { - wholeTextureExtent[i]--; - i+=2; - } - } - - // Indexable hardware limits - GLint maxSize; - glGetIntegerv(vtkgl::MAX_3D_TEXTURE_SIZE,&maxSize); - - vtkIdType rTextureSize[3]; - double dMaxSize=static_cast(maxSize); - i=0; - while(i<3) - { - double textureSize=wholeTextureExtent[2*i+1]-wholeTextureExtent[2*i]+1; - if(textureSize>maxSize) - { - ratio[i]=dMaxSize/textureSize; - } - else - { - ratio[i]=1.0; // no reduction - } - rTextureSize[i]=static_cast(floor(textureSize*ratio[i])); - ++i; - } - - // Data memory limits. - int scalarType=scalars->GetDataType(); - - vtkIdType size=rTextureSize[0]*rTextureSize[1]*rTextureSize[2] - *vtkAbstractArray::GetDataTypeSize(scalarType) - *scalars->GetNumberOfComponents(); - - if(size>static_cast(this->MaxMemoryInBytes) - *static_cast(this->MaxMemoryFraction)) - { - double r=static_cast(this->MaxMemoryInBytes) - *static_cast(this->MaxMemoryFraction)/static_cast(size); - double r3=pow(r,1.0/3.0); - // try the keep reduction ratio uniform to avoid artifacts. - bool reduced[3]; - i=0; - int count=0; - while(i<3) - { - vtkIdType newSize=static_cast( - floor(static_cast(rTextureSize[i])*r3)); - reduced[i]=newSize>=1; - if(reduced[i]) - { - ++count; - } - ++i; - } - - if(count<3) // some axis cannot be reduced - { - double r2=sqrt(r); - count=0; - i=0; - while(i<3) - { - if(reduced[i]) - { - vtkIdType newSize=static_cast( - floor(static_cast(rTextureSize[i])*r2)); - reduced[i]=newSize>=1; - if(reduced[i]) - { - ++count; - } - } - ++i; - } - if(count<2) // we can only reduce one axis - { - i=0; - while(i<3) - { - if(reduced[i]) - { - ratio[i]*=r; - } - ++i; - } - } - else // we can reduce two axes - { - i=0; - while(i<3) - { - if(reduced[i]) - { - ratio[i]*=r2; - } - ++i; - } - } - } - else // we can reduce all three axes - { - i=0; - while(i<3) - { - ratio[i]*=r3; - ++i; - } - } - } - - assert("post: valid_i_ratio" && ratio[0]>0 && ratio[0]<=1.0); - assert("post: valid_j_ratio" && ratio[1]>0 && ratio[1]<=1.0); - assert("post: valid_k_ratio" && ratio[2]>0 && ratio[2]<=1.0); -} - -//----------------------------------------------------------------------------- -// Standard print method -//----------------------------------------------------------------------------- -void vtkOpenGLGPUVolumeRayCastMapper::PrintSelf(ostream& os, - vtkIndent indent) -{ - this->Superclass::PrintSelf(os,indent); -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLGPUVolumeRayCastMapper.h paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLGPUVolumeRayCastMapper.h --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLGPUVolumeRayCastMapper.h 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLGPUVolumeRayCastMapper.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,511 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkOpenGLGPUVolumeRayCastMapper.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -/** - * @class vtkOpenGLGPUVolumeRayCastMapper - * @brief OpenGL subclass that draws the - * image to the screen - * - * This is the concrete implementation of a ray cast image display helper - - * a helper class responsible for drawing the image to the screen. - * - * @sa - * vtkGPUVolumeRayCastMapper - * - * @par Thanks: - * Thanks to Michael Granseier for helping to debug this class with respect - * to maximum memory issues (which must be specified as vtkIdType and not int). -*/ - -#ifndef vtkOpenGLGPUVolumeRayCastMapper_h -#define vtkOpenGLGPUVolumeRayCastMapper_h - -#include "vtkRenderingVolumeOpenGLModule.h" // For export macro -#include "vtkGPUVolumeRayCastMapper.h" - -class vtkVolume; -class vtkRenderer; -class vtkOpenGLExtensionManager; -class vtkMatrix4x4; -class vtkUnsupportedRequiredExtensionsStringStream; // Pimpl -class vtkMapDataArrayTextureId; // Pimpl -class vtkMapMaskTextureId; // Pimpl -class vtkPolyData; -class vtkClipConvexPolyData; -class vtkClipPolyData; -class vtkTessellatedBoxSource; - -class vtkOpacityTable; // internal class. -class vtkRGBTable; // internal class. -class vtkKWScalarField; // internal class. -class vtkKWMask; // internal class. - -class vtkOpacityTables; // Pimpl -class vtkDensifyPolyData; -class vtkStdString; - -class vtkShaderProgram2; -class vtkShader2; - -class VTKRENDERINGVOLUMEOPENGL_EXPORT vtkOpenGLGPUVolumeRayCastMapper - : public vtkGPUVolumeRayCastMapper -{ -public: - static vtkOpenGLGPUVolumeRayCastMapper *New(); - vtkTypeMacro(vtkOpenGLGPUVolumeRayCastMapper,vtkGPUVolumeRayCastMapper); - void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; - - /** - * Based on hardware and properties, we may or may not be able to - * render using 3D texture mapping. This indicates if 3D texture - * mapping is supported by the hardware, and if the other extensions - * necessary to support the specific properties are available. - */ - int IsRenderSupported(vtkRenderWindow *window, - vtkVolumeProperty *property) VTK_OVERRIDE; - - /** - * Delete OpenGL objects. - * \post done: this->OpenGLObjectsCreated==0 - */ - void ReleaseGraphicsResources(vtkWindow *window) VTK_OVERRIDE; - - /** - * Return a string matching the OpenGL errorCode. - * \post result_exists: result!=0 - */ - static const char *OpenGLErrorMessage(unsigned int errorCode); - - /** - * Display headerMessage on the standard output and the last OpenGL error - * message if any. - * \pre headerMessage_exists: headerMessage!=0 - */ - static void PrintError(const char *headerMessage); - -protected: - vtkOpenGLGPUVolumeRayCastMapper(); - ~vtkOpenGLGPUVolumeRayCastMapper() VTK_OVERRIDE; - - // The render method called by the superclass - void GPURender(vtkRenderer *ren, - vtkVolume *vol) VTK_OVERRIDE; - - // Methods called by the AMR Volume Mapper. - void PreRender(vtkRenderer *ren, - vtkVolume *vol, - double datasetBounds[6], - double scalarRange[2], - int numberOfScalarComponents, - unsigned int numberOfLevels) VTK_OVERRIDE; - - // \pre input is up-to-date - void RenderBlock(vtkRenderer *ren, - vtkVolume *vol, - unsigned int level) VTK_OVERRIDE; - - void PostRender(vtkRenderer *ren, - int numberOfScalarComponents) VTK_OVERRIDE; - - /** - * Return if the required OpenGL extension `extensionName' is supported. - * If not, its name is added to the string of unsupported but required - * extensions. - * \pre extensions_exist: extensions!=0 - * \pre extensionName_exists: extensionName!=0 - */ - int TestRequiredExtension(vtkOpenGLExtensionManager *extensions, - const char *extensionName); - - /** - * Attempt to load required and optional OpenGL extensions for the current - * context window. Variable LoadExtensionsSucceeded is set if all required - * extensions has been loaded. In addition, variable - * Supports_GL_ARB_texture_float is set if this extension has been loaded. - * \pre: window_exists: window!=0 - */ - void LoadExtensions(vtkRenderWindow *window); - - /** - * Create OpenGL objects such as textures, buffers and fragment program Ids. - * It only registers Ids, there is no actual initialization of textures or - * fragment program. - * \pre extensions_loaded: this->LoadExtensionsSucceeded - * \post done: this->OpenGLObjectsCreated==1 - */ - void CreateOpenGLObjects(vtkRenderer *ren); - - /** - * Allocate memory on the GPU for the framebuffers according to the size of - * the window or reallocate if the size has changed. Return true if - * allocation succeeded. - * \pre ren_exists: ren!=0 - * \pre opengl_objects_created: this->OpenGLObjectsCreated - * \post right_size: LastSize[]=window size. - */ - int AllocateFrameBuffers(vtkRenderer *ren); - - /** - * Load the scalar field (one or four component scalar field), cell or point - * based for a given subextent of the whole extent (can be the whole extent) - * as a 3D texture on the GPU. - * Extents are expressed in point if the cell flag is false or in cells of - * the cell flag is true. - * It returns true if it succeeded, false if there is not enough memory on - * the GPU. - * If succeeded, it updates the LoadedExtent, LoadedBounds, LoadedCellFlag - * and LoadedTime. It also succeed if the scalar field is already loaded - * (ie since last load, input has not changed and cell flag has not changed - * and requested texture extents are enclosed in the loaded extent). - * \pre input_exists: input!=0 - * \pre valid_point_extent: (this->CellFlag || - * (textureExtent[0]CellFlag || - * (textureExtent[0]<=textureExtent[1] && - * textureExtent[2]<=textureExtent[3] && - * textureExtent[4]<=textureExtent[5]))) - */ - int LoadScalarField(vtkImageData *input, - vtkImageData *maskInput, - int textureExtent[6], - vtkVolume *volume); - - /** - * Allocate memory and load color table on the GPU or - * reload it if the transfer function changed. - * \pre vol_exists: vol!=0 - * \pre valid_numberOfScalarComponents: numberOfScalarComponents==1 || numberOfScalarComponents==4 - */ - int UpdateColorTransferFunction(vtkVolume *vol, - int numberOfScalarComponents); - /** - * Allocate memory and load opacity table on the GPU or - * reload it if the transfer functions changed. - * \pre vol_exists: vol!=0 - * \pre valid_numberOfScalarComponents: numberOfScalarComponents==1 || numberOfScalarComponents==4 - */ - int UpdateOpacityTransferFunction(vtkVolume *vol, - int numberOfScalarComponents, - unsigned int level); - - /** - * Prepare rendering in the offscreen framebuffer. - * \pre ren_exists: ren!=0 - * \pre vol_exists: vol!=0 - */ - void SetupRender(vtkRenderer *ren, vtkVolume *vol); - - /** - * Clip the bounding box with all clipping planes - * and the near and far plane - */ - void ClipBoundingBox(vtkRenderer *ren, - double worldBounds[6], - vtkVolume *vol); - - /** - * Render the bounding box. The flag indicates whether - * or not tcoords are rendered too. Return abort status (true==abort). - * \pre valid_currentBlock: currentBlock>=0 && currentBlock=0 - * \post valid_result: result>=x - */ - int PowerOfTwoGreaterOrEqual(int x); - - /** - * Display the status of the current framebuffer on the standard output. - */ - void CheckFrameBufferStatus(); - - /** - * Create a string from a buffer id. The result has to be free by the caller. - */ - vtkStdString BufferToString(int buffer); - - /** - * Display the buffers assigned for drawing and reading operations. - */ - void DisplayReadAndDrawBuffers(); - - /** - * Display all the attachments of the current framebuffer object. - */ - void DisplayFrameBufferAttachments(); - - /** - * Display a given attachment for the current framebuffer object. - */ - void DisplayFrameBufferAttachment(unsigned int uattachment); - - /** - * Concatenate the header string, projection type code and method to the - * final fragment code in this->FragmentCode. - * \pre valid_raycastMethod: raycastMethod>= vtkOpenGLGPUVolumeRayCastMapperMethodMaximumIntensityProjection && raycastMethod<=vtkOpenGLGPUVolumeRayCastMapperMethodMinIPFourDependent - */ - void BuildProgram(vtkRenderWindow *w, - int parallelProjection, - int raycastMethod, - int shadeMethod, - int componentMethod); - - /** - * Return the current OpenGL state about lighting. - */ - void GetLightingStatus(); - - /** - * Update the reduction factor of the render viewport (this->ReductionFactor) - * according to the time spent in seconds to render the previous frame - * (this->TimeToDraw) and a time in seconds allocated to render the next - * frame (allocatedTime). - * \pre valid_current_reduction_range: this->ReductionFactor>0.0 && this->ReductionFactor<=1.0 - * \pre positive_TimeToDraw: this->TimeToDraw>=0.0 - * \pre positive_time: allocatedTime>0 - * \post valid_new_reduction_range: this->ReductionFactor>0.0 && this->ReductionFactor<=1.0 - */ - void ComputeReductionFactor(double allocatedTime); - - /** - * Render a subvolume. - * \pre this->ProgramShader!=0 and is linked. - */ - void RenderWholeVolume(vtkRenderer *ren, - vtkVolume *vol); - - /** - * Render a subvolume. - * \pre this->ProgramShader!=0 and is linked. - */ - void RenderRegions(vtkRenderer *ren, - vtkVolume *vol); - - // Return abort status (true==abort) - int RenderSubVolume(vtkRenderer *ren, - double bounds[6], - vtkVolume *vol); - - void LoadProjectionParameters(vtkRenderer *ren, - vtkVolume *vol); - - /** - * Compute and return the number of cropping regions - */ - void ComputeNumberOfCroppingRegions(); - - void GetTextureFormat(vtkImageData *input, - unsigned int *internalFormat, - unsigned int *format, - unsigned int *type, - int *componentSize); - - bool TestLoadingScalar(unsigned int internalFormat, - unsigned int format, - unsigned int type, - int textureSize[3], - int componentSize); - - void SlabsFromDatasetToIndex(double slabsDataSet[6], - double slabsPoints[6]); - - void SlabsFromIndexToDataset(double slabsPoints[6], - double slabsDataSet[6]); - - const char *GetEnabledString(unsigned char value); - void GetOpenGLState(); - - void DebugDisplayBox(vtkPolyData *box); - - void UpdateNoiseTexture(); - - /** - * Compute how each axis of a cell is projected on the viewport in pixel. - * This requires to have information about the camera and about the volume. - * It set the value of IgnoreSampleDistancePerPixel to true in case of - * degenerated case (axes aligned with the view). - */ - double ComputeMinimalSampleDistancePerPixel(vtkRenderer *renderer, - vtkVolume *volume); - - /** - * Return how much the dataset has to be reduced in each dimension to - * fit on the GPU. If the value is 1.0, there is no need to reduce the - * dataset. - * \pre the calling thread has a current OpenGL context. - * \pre mapper_supported: IsRenderSupported(renderer->GetRenderWindow(),0) - * The computation is based on hardware limits (3D texture indexable size) - * and MaxMemoryInBytes. - * \post valid_i_ratio: ratio[0]>0 && ratio[0]<=1.0 - * \post valid_j_ratio: ratio[1]>0 && ratio[1]<=1.0 - * \post valid_k_ratio: ratio[2]>0 && ratio[2]<=1.0 - */ - void GetReductionRatio(double ratio[3]) VTK_OVERRIDE; - - int NumberOfCroppingRegions; - - // World coordinates of each corner of the dataset. - double BoundingBox[8][3]; - - // Used during the clipping process. - vtkPolyData *PolyDataBoundingBox; - vtkPlaneCollection *Planes; - vtkPlane *NearPlane; - - vtkClipConvexPolyData *Clip; - vtkMatrix4x4 *InvVolumeMatrix; - - vtkDensifyPolyData *Densify; - - int OpenGLObjectsCreated; - int NumberOfFrameBuffers; - - unsigned int FrameBufferObject; - unsigned int DepthRenderBufferObject; - - // 3D scalar texture +1D color+1D opacity+2D grabbed depth buffer - // +1 2D colorbuffer. - unsigned int TextureObjects[5]; - // used in MIP Mode (2 needed for ping-pong technique) - unsigned int MaxValueFrameBuffer; - unsigned int MaxValueFrameBuffer2; - int ReducedSize[2]; - - vtkPolyData *ClippedBoundingBox; - - int LastSize[2]; - - double ReductionFactor; - - // Supported extensions - // List of unsupported required extensions. Pimpl. - vtkUnsupportedRequiredExtensionsStringStream *UnsupportedRequiredExtensions; - int LoadExtensionsSucceeded; - - int Supports_GL_ARB_texture_float; - int SupportsPixelBufferObjects; - - vtkTimeStamp DataBufferTime; - - // Matrices used in internal computation. As a member variable, - // only one memory allocation is performed. - vtkMatrix4x4 *TempMatrix[3]; - - double TableRange[2]; - - // Final string to send to the GPU as the fragment program source code. -// char *FragmentCode; -// int FragmentCodeCapacity; - - int ErrorLine; - int ErrorColumn; - char *ErrorString; - - // Store the last projection an raycast method in order to not rebuild - // the fragment code at every call. - int LastParallelProjection; - int LastRayCastMethod; - int LastCroppingMode; - int LastComponent; - int LastShade; - - vtkImageData *SmallInput; - vtkTimeStamp SmallInputBuildTime; - - /** - * Build the fragment shader program that scale and bias a texture - * for window/level purpose. - */ - void BuildScaleBiasProgram(vtkRenderWindow *w); - -#if 0 - vtkIdType LoadedExtent[6]; - double LoadedBounds[6]; - vtkTimeStamp LoadedScalarTime; - int LoadedCellFlag; // point data or cell data (or field data, not handled) ? -#endif - - unsigned int SavedFrameBuffer; // some offscreen mode use a framebuffer too. - - vtkTessellatedBoxSource *BoxSource; - - float *NoiseTexture; - int NoiseTextureSize; // size of one dimension. - unsigned int NoiseTextureId; // GLuint - - bool IgnoreSampleDistancePerPixel; - - vtkMapDataArrayTextureId *ScalarsTextures; // need a list for AMR mode. - vtkMapMaskTextureId *MaskTextures; // need a list for AMR mode. - - vtkRGBTable *RGBTable; - vtkRGBTable *Mask1RGBTable; - vtkRGBTable *Mask2RGBTable; - - vtkOpacityTables *OpacityTables; - - vtkKWScalarField *CurrentScalar; - vtkKWMask *CurrentMask; - - float ActualSampleDistance; - - double LastProgressEventTime; // initial value is 0.0. Expressed in seconds. - - bool PreserveOrientation; - - vtkShaderProgram2 *Program; - vtkShader2 *Main; - vtkShader2 *Projection; - vtkShader2 *Trace; - vtkShader2 *CroppingShader; - vtkShader2 *Component; - vtkShader2 *Shade; - - // Internal Variable used to keep track of whether or render window's size - // changed and therefore we need re-allocation. - bool SizeChanged; - - vtkShaderProgram2 *ScaleBiasProgram; - -private: - vtkOpenGLGPUVolumeRayCastMapper(const vtkOpenGLGPUVolumeRayCastMapper&) VTK_DELETE_FUNCTION; - void operator=(const vtkOpenGLGPUVolumeRayCastMapper&) VTK_DELETE_FUNCTION; -}; - -#endif diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLHAVSVolumeMapper.cxx paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLHAVSVolumeMapper.cxx --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLHAVSVolumeMapper.cxx 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLHAVSVolumeMapper.cxx 1970-01-01 00:00:00.000000000 +0000 @@ -1,1250 +0,0 @@ -/*========================================================================= - -Program: Visualization Toolkit -Module: vtkOpenGLHAVSVolumeMapper.cxx - -Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -All rights reserved. -See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -/* Copyright 2005, 2006 by University of Utah. */ - -#include "vtkOpenGLHAVSVolumeMapper.h" - -#include "vtkCamera.h" -#include "vtkColorTransferFunction.h" -#include "vtkgl.h" -#include "vtkInformation.h" -#include "vtkObjectFactory.h" -#include "vtkOpenGL.h" -#include "vtkOpenGLExtensionManager.h" -#include "vtkPiecewiseFunction.h" -#include "vtkRenderer.h" -#include "vtkRenderWindow.h" -#include "vtkTimerLog.h" -#include "vtkTransform.h" -#include "vtkUnstructuredGrid.h" -#include "vtkUnstructuredGridPartialPreIntegration.h" -#include "vtkVolumeProperty.h" -#include "vtkOpenGLRenderWindow.h" -#include "vtkOpenGLError.h" - -#include "vtkHAVSVolumeMapper_kbufferVP.h" -#include "vtkHAVSVolumeMapper_k2BeginFP.h" -#include "vtkHAVSVolumeMapper_k2FP.h" -#include "vtkHAVSVolumeMapper_k2EndFP.h" -#include "vtkHAVSVolumeMapper_k6BeginFP.h" -#include "vtkHAVSVolumeMapper_k6FP.h" -#include "vtkHAVSVolumeMapper_k6EndFP.h" - -vtkStandardNewMacro(vtkOpenGLHAVSVolumeMapper); - -//---------------------------------------------------------------------------- -// return the correct type of UnstructuredGridVolumeMapper -vtkOpenGLHAVSVolumeMapper::vtkOpenGLHAVSVolumeMapper() -{ - this->VBOVertexName = 0; - this->VBOTexCoordName = 0; - this->VBOVertexIndexName = 0; - this->PsiTableTexture = 0; - this->FramebufferObjectSize = 0; - this->OrderedTriangles = 0; - this->RenderWindow=0; -} - -//---------------------------------------------------------------------------- -// return the correct type of UnstructuredGridVolumeMapper -vtkOpenGLHAVSVolumeMapper::~vtkOpenGLHAVSVolumeMapper() -{ - if (!this->GPUDataStructures) - { - delete [] this->OrderedTriangles; - } -} - -//---------------------------------------------------------------------------- -void vtkOpenGLHAVSVolumeMapper::CheckOpenGLError(const char * str) -{ - int err = glGetError(); (void)str; - if ( err != GL_NO_ERROR && this->GetDebug() ) - { - vtkDebugMacro( << "OpenGL Error: " << str ); - } -} - -//---------------------------------------------------------------------------- -void vtkOpenGLHAVSVolumeMapper::ReleaseGraphicsResources(vtkWindow *renWin) -{ - if (this->Initialized) - { - static_cast(renWin)->MakeCurrent(); - vtkOpenGLClearErrorMacro(); - - this->DeleteShaders(); - - glDisable( vtkgl::VERTEX_PROGRAM_ARB ); - glDisable( vtkgl::FRAGMENT_PROGRAM_ARB ); - - glDeleteTextures(1, reinterpret_cast(&this->TransferFunctionTexture)); - - int numBuffers = (this->KBufferState == VTK_KBUFFER_SIZE_2)? 2 : 4; - for (int i = 0; i < numBuffers; i++) - { - glDeleteTextures(1,reinterpret_cast(&this->FramebufferTextures[i])); - } - - vtkgl::DeleteFramebuffersEXT(1,reinterpret_cast(&this->FramebufferObject)); - this->Initialized = false; - if (this->GPUDataStructures) - { - vtkgl::DeleteBuffers(1, reinterpret_cast(&this->VBOVertexName)); - vtkgl::DeleteBuffers(1, reinterpret_cast(&this->VBOTexCoordName)); - vtkgl::DeleteBuffers(1,reinterpret_cast(&this->VBOVertexIndexName)); - vtkgl::BindBuffer(vtkgl::ARRAY_BUFFER, 0); - vtkgl::BindBuffer(vtkgl::ELEMENT_ARRAY_BUFFER, 0); - } - vtkOpenGLCheckErrorMacro("failed after ReleaseGraphicsResources"); - } - this->Superclass::ReleaseGraphicsResources(renWin); -} - -//---------------------------------------------------------------------------- -void vtkOpenGLHAVSVolumeMapper::Initialize(vtkRenderer *ren, - vtkVolume *vol) -{ - // Check for the required extensions only. - if (!this->SupportedByHardware(ren)) - { - this->InitializationError = vtkHAVSVolumeMapper::UNSUPPORTED_EXTENSIONS; - return; - } - - vtkOpenGLExtensionManager *extensions= - static_cast(ren->GetRenderWindow()) - ->GetExtensionManager(); - - // Load required extensions - - // supports_GL_1_3=1 as checked by this->SupportedByHardware() - // OpenGL 1.3 is required by GL_ARB_draw_buffers, GL_ARB_fragment_program - // and GL_ARB_vertex_program. - // CLAMP_TO_EGDE is core feature of OpenGL 1.2 and - // multitexture is core feature of OpenGL 1.3. - extensions->LoadExtension("GL_VERSION_1_3"); // multitexture - - // supports_draw_buffers as checked by this->SupportedByHardware() - int supports_GL_2_0=extensions->ExtensionSupported( "GL_VERSION_2_0" ); - - if(supports_GL_2_0) - { - extensions->LoadExtension("GL_VERSION_2_0"); - } - else - { - extensions->LoadCorePromotedExtension( "GL_ARB_draw_buffers" ); - } - - // supports_fragment_program && supports_vertex_program as checked - // by this->SupportedByHardware() - extensions->LoadExtension( "GL_ARB_fragment_program" ); - extensions->LoadExtension( "GL_ARB_vertex_program" ); - - // supports_GL_EXT_framebuffer_object==1 as checked - // by this->SupportedByHardware() - extensions->LoadExtension("GL_EXT_framebuffer_object"); - - // GL_ARB_texture_float or GL_ATI_texture_float introduce new tokens but - // no new function: don't need to call LoadExtension. - - // Optional extension. - int supports_GL_1_5=extensions->ExtensionSupported( "GL_VERSION_1_5" ); - int supports_vertex_buffer_object; - - if(supports_GL_1_5) - { - supports_vertex_buffer_object=1; - } - else - { - supports_vertex_buffer_object = - extensions->ExtensionSupported( "GL_ARB_vertex_buffer_object" ); - } - - if(supports_vertex_buffer_object) - { - if(supports_GL_1_5) - { - extensions->LoadExtension("GL_VERSION_1_5"); - } - else - { - extensions->LoadCorePromotedExtension( "GL_ARB_vertex_buffer_object" ); - } - } - - if (!supports_vertex_buffer_object) - { - this->SetGPUDataStructures(false); - } - - this->UpdateProgress(0.0); - - // Initialize triangles and VBOs or Vertex Arrays - this->InitializePrimitives(vol); - - this->UpdateProgress(0.4); - - // Initialize scalars and VBOs - this->InitializeScalars(); - - this->UpdateProgress(0.5); - - // Initialize Level-of-Detail data structures - this->InitializeLevelOfDetail(); - - this->UpdateProgress(0.7); - - // Initialize Lookup tables - this->InitializeLookupTables(vol); - - this->UpdateProgress(0.8); - - // Initialize vertex and scalar storage - this->InitializeGPUDataStructures(); - - this->UpdateProgress(0.9); - - // Initialize shaders - this->InitializeShaders(); - - // Initialize FBOs - this->InitializeFramebufferObject(); - - this->UpdateProgress(1.0); - - this->Initialized = 1; -} - -//---------------------------------------------------------------------------- -// Change GPU data structures state -void vtkOpenGLHAVSVolumeMapper::SetGPUDataStructures(bool gpu) -{ - if(this->GPUDataStructures!=gpu) - { - if(!this->GPUDataStructures) - { - delete [] this->OrderedTriangles; - this->OrderedTriangles=0; - } - this->GPUDataStructures = gpu; - if (this->Initialized) - { - this->InitializeGPUDataStructures(); - } - } -} - -//---------------------------------------------------------------------------- -// Store data structures on GPU if possible -void vtkOpenGLHAVSVolumeMapper::InitializeGPUDataStructures() -{ - vtkOpenGLClearErrorMacro(); - - if (this->GPUDataStructures) - { - if (VBOVertexName) - { - vtkgl::DeleteBuffers(1, reinterpret_cast(&this->VBOVertexName)); - } - if (VBOVertexIndexName) - { - vtkgl::DeleteBuffers(1,reinterpret_cast(&this->VBOVertexIndexName)); - } - if (VBOTexCoordName) - { - vtkgl::DeleteBuffers(1, reinterpret_cast(&this->VBOTexCoordName)); - } - - // Build vertex array - vtkgl::GenBuffers(1, reinterpret_cast(&this->VBOVertexName)); - vtkgl::BindBuffer(vtkgl::ARRAY_BUFFER, this->VBOVertexName); - vtkgl::BufferData(vtkgl::ARRAY_BUFFER, - this->NumberOfVertices*3*sizeof(float), - this->Vertices, vtkgl::STATIC_DRAW); - // Build dynamic vertex index array - vtkgl::GenBuffers(1, reinterpret_cast(&this->VBOVertexIndexName)); - vtkgl::BindBuffer(vtkgl::ELEMENT_ARRAY_BUFFER, - this->VBOVertexIndexName); - vtkgl::BufferData(vtkgl::ELEMENT_ARRAY_BUFFER, - this->NumberOfTriangles*3*sizeof(GLuint), 0, - vtkgl::STREAM_DRAW); - - vtkgl::BindBuffer(vtkgl::ARRAY_BUFFER, 0); - vtkgl::BindBuffer(vtkgl::ELEMENT_ARRAY_BUFFER, 0); - - // Build tex coord array - vtkgl::GenBuffers(1, reinterpret_cast(&this->VBOTexCoordName)); - vtkgl::BindBuffer(vtkgl::ARRAY_BUFFER, this->VBOTexCoordName); - vtkgl::BufferData(vtkgl::ARRAY_BUFFER, - this->NumberOfScalars*sizeof(float), - this->Scalars, vtkgl::STATIC_DRAW); - vtkgl::BindBuffer(vtkgl::ARRAY_BUFFER, 0); - } - else - { - delete [] this->OrderedTriangles; - this->OrderedTriangles = new unsigned int[this->NumberOfTriangles*3]; - } - - vtkOpenGLCheckErrorMacro("failed after InitializeGPUDataStructures"); -} - -//---------------------------------------------------------------------------- -// Vertex and Fragment shaders -void vtkOpenGLHAVSVolumeMapper::InitializeShaders() -{ - vtkOpenGLClearErrorMacro(); - - // Create vertex shader - glEnable( vtkgl::VERTEX_PROGRAM_ARB ); - vtkgl::GenProgramsARB(1, reinterpret_cast(&this->VertexProgram)); - vtkgl::BindProgramARB(vtkgl::VERTEX_PROGRAM_ARB, this->VertexProgram); - vtkgl::ProgramStringARB(vtkgl::VERTEX_PROGRAM_ARB, - vtkgl::PROGRAM_FORMAT_ASCII_ARB, - static_cast(strlen(vtkHAVSVolumeMapper_kbufferVP)), - vtkHAVSVolumeMapper_kbufferVP); - - // Create fragment shaders - glEnable( vtkgl::FRAGMENT_PROGRAM_ARB ); - if (this->KBufferSize == VTK_KBUFFER_SIZE_2) - { - vtkgl::GenProgramsARB(1, - reinterpret_cast(&this->FragmentProgramBegin)); - vtkgl::BindProgramARB(vtkgl::FRAGMENT_PROGRAM_ARB, - this->FragmentProgramBegin); - vtkgl::ProgramStringARB(vtkgl::FRAGMENT_PROGRAM_ARB, - vtkgl::PROGRAM_FORMAT_ASCII_ARB, - static_cast(strlen(vtkHAVSVolumeMapper_k2BeginFP)), - vtkHAVSVolumeMapper_k2BeginFP); - vtkgl::GenProgramsARB(1, reinterpret_cast(&this->FragmentProgram)); - vtkgl::BindProgramARB(vtkgl::FRAGMENT_PROGRAM_ARB, this->FragmentProgram); - vtkgl::ProgramStringARB(vtkgl::FRAGMENT_PROGRAM_ARB, - vtkgl::PROGRAM_FORMAT_ASCII_ARB, - static_cast(strlen(vtkHAVSVolumeMapper_k2FP)), - vtkHAVSVolumeMapper_k2FP); - vtkgl::GenProgramsARB(1, reinterpret_cast(&this->FragmentProgramEnd)); - vtkgl::BindProgramARB(vtkgl::FRAGMENT_PROGRAM_ARB, - this->FragmentProgramEnd); - vtkgl::ProgramStringARB(vtkgl::FRAGMENT_PROGRAM_ARB, - vtkgl::PROGRAM_FORMAT_ASCII_ARB, - static_cast(strlen(vtkHAVSVolumeMapper_k2EndFP)), - vtkHAVSVolumeMapper_k2EndFP); - } - else - { - vtkgl::GenProgramsARB(1, - reinterpret_cast(&this->FragmentProgramBegin)); - vtkgl::BindProgramARB(vtkgl::FRAGMENT_PROGRAM_ARB, - this->FragmentProgramBegin); - vtkgl::ProgramStringARB(vtkgl::FRAGMENT_PROGRAM_ARB, - vtkgl::PROGRAM_FORMAT_ASCII_ARB, - static_cast(strlen(vtkHAVSVolumeMapper_k6BeginFP)), - vtkHAVSVolumeMapper_k6BeginFP); - vtkgl::GenProgramsARB(1, reinterpret_cast(&this->FragmentProgram)); - vtkgl::BindProgramARB(vtkgl::FRAGMENT_PROGRAM_ARB, this->FragmentProgram); - vtkgl::ProgramStringARB(vtkgl::FRAGMENT_PROGRAM_ARB, - vtkgl::PROGRAM_FORMAT_ASCII_ARB, - static_cast(strlen(vtkHAVSVolumeMapper_k6FP)), - vtkHAVSVolumeMapper_k6FP); - vtkgl::GenProgramsARB(1, reinterpret_cast(&this->FragmentProgramEnd)); - vtkgl::BindProgramARB(vtkgl::FRAGMENT_PROGRAM_ARB, - this->FragmentProgramEnd); - vtkgl::ProgramStringARB(vtkgl::FRAGMENT_PROGRAM_ARB, - vtkgl::PROGRAM_FORMAT_ASCII_ARB, - static_cast(strlen(vtkHAVSVolumeMapper_k6EndFP)), - vtkHAVSVolumeMapper_k6EndFP); - } - - // Disable shaders - vtkgl::BindProgramARB(vtkgl::VERTEX_PROGRAM_ARB, 0); - vtkgl::BindProgramARB(vtkgl::FRAGMENT_PROGRAM_ARB, 0); - glDisable( vtkgl::VERTEX_PROGRAM_ARB ); - glDisable( vtkgl::FRAGMENT_PROGRAM_ARB ); - - vtkOpenGLCheckErrorMacro("failed after InitializeShaders"); -} - -//---------------------------------------------------------------------------- -void vtkOpenGLHAVSVolumeMapper::DeleteShaders() -{ - vtkgl::DeleteProgramsARB(1, reinterpret_cast(&this->VertexProgram)); - vtkgl::DeleteProgramsARB(1, - reinterpret_cast(&this->FragmentProgramBegin)); - vtkgl::DeleteProgramsARB(1, reinterpret_cast(&this->FragmentProgram)); - vtkgl::DeleteProgramsARB(1, - reinterpret_cast(&this->FragmentProgramEnd)); - - vtkOpenGLCheckErrorMacro("failed after DeleteShaders"); -} - -//---------------------------------------------------------------------------- -// Build the lookup tables used for partial pre-integration -void vtkOpenGLHAVSVolumeMapper::InitializeLookupTables(vtkVolume *vol) -{ - vtkOpenGLClearErrorMacro(); - this->Superclass::InitializeLookupTables(vol); - - // Create a 1D texture for transfer function look up - glGenTextures(1, reinterpret_cast(&this->TransferFunctionTexture)); - glBindTexture(GL_TEXTURE_1D, this->TransferFunctionTexture); - glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA8, this->TransferFunctionSize,0, - GL_RGBA,GL_FLOAT, this->TransferFunction); - - if (!this->PsiTableTexture) - { - vtkUnstructuredGridPartialPreIntegration *ppi = - vtkUnstructuredGridPartialPreIntegration::New(); - ppi->BuildPsiTable(); - int tableSize = 0; - float *psiTable = ppi->GetPsiTable(tableSize); - - // Create a 2D texture for the PSI lookup table - glGenTextures(1, reinterpret_cast(&this->PsiTableTexture)); - glBindTexture(GL_TEXTURE_2D, this->PsiTableTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8, tableSize, tableSize, - 0, GL_LUMINANCE, GL_FLOAT, psiTable); - ppi->Delete(); - } - vtkOpenGLCheckErrorMacro("failed after InitializeLookupTables"); -} - -//---------------------------------------------------------------------------- -// Initialize FBO and attach color and depth textures. -void vtkOpenGLHAVSVolumeMapper::InitializeFramebufferObject() -{ - vtkOpenGLClearErrorMacro(); - - GLint maxRB; - glGetIntegerv(vtkgl::MAX_RENDERBUFFER_SIZE_EXT, &maxRB); - int texSize = (maxRB > 1024)? 1024 : maxRB; - int numBuffers = (this->KBufferState == VTK_KBUFFER_SIZE_2)? 2 : 4; - - if (!this->Initialized) - { - // Create FBO - vtkgl::GenFramebuffersEXT(1, - reinterpret_cast(&this->FramebufferObject)); - vtkOpenGLCheckErrorMacro("creating FBO"); - } - else - { - glDeleteTextures(numBuffers, - reinterpret_cast(this->FramebufferTextures)); - vtkgl::DeleteRenderbuffersEXT(1, - reinterpret_cast(&this->DepthTexture)); - } - - numBuffers = (this->KBufferSize == VTK_KBUFFER_SIZE_2)? 2 : 4; - - // Create FBO textures - glGenTextures(numBuffers, reinterpret_cast(this->FramebufferTextures)); - for (int i = 0; i < numBuffers; i++) - { - glBindTexture(GL_TEXTURE_2D, this->FramebufferTextures[i]); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, vtkgl::RGBA32F_ARB, texSize, texSize, 0, - GL_RGBA, GL_FLOAT, 0); - } - - vtkOpenGLCheckErrorMacro("creating fbo textures"); - - // Bind framebuffer object - GLint savedFrameBuffer; - glGetIntegerv(vtkgl::FRAMEBUFFER_BINDING_EXT,&savedFrameBuffer); - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT, this->FramebufferObject); - vtkOpenGLCheckErrorMacro("binding FBO"); - - // Generate depth buffer texture for framebuffer - vtkgl::GenRenderbuffersEXT(1, reinterpret_cast(&this->DepthTexture)); - - // Attach texture to framebuffer color buffer - vtkgl::FramebufferTexture2DEXT( vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, - this->FramebufferTextures[0], 0 ); - vtkgl::FramebufferTexture2DEXT( vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, - this->FramebufferTextures[1], 0 ); - if (numBuffers == 4) - { - vtkgl::FramebufferTexture2DEXT( vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT2_EXT, - GL_TEXTURE_2D, - this->FramebufferTextures[2], 0 ); - vtkgl::FramebufferTexture2DEXT( vtkgl::FRAMEBUFFER_EXT, - vtkgl::COLOR_ATTACHMENT3_EXT, - GL_TEXTURE_2D, - this->FramebufferTextures[3], 0 ); - } - - // Attach depth texture to framebuffer - vtkgl::BindRenderbufferEXT(vtkgl::RENDERBUFFER_EXT, this->DepthTexture); - vtkgl::RenderbufferStorageEXT(vtkgl::RENDERBUFFER_EXT, - vtkgl::DEPTH_COMPONENT24, - texSize, texSize); - vtkgl::FramebufferRenderbufferEXT(vtkgl::FRAMEBUFFER_EXT, - vtkgl::DEPTH_ATTACHMENT_EXT, - vtkgl::RENDERBUFFER_EXT, - this->DepthTexture); - - vtkOpenGLCheckErrorMacro("attach textures to FBO"); - - // Validate FBO after attaching textures - if (vtkgl::CheckFramebufferStatusEXT(vtkgl::FRAMEBUFFER_EXT) != - vtkgl::FRAMEBUFFER_COMPLETE_EXT && this->GetDebug()) - { - vtkDebugMacro( << "FBO incomplete" ); - } - - // Disable FBO rendering - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT,savedFrameBuffer); - - this->FramebufferObjectSize = texSize; - this->KBufferState = this->KBufferSize; - - vtkOpenGLCheckErrorMacro("failed after InitializeFramebufferObject"); -} - -//---------------------------------------------------------------------------- -void vtkOpenGLHAVSVolumeMapper::Render(vtkRenderer *ren, - vtkVolume *vol) -{ - ren->GetRenderWindow()->MakeCurrent(); - - this->RenderWindow=ren->GetRenderWindow(); - - if (!this->Initialized) - { - this->InitializationError = - vtkHAVSVolumeMapper::NO_INIT_ERROR; - this->Initialize(ren, vol); - if (this->CheckInitializationError()) - { - return; - } - } - - if (ren->GetRenderWindow()->CheckAbortStatus()) - { - return; - } - - // Check to see if we need to update the lookup table - if ((this->ColorTransferFunctionMTime < - vol->GetProperty()->GetRGBTransferFunction()->GetMTime()) - ||(this->AlphaTransferFunctionMTime < - vol->GetProperty()->GetScalarOpacity()->GetMTime()) - ||(this->UnitDistance != vol->GetProperty()->GetScalarOpacityUnitDistance())) - { - this->InitializeLookupTables(vol); - this->ColorTransferFunctionMTime.Modified(); - this->AlphaTransferFunctionMTime.Modified(); - } - - if (ren->GetRenderWindow()->CheckAbortStatus()) - { - return; - } - - // Check to see if we need to update the scalars - if ((this->ScalarsMTime < this->MTime) - || (this->ScalarsMTime < this->GetInput()->GetMTime()) - || (this->LastVolume != vol)) - { - this->InitializationError = - vtkHAVSVolumeMapper::NO_INIT_ERROR; - this->InitializeScalars(); - this->InitializeGPUDataStructures(); - if (this->CheckInitializationError()) - return; - this->ScalarsMTime.Modified(); - } - - if (ren->GetRenderWindow()->CheckAbortStatus()) - { - return; - } - - // Check to see if we need to update the geometry - if ((this->UnstructuredGridMTime < this->GetInput()->GetMTime()) - || (this->UnstructuredGridMTime < this->MTime)) - { - this->InitializationError = - vtkHAVSVolumeMapper::NO_INIT_ERROR; - this->InitializePrimitives(vol); - this->InitializeLevelOfDetail(); - this->InitializeGPUDataStructures(); - if (this->CheckInitializationError()) - return; - this->UnstructuredGridMTime.Modified(); - } - - if (ren->GetRenderWindow()->CheckAbortStatus()) - { - return; - } - - this->Timer->StartTimer(); - - this->RenderHAVS(ren); - this->LastVolume = vol; - - this->Timer->StopTimer(); - this->TimeToDraw = static_cast(this->Timer->GetElapsedTime()); - - // Update level-of-detail - this->UpdateLevelOfDetail(TimeToDraw); -} - -//---------------------------------------------------------------------------- -// The OpenGL rendering -void vtkOpenGLHAVSVolumeMapper::RenderHAVS(vtkRenderer *ren) -{ - vtkOpenGLClearErrorMacro(); - - glPushAttrib(GL_ENABLE_BIT | - GL_CURRENT_BIT | - GL_COLOR_BUFFER_BIT | - GL_STENCIL_BUFFER_BIT | - GL_DEPTH_BUFFER_BIT | - GL_POLYGON_BIT | - GL_TEXTURE_BIT | - GL_LIGHTING_BIT | - GL_TRANSFORM_BIT | - GL_VIEWPORT_BIT); - - // Setup OpenGL state - glShadeModel(GL_SMOOTH); - glDisable(GL_DEPTH_TEST); - glDisable(GL_CULL_FACE); - glDisable(GL_LIGHTING); - glDisable(GL_NORMALIZE); - glDisable(GL_BLEND); - glDisable(GL_SCISSOR_TEST); - glDisable(GL_STENCIL_TEST); - - int screenWidth, screenHeight; - ren->GetTiledSize(&screenWidth, &screenHeight); - - // Keep shaders up to date - if (this->KBufferSize != this->KBufferState) - { - this->DeleteShaders(); - this->InitializeShaders(); - // Keep FBO up to date - this->InitializeFramebufferObject(); - } - - int vpWidth = screenWidth; - int vpHeight = screenHeight; - if (screenWidth > this->FramebufferObjectSize) - { - vpWidth = this->FramebufferObjectSize; - } - if (screenHeight > this->FramebufferObjectSize) - { - vpHeight = this->FramebufferObjectSize; - } - - // Bind geometry arrays - if (this->GPUDataStructures) - { - glEnableClientState(GL_VERTEX_ARRAY); - vtkgl::BindBuffer(vtkgl::ARRAY_BUFFER, this->VBOVertexName); - glVertexPointer(3, GL_FLOAT, 0, static_cast(NULL)); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - vtkgl::BindBuffer(vtkgl::ARRAY_BUFFER, this->VBOTexCoordName); - glTexCoordPointer(1, GL_FLOAT, 0, static_cast(NULL)); - - vtkgl::BindBuffer(vtkgl::ELEMENT_ARRAY_BUFFER, this->VBOVertexIndexName); - } - else - { - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, this->Vertices); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(1, GL_FLOAT, 0, this->Scalars); - } - - if (ren->GetRenderWindow()->CheckAbortStatus()) - { - vtkOpenGLCheckErrorMacro("failed during Render"); - return; - } - - // Object-space sorting - double *e = ren->GetActiveCamera()->GetPosition(); - float eye[3]; - eye[0] = e[0]; - eye[1] = e[1]; - eye[2] = e[2]; - if (this->GPUDataStructures) - { - this->OrderedTriangles = - static_cast(vtkgl::MapBuffer(vtkgl::ELEMENT_ARRAY_BUFFER, - vtkgl::WRITE_ONLY)); - } - - this->PartialVisibilitySort(eye); - - if (this->GPUDataStructures) - { - vtkgl::UnmapBuffer(vtkgl::ELEMENT_ARRAY_BUFFER); - } - - this->UpdateProgress(0.4); - if (ren->GetRenderWindow()->CheckAbortStatus()) - { - vtkOpenGLCheckErrorMacro("failed during Render"); - return; - } - - // Get depth range from OpenGL state for correct z - GLfloat depthRange[2]; - glGetFloatv(GL_DEPTH_RANGE, depthRange); - - // Get the current z-buffer - float *zbuffer = - ren->GetRenderWindow()->GetZbufferData(0,0,screenWidth-1,screenHeight-1); - - // Enable FBO Rendering - GLint savedFrameBuffer; - glGetIntegerv(vtkgl::FRAMEBUFFER_BINDING_EXT,&savedFrameBuffer); - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT, this->FramebufferObject); - - // Setup z-buffer - this->SetupFBOZBuffer(vpWidth, vpHeight, depthRange[0], depthRange[1], - zbuffer); - delete [] zbuffer; - - // Setup multiple render targets - this->SetupFBOMRT(); - - // Draw Initialization pass - this->DrawFBOInit(vpWidth, vpHeight, depthRange[0], depthRange[1]); - - // Draw Geometry pass - this->DrawFBOGeometry(); - this->UpdateProgress(0.9); - - // Draw Flushing pass - this->DrawFBOFlush(vpWidth, vpHeight, depthRange[0], depthRange[1]); - - // Disable FBO rendering - vtkgl::BindFramebufferEXT(vtkgl::FRAMEBUFFER_EXT, savedFrameBuffer); - - glPopAttrib(); - - // Blend Result into framebuffer - this->DrawBlend(vpWidth, vpHeight, depthRange[0], depthRange[1]); - - this->UpdateProgress(1.0); - vtkOpenGLCheckErrorMacro("failed after Render"); -} - -//---------------------------------------------------------------------------- -// Draw the current z-buffer into the FBO z-buffer for correct compositing -// with existing geometry or widgets. -void vtkOpenGLHAVSVolumeMapper::SetupFBOZBuffer(int screenWidth, - int screenHeight, - float depthNear, - float depthFar, - float *zbuffer) -{ - vtkOpenGLClearErrorMacro(); - - // Setup view for z-buffer copy - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(0.0, static_cast(screenWidth), 0.0, - static_cast(screenHeight), - static_cast(depthNear), static_cast(depthFar)); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - // Enable FBO z-buffer - glEnable(GL_DEPTH_TEST); - glClearDepth(depthFar); - glClear(GL_DEPTH_BUFFER_BIT); - glDepthFunc(GL_LESS); - - glRasterPos2i(0,0); - glPixelStorei(GL_PACK_ALIGNMENT, 1); - glDrawPixels(screenWidth, screenHeight, GL_DEPTH_COMPONENT, GL_FLOAT, - zbuffer); - glFlush(); - - // Make z-buffer Read only - glDepthMask(GL_FALSE); - - // Reset view state after z-buffer copy - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - - vtkOpenGLCheckErrorMacro("failed after SetupFBOZBuffer"); -} - -//---------------------------------------------------------------------------- -// Setup reading and writing into multiple textures from an FBO -void vtkOpenGLHAVSVolumeMapper::SetupFBOMRT() -{ - vtkOpenGLClearErrorMacro(); - - int numBuffers = (this->KBufferSize == VTK_KBUFFER_SIZE_2)? 2 : 4; - GLenum buffers[4] = {vtkgl::COLOR_ATTACHMENT0_EXT, - vtkgl::COLOR_ATTACHMENT1_EXT, - vtkgl::COLOR_ATTACHMENT2_EXT, - vtkgl::COLOR_ATTACHMENT3_EXT}; - vtkgl::DrawBuffers(numBuffers, buffers); - - // Bind textures for reading - glEnable(GL_TEXTURE_2D); - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - glBindTexture(GL_TEXTURE_2D, this->FramebufferTextures[0]); - - vtkgl::ActiveTexture(vtkgl::TEXTURE1); - glBindTexture(GL_TEXTURE_2D, this->FramebufferTextures[1]); - - if (numBuffers == 2) - { - // Bind lookup tables - glEnable(GL_TEXTURE_2D); - vtkgl::ActiveTexture(vtkgl::TEXTURE2); - glBindTexture(GL_TEXTURE_2D, this->PsiTableTexture); - - glEnable(GL_TEXTURE_1D); - vtkgl::ActiveTexture(vtkgl::TEXTURE3); - glBindTexture(GL_TEXTURE_1D,this->TransferFunctionTexture); - } - else - { - // Bind lookup tables - vtkgl::ActiveTexture(vtkgl::TEXTURE2); - glBindTexture(GL_TEXTURE_2D, this->FramebufferTextures[2]); - - vtkgl::ActiveTexture(vtkgl::TEXTURE3); - glBindTexture(GL_TEXTURE_2D, this->FramebufferTextures[3]); - - glEnable(GL_TEXTURE_2D); - vtkgl::ActiveTexture(vtkgl::TEXTURE4); - glBindTexture(GL_TEXTURE_2D, this->PsiTableTexture); - - glEnable(GL_TEXTURE_1D); - vtkgl::ActiveTexture(vtkgl::TEXTURE5); - glBindTexture(GL_TEXTURE_1D,this->TransferFunctionTexture); - } - - vtkOpenGLCheckErrorMacro("SetupFBOMRT"); -} - -//---------------------------------------------------------------------------- -// Draw a screen-aligned plane with the init fragment shader enabled. The -// init fragment shader clears the framebuffer to 0 and the k-buffers to -1. -void vtkOpenGLHAVSVolumeMapper::DrawFBOInit(int screenWidth, int screenHeight, - float depthNear, float depthFar) -{ - vtkOpenGLClearErrorMacro(); - - // Bind initializing fragment shader - glEnable(vtkgl::FRAGMENT_PROGRAM_ARB); - vtkgl::BindProgramARB(vtkgl::FRAGMENT_PROGRAM_ARB, - this->FragmentProgramBegin); - - // Setup ortho view - glViewport(0,0,screenWidth,screenHeight); - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(0.0, static_cast(screenWidth), 0.0, - static_cast(screenHeight), - static_cast(depthNear), static_cast(depthFar)); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - // Draw a quad to initialize the k-buffer - glBegin(GL_QUADS); - glVertex3f(0.0, 0.0, 0.0); - glVertex3f(static_cast(screenWidth), 0.0, 0.0); - glVertex3f(static_cast(screenWidth), - static_cast(screenHeight), 0.0); - glVertex3f(0.0, static_cast(screenHeight), 0.0); - glEnd(); - - vtkgl::BindProgramARB(vtkgl::FRAGMENT_PROGRAM_ARB, 0); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - - vtkOpenGLCheckErrorMacro("failed after DrawFBOInit"); -} - -//---------------------------------------------------------------------------- -// Draw the geometry using the k-buffer to sort and composite into the -// framebuffer. -void vtkOpenGLHAVSVolumeMapper::DrawFBOGeometry() -{ - vtkOpenGLClearErrorMacro(); - - // Bind shaders - glEnable(vtkgl::VERTEX_PROGRAM_ARB); - vtkgl::BindProgramARB(vtkgl::VERTEX_PROGRAM_ARB, this->VertexProgram); - vtkgl::BindProgramARB(vtkgl::FRAGMENT_PROGRAM_ARB, this->FragmentProgram); - - float scale = this->MaxEdgeLength; - if (this->LevelOfDetail || !this->PartiallyRemoveNonConvexities) - { - scale = this->LevelOfDetailMaxEdgeLength; - } - float params[4] = {1.0f/this->FramebufferObjectSize, - 1.0f/this->FramebufferObjectSize, - scale, - 0.0f}; - vtkgl::ProgramLocalParameter4fvARB(vtkgl::FRAGMENT_PROGRAM_ARB, 0, params); - - // Draw geometry - if (this->GPUDataStructures) - { - glDrawElements(GL_TRIANGLES, this->LevelOfDetailTriangleCount*3, - GL_UNSIGNED_INT, static_cast(NULL)); - } - else - { - glDrawElements(GL_TRIANGLES, this->LevelOfDetailTriangleCount*3, - GL_UNSIGNED_INT, this->OrderedTriangles); - } - - vtkgl::BindProgramARB(vtkgl::FRAGMENT_PROGRAM_ARB, 0); - vtkgl::BindProgramARB(vtkgl::VERTEX_PROGRAM_ARB, 0); - glDisable( vtkgl::VERTEX_PROGRAM_ARB); - - vtkOpenGLCheckErrorMacro("failed after DrawFBOGeometry"); -} - -//---------------------------------------------------------------------------- -// Draw a k-1 screen-aligned planes to flush the valid entries from the -// k-buffer. -void vtkOpenGLHAVSVolumeMapper::DrawFBOFlush(int screenWidth, - int screenHeight, - float depthNear, float depthFar) -{ - vtkOpenGLClearErrorMacro(); - - float scale = this->MaxEdgeLength; - if (this->LevelOfDetail || !this->PartiallyRemoveNonConvexities) - { - scale = this->LevelOfDetailMaxEdgeLength; - } - float params[4] = {1.0f/this->FramebufferObjectSize, - 1.0f/this->FramebufferObjectSize, - scale, - 0.0f}; - - // Bind fragment shader - vtkgl::BindProgramARB(vtkgl::FRAGMENT_PROGRAM_ARB, this->FragmentProgramEnd); - vtkgl::ProgramLocalParameter4fvARB(vtkgl::FRAGMENT_PROGRAM_ARB, 0, params); - - - // Setup ortho view - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(0.0, static_cast(screenWidth), 0.0, - static_cast(screenHeight), - static_cast(depthNear), static_cast(depthFar)); - - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - // Draw k-1 quads to flush k-buffer - int flushCount = (this->KBufferSize == VTK_KBUFFER_SIZE_2)? 1 : 5; - for (int i = 0; i < flushCount; i++) - { - glBegin(GL_QUADS); - glVertex3f(0.0, 0.0, 0.0); - glVertex3f(0.0, static_cast(screenHeight), 0.0); - glVertex3f(static_cast(screenWidth), - static_cast(screenHeight), 0.0); - glVertex3f(static_cast(screenWidth), 0.0, 0.0); - glEnd(); - } - - // Disable shader - vtkgl::BindProgramARB(vtkgl::FRAGMENT_PROGRAM_ARB, 0); - glDisable( vtkgl::FRAGMENT_PROGRAM_ARB ); - - // Reset view - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - - // Disable Textures - if (this->KBufferSize == VTK_KBUFFER_SIZE_2) - { - vtkgl::ActiveTexture(vtkgl::TEXTURE2); - glDisable(GL_TEXTURE_2D); - vtkgl::ActiveTexture(vtkgl::TEXTURE3); - glDisable(GL_TEXTURE_1D); - } - else - { - vtkgl::ActiveTexture(vtkgl::TEXTURE4); - glDisable(GL_TEXTURE_2D); - vtkgl::ActiveTexture(vtkgl::TEXTURE5); - glDisable(GL_TEXTURE_1D); - - } - - vtkgl::ActiveTexture(vtkgl::TEXTURE1); - glDisable(GL_TEXTURE_2D); - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - glDisable(GL_TEXTURE_2D); - - glDisable(GL_DEPTH_TEST); - - glFinish(); - - // Disable vertex arrays - if (this->GPUDataStructures) - { - vtkgl::BindBuffer(vtkgl::ARRAY_BUFFER, 0); - vtkgl::BindBuffer(vtkgl::ELEMENT_ARRAY_BUFFER, 0); - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - } - else - { - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - } - - vtkOpenGLCheckErrorMacro("failed after DrawFBOFlush"); -} - -//---------------------------------------------------------------------------- -// Blend the result from the off screen rendering into the framebuffer by -// drawing a textured screen-aligned plane. This avoids expensive data -// transfers between GPU and CPU. -void vtkOpenGLHAVSVolumeMapper::DrawBlend(int screenWidth, int screenHeight, - float depthNear, float depthFar) -{ - vtkOpenGLClearErrorMacro(); - - // Setup draw buffer - glDrawBuffer(GL_BACK); - - // Setup 2D view - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(0.0, screenWidth, 0.0, screenHeight, depthNear, depthFar); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - // Bind resulting texture - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - - glBindTexture(GL_TEXTURE_2D, this->FramebufferTextures[0]); - glEnable(GL_TEXTURE_2D); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - float max_u =static_cast(screenWidth)/static_cast(this->FramebufferObjectSize); - float max_v = static_cast(screenHeight)/static_cast(this->FramebufferObjectSize); - if (max_u > 1.0) { max_u = 1.0; } - if (max_v > 1.0) { max_v = 1.0; } - - // Setup blending. Use the same non-standard blending function as PT to get - // similar images. - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - - // Draw textured screen-aligned plane - glColor4f(0.0, 0.0, 0.0, 0.0); - glBegin(GL_QUADS); - glTexCoord2f(0.0, 0.0); - glVertex2f(0.0, 0.0); - glTexCoord2f(max_u, 0.0); - glVertex2f(screenWidth, 0.0); - glTexCoord2f(max_u, max_v); - glVertex2f(screenWidth, screenHeight); - glTexCoord2f(0.0, max_v); - glVertex2f(0.0, screenHeight); - glEnd(); - - // Reset view - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - - // Restore OpenGL state - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - - vtkOpenGLCheckErrorMacro("failed after DrawBlend"); -} - -//---------------------------------------------------------------------------- -void vtkOpenGLHAVSVolumeMapper::PrintSelf(ostream& os, vtkIndent indent) -{ - if(this->RenderWindow!=0) - { - vtkOpenGLExtensionManager *extensions= - static_cast(this->RenderWindow.GetPointer()) - ->GetExtensionManager(); - if ( this->Initialized ) - { - os << indent << "Supports GL_VERSION_1_3 (edge_clamp (1.2) and" - << " multitexture (1.3) minimal version required by" - << " GL_ARB_draw_buffers): " - << extensions->ExtensionSupported( "GL_VERSION_1_3" ); - - os << indent << "Supports GL_VERSION_2_0 (GL_ARB_draw_buffers is a core" - << "feature): " - << extensions->ExtensionSupported( "GL_VERSION_2_0" ); - - os << indent << "Supports GL_ARB_draw_buffers: " - << extensions->ExtensionSupported( "GL_ARB_draw_buffers" ); - - os << indent << "Supports GL_EXT_framebuffer_object: " - << extensions->ExtensionSupported( "GL_EXT_framebuffer_object" ) - << endl; - os << indent << "Supports GL_ARB_vertex_program: " - << extensions->ExtensionSupported( "GL_ARB_vertex_program" ) << endl; - os << indent << "Supports GL_ARB_fragment_program: " - << extensions->ExtensionSupported( "GL_ARB_fragment_program" ) << endl; - os << indent << "Supports GL_ARB_texture_float" - << extensions->ExtensionSupported( "GL_ARB_texture_float" ) << endl; - os << indent << "Supports GL_ATI_texture_float: " - << extensions->ExtensionSupported( "GL_ATI_texture_float" ) << endl; - - os << indent << "Supports GL_VERSION_1_5 (for optional core feature VBO): " - << extensions->ExtensionSupported( "GL_VERSION_1_5" ) <ExtensionSupported( "GL_ARB_vertex_buffer_object" ) - <FramebufferObjectSize << endl; - - this->Superclass::PrintSelf(os,indent); -} - -//---------------------------------------------------------------------------- -// Check the OpenGL extension manager for GPU features necessary for the -// HAVS algorithm. -bool vtkOpenGLHAVSVolumeMapper::SupportedByHardware(vtkRenderer *r) -{ - vtkOpenGLExtensionManager *extensions= - static_cast(r->GetRenderWindow()) - ->GetExtensionManager(); - - // os mesa notes: - // 9.1.4 -- test fails with open gl errors (mesa bug) - // 9.2.0 w/llvmpipe -- test passes - if ( extensions->DriverIsMesa() - && !(extensions->DriverGLRendererIsOSMesa() - && extensions->DriverGLRendererHasToken("llvmpipe")) - && !extensions->GetIgnoreDriverBugs("Mesa FBO bugs") ) - { - return false; - } - - // Temporarily filter out the Macs, as this mapper makes the ATI driver crash - // (RogueResearch2 on VTK, ATI Radeon X1600 OpenGL Engine 2.0 ATI-1.4.56) and - // makes the Nvidia driver render some corrupted image (kamino on ParaView3 - // dashboard NVIDIA GeForce 7300 GT 2.0 NVIDIA-1.4.56). - // This mapper does not actually use texture3D but it is known that Macs - // only support texture3d through OpenGL 1.2 API, not as an extension, so - // this is a good way to filter them out. - int iAmAMac=!extensions->ExtensionSupported("GL_EXT_texture3D"); - - // OpenGL 1.3 is required by GL_ARB_draw_buffers, GL_ARB_fragment_program - // and GL_ARB_vertex_program - // CLAMP_TO_EGDE is core feature of OpenGL 1.2 and - // multitexture is core feature of OpenGL 1.3. - int supports_GL_1_3=extensions->ExtensionSupported( "GL_VERSION_1_3" ); - - - int supports_GL_2_0=extensions->ExtensionSupported( "GL_VERSION_2_0" ); - int supports_draw_buffers; - if(supports_GL_2_0) - { - supports_draw_buffers=1; - } - else - { - supports_draw_buffers= - extensions->ExtensionSupported( "GL_ARB_draw_buffers" ); - } - - int supports_GL_ARB_fragment_program = - extensions->ExtensionSupported( "GL_ARB_fragment_program" ); - int supports_GL_ARB_vertex_program = - extensions->ExtensionSupported( "GL_ARB_vertex_program" ); - - int supports_GL_EXT_framebuffer_object = - extensions->ExtensionSupported( "GL_EXT_framebuffer_object"); - - // GL_ARB_texture_float or GL_ATI_texture_float introduce new tokens but - // no new function: don't need to call LoadExtension. - - int supports_GL_ARB_texture_float = - extensions->ExtensionSupported( "GL_ARB_texture_float" ); - int supports_GL_ATI_texture_float = - extensions->ExtensionSupported( "GL_ATI_texture_float" ); - - return !iAmAMac && supports_GL_1_3 && supports_draw_buffers && - supports_GL_ARB_fragment_program && supports_GL_ARB_vertex_program && - supports_GL_EXT_framebuffer_object && - ( supports_GL_ARB_texture_float || supports_GL_ATI_texture_float); -} - -//---------------------------------------------------------------------------- -int vtkOpenGLHAVSVolumeMapper::FillInputPortInformation(int port, - vtkInformation* info) -{ - if(!this->Superclass::FillInputPortInformation(port, info)) - { - return 0; - } - info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkUnstructuredGrid"); - return 1; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLHAVSVolumeMapper.h paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLHAVSVolumeMapper.h --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLHAVSVolumeMapper.h 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLHAVSVolumeMapper.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,210 +0,0 @@ -/*========================================================================= - -Program: Visualization Toolkit -Module: vtkOpenGLHAVSVolumeMapper.h - -Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -All rights reserved. -See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -/* Copyright 2005, 2006 by University of Utah. */ - -/** - * @class vtkOpenGLHAVSVolumeMapper - * @brief Hardware-Assisted - * Visibility Sorting unstructured grid mapper, OpenGL implementation - * - * - * - * vtkHAVSVolumeMapper is a class that renders polygonal data - * (represented as an unstructured grid) using the Hardware-Assisted - * Visibility Sorting (HAVS) algorithm. First the unique triangles are sorted - * in object space, then they are sorted in image space using a fixed size - * A-buffer implemented on the GPU called the k-buffer. The HAVS algorithm - * excels at rendering large datasets quickly. The trade-off is that the - * algorithm may produce some rendering artifacts due to an insufficient k - * size (currently 2 or 6 is supported) or read/write race conditions. - * - * A built in level-of-detail (LOD) approach samples the geometry using one of - * two heuristics (field or area). If LOD is enabled, the amount of geometry - * that is sampled and rendered changes dynamically to stay within the target - * frame rate. The field sampling method generally works best for datasets - * with cell sizes that don't vary much in size. On the contrary, the area - * sampling approach gives better approximations when the volume has a lot of - * variation in cell size. - * - * The HAVS algorithm uses several advanced features on graphics hardware. - * The k-buffer sorting network is implemented using framebuffer objects - * (FBOs) with multiple render targets (MRTs). Therefore, only cards that - * support these features can run the algorithm (at least an ATI 9500 or an - * NVidia NV40 (6600)). - * - * - * @attention - * Several issues had to be addressed to get the HAVS algorithm working within - * the vtk framework. These additions forced the code to forsake speed for - * the sake of compliance and robustness. - * - * @attention - * The HAVS algorithm operates on the triangles that compose the mesh. - * Therefore, before rendering, the cells are decomposed into unique triangles - * and stored on the GPU for efficient rendering. The use of GPU data - * structures is only recommended if the entire geometry can fit in graphics - * memory. Otherwise this feature should be disabled. - * - * @attention - * Another new feature is the handling of mixed data types (eg., polygonal - * data with volume data). This is handled by reading the z-buffer from the - * current window and copying it into the framebuffer object for off-screen - * rendering. The depth test is then enabled so that the volume only appears - * over the opaque geometry. Finally, the results of the off-screen rendering - * are blended into the framebuffer as a transparent, view-aligned texture. - * - * @attention - * Instead of using a preintegrated 3D lookup table for storing the ray - * integral, this implementation uses partial pre-integration. This improves - * the performance of dynamic transfer function updates by avoiding a costly - * preprocess of the table. - * - * @attention - * A final change to the original algorithm is the handling of non-convexities - * in the mesh. Due to read/write hazards that may create undesired artifacts - * with non-convexities when using a inside/outside toggle in the fragment - * program, another approach was employed. To handle non-convexities, the - * fragment shader determines if a ray-gap is larger than the max cell size - * and kill the fragment if so. This approximation performs rather well in - * practice but may miss small non-convexities. - * - * @attention - * For more information on the HAVS algorithm see: - * - * @attention - * "Hardware-Assisted Visibility Sorting for Unstructured Volume - * Rendering" by S. P. Callahan, M. Ikits, J. L. D. Comba, and C. T. Silva, - * IEEE Transactions of Visualization and Computer Graphics; May/June 2005. - * - * @attention - * For more information on the Level-of-Detail algorithm, see: - * - * @attention - * "Interactive Rendering of Large Unstructured Grids Using Dynamic - * Level-of-Detail" by S. P. Callahan, J. L. D. Comba, P. Shirley, and - * C. T. Silva, Proceedings of IEEE Visualization '05, Oct. 2005. - * - * - * @par Acknowledgments: - * This code was developed by Steven P. Callahan under the supervision - * of Prof. Claudio T. Silva. The code also contains contributions - * from Milan Ikits, Linh Ha, Huy T. Vo, Carlos E. Scheidegger, and - * Joao L. D. Comba. - * - * @par Acknowledgments: - * The work was supported by grants, contracts, and gifts from the - * National Science Foundation, the Department of Energy, the Army - * Research Office, and IBM. - * - * @par Acknowledgments: - * The port of HAVS to VTK and ParaView has been primarily supported - * by Sandia National Labs. - * -*/ - -#ifndef vtkOpenGLHAVSVolumeMapper_h -#define vtkOpenGLHAVSVolumeMapper_h - -#include "vtkRenderingVolumeOpenGLModule.h" // For export macro -#include "vtkHAVSVolumeMapper.h" - -#include "vtkWeakPointer.h" // to cache the vtkRenderWindow -class vtkRenderer; -class vtkRenderWindow; - - -class VTKRENDERINGVOLUMEOPENGL_EXPORT vtkOpenGLHAVSVolumeMapper - : public vtkHAVSVolumeMapper -{ -public: - static vtkOpenGLHAVSVolumeMapper *New(); - vtkTypeMacro(vtkOpenGLHAVSVolumeMapper, - vtkHAVSVolumeMapper); - void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; - - /** - * Render the volume - */ - void Render(vtkRenderer *ren, vtkVolume *vol) VTK_OVERRIDE; - - /** - * Release any graphics resources that are being consumed by this volume - * renderer. - */ - void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE; - - /** - * Set/get whether or not the data structures should be stored on the GPU - * for better peformance. - */ - void SetGPUDataStructures(bool) VTK_OVERRIDE; - - /** - * Check hardware support for the HAVS algorithm. Necessary - * features include off-screen rendering, 32-bit fp textures, multiple - * render targets, and framebuffer objects. - * Subclasses must override this method to indicate if supported by Hardware. - */ - bool SupportedByHardware(vtkRenderer *r) VTK_OVERRIDE; -protected: - - vtkOpenGLHAVSVolumeMapper(); - ~vtkOpenGLHAVSVolumeMapper() VTK_OVERRIDE; - int FillInputPortInformation(int port, vtkInformation* info) VTK_OVERRIDE; - - void Initialize(vtkRenderer *ren, vtkVolume *vol) VTK_OVERRIDE; - virtual void InitializeLookupTables(vtkVolume *vol); - void InitializeGPUDataStructures(); - void InitializeShaders(); - void DeleteShaders(); - void InitializeFramebufferObject(); - - void RenderHAVS(vtkRenderer *ren); - void SetupFBOZBuffer(int screenWidth, int screenHeight, float depthNear, float depthFar, - float *zbuffer); - void SetupFBOMRT(); - void DrawFBOInit(int screenWidth, int screenHeight, float depthNear, float depthFar); - void DrawFBOGeometry(); - void DrawFBOFlush(int screenWidth, int screenHeight, float depthNear, float depthFar); - void DrawBlend(int screenWidth, int screenHeight, float depthNear, float depthFar); - - void CheckOpenGLError(const char *str); - - // GPU - unsigned int VBOVertexName; - unsigned int VBOTexCoordName; - unsigned int VBOVertexIndexName; - unsigned int VertexProgram; - unsigned int FragmentProgramBegin; - unsigned int FragmentProgram; - unsigned int FragmentProgramEnd; - unsigned int FramebufferObject; - int FramebufferObjectSize; - unsigned int FramebufferTextures[4]; - unsigned int DepthTexture; - - // Lookup Tables - unsigned int PsiTableTexture; - unsigned int TransferFunctionTexture; - - vtkWeakPointer RenderWindow; - -private: - vtkOpenGLHAVSVolumeMapper(const vtkOpenGLHAVSVolumeMapper&) VTK_DELETE_FUNCTION; - void operator=(const vtkOpenGLHAVSVolumeMapper&) VTK_DELETE_FUNCTION; -}; - -#endif diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLProjectedAAHexahedraMapper.cxx paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLProjectedAAHexahedraMapper.cxx --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLProjectedAAHexahedraMapper.cxx 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLProjectedAAHexahedraMapper.cxx 1970-01-01 00:00:00.000000000 +0000 @@ -1,774 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkOpenGLProjectedAAHexahedraMapper.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// High quality volume renderer for axis-aligned hexahedra -// Implementation by Stephane Marchesin (stephane.marchesin@gmail.com) -// CEA/DIF - Commissariat a l'Energie Atomique, Centre DAM Ile-De-France -// BP12, F-91297 Arpajon, France. -// -// This file implements the paper -// "High-Quality, Semi-Analytical Volume Rendering for AMR Data", -// Stephane Marchesin and Guillaume Colin de Verdiere, IEEE Vis 2009. - - -#include "vtkOpenGLProjectedAAHexahedraMapper.h" - -#include "vtkCamera.h" -#include "vtkCellArray.h" -#include "vtkCellCenterDepthSort.h" -#include "vtkCellData.h" -#include "vtkCellIterator.h" -#include "vtkColorTransferFunction.h" -#include "vtkDoubleArray.h" -#include "vtkFloatArray.h" -#include "vtkIdList.h" -#include "vtkIdTypeArray.h" -#include "vtkGarbageCollector.h" -#include "vtkMath.h" -#include "vtkNew.h" -#include "vtkObjectFactory.h" -#include "vtkOpenGLExtensionManager.h" -#include "vtkOpenGLRenderWindow.h" -#include "vtkPiecewiseFunction.h" -#include "vtkPointData.h" -#include "vtkRenderer.h" -#include "vtkRenderWindow.h" -#include "vtkTimerLog.h" -#include "vtkUnsignedCharArray.h" -#include "vtkUnstructuredGrid.h" -#include "vtkUnstructuredGridPreIntegration.h" -#include "vtkVisibilitySort.h" -#include "vtkVolume.h" -#include "vtkVolumeProperty.h" -#include "vtkgl.h" -#include "vtkShaderProgram2.h" -#include "vtkShader2.h" -#include "vtkSmartPointer.h" -#include "vtkUniformVariables.h" -#include "vtkShader2Collection.h" -#include "vtkOpenGLError.h" - -#include -#include - -// Shader code -extern const char *vtkProjectedAAHexahedraMapper_VS; -extern const char *vtkProjectedAAHexahedraMapper_GS; -extern const char *vtkProjectedAAHexahedraMapper_FS; - -// ---------------------------------------------------------------------------- - -vtkStandardNewMacro(vtkOpenGLProjectedAAHexahedraMapper); - -// ---------------------------------------------------------------------------- -vtkOpenGLProjectedAAHexahedraMapper::vtkOpenGLProjectedAAHexahedraMapper() -{ - this->ConvertedPoints = vtkFloatArray::New(); - this->ConvertedScalars = vtkFloatArray::New(); - - this->LastProperty = NULL; - - this->PreintTexture = 0; - this->MaxCellSize = 0; - - this->GaveError = 0; - this->Initialized=false; - this->Shader=0; -} - -// ---------------------------------------------------------------------------- -vtkOpenGLProjectedAAHexahedraMapper::~vtkOpenGLProjectedAAHexahedraMapper() -{ - this->ConvertedPoints->Delete(); - this->ConvertedScalars->Delete(); - if(this->Shader!=0) - { - this->Shader->Delete(); - } -} - -// ---------------------------------------------------------------------------- -void vtkOpenGLProjectedAAHexahedraMapper::PrintSelf(ostream &os, - vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} - -// ---------------------------------------------------------------------------- -bool vtkOpenGLProjectedAAHexahedraMapper::IsRenderSupported(vtkRenderWindow *w) -{ - vtkOpenGLExtensionManager *e= - static_cast(w)->GetExtensionManager(); - - bool texture3D=e->ExtensionSupported("GL_VERSION_1_2") || - e->ExtensionSupported("GL_EXT_texture3D"); - - bool multiTexture=e->ExtensionSupported("GL_VERSION_1_3") || - e->ExtensionSupported("GL_ARB_multitexture"); - - bool glsl=e->ExtensionSupported("GL_VERSION_2_0") || - (e->ExtensionSupported("GL_ARB_shading_language_100") && - e->ExtensionSupported("GL_ARB_shader_objects") && - e->ExtensionSupported("GL_ARB_vertex_shader") && - e->ExtensionSupported("GL_ARB_fragment_shader")); - - bool geometry_shader=e->ExtensionSupported("GL_EXT_geometry_shader4")==1; - - return texture3D && multiTexture && glsl && geometry_shader; -} - -// ---------------------------------------------------------------------------- -void vtkOpenGLProjectedAAHexahedraMapper::Initialize( - vtkRenderer *ren, - vtkVolume *vtkNotUsed(vol)) -{ - vtkOpenGLExtensionManager *e=static_cast( - ren->GetRenderWindow())->GetExtensionManager(); - - bool gl12=e->ExtensionSupported("GL_VERSION_1_2")==1; - bool gl13=e->ExtensionSupported("GL_VERSION_1_3")==1; - bool gl20=e->ExtensionSupported("GL_VERSION_2_0")==1; - - bool texture3D=gl12 || e->ExtensionSupported("GL_EXT_texture3D"); - bool multiTexture=gl13 || e->ExtensionSupported("GL_ARB_multitexture"); - bool glsl=gl20 || (e->ExtensionSupported("GL_ARB_shading_language_100") && - e->ExtensionSupported("GL_ARB_shader_objects") && - e->ExtensionSupported("GL_ARB_vertex_shader") && - e->ExtensionSupported("GL_ARB_fragment_shader")); - bool geometry_shader=e->ExtensionSupported("GL_EXT_geometry_shader4")==1; - - bool result=texture3D && multiTexture && glsl && geometry_shader; - - if(result) - { - if(gl12) - { - e->LoadExtension("GL_VERSION_1_2"); - } - else - { - e->LoadCorePromotedExtension("GL_EXT_texture3D"); - } - if(gl13) - { - e->LoadExtension("GL_VERSION_1_3"); - } - else - { - e->LoadCorePromotedExtension("GL_ARB_multitexture"); - } - if(gl20) - { - e->LoadExtension("GL_VERSION_2_0"); - } - else - { - e->LoadCorePromotedExtension("GL_ARB_shading_language_100"); - e->LoadCorePromotedExtension("GL_ARB_shader_objects"); - e->LoadCorePromotedExtension("GL_ARB_vertex_shader"); - e->LoadCorePromotedExtension("GL_ARB_fragment_shader"); - } - e->LoadExtension("GL_EXT_geometry_shader4"); - - this->Initialized=true; - this->CreateProgram(ren->GetRenderWindow()); - pos_points = new float[3*max_points]; - min_points = new float[3*max_points]; - node_data1 = new float[4*max_points]; - node_data2 = new float[4*max_points]; - } -} - -// ---------------------------------------------------------------------------- -// sort, iterate the hexahedra and call the rendering function -void vtkOpenGLProjectedAAHexahedraMapper::Render(vtkRenderer *renderer, - vtkVolume *volume) -{ - vtkOpenGLClearErrorMacro(); - - if ( !this->Initialized ) - { - this->Initialize(renderer, volume); - } - vtkUnstructuredGridBase *input = this->GetInput(); - vtkVolumeProperty *property = volume->GetProperty(); - - float last_max_cell_size = this->MaxCellSize; - - // Check to see if input changed. - if ( (this->InputAnalyzedTime < this->MTime) - || (this->InputAnalyzedTime < input->GetMTime()) ) - { - this->GaveError = 0; - - if (input->GetNumberOfCells() == 0) - { - // Apparently, the input has no cells. Just do nothing. - return; - } - - vtkIdType npts, *pts; - vtkSmartPointer cellIter = - vtkSmartPointer::Take(input->NewCellIterator()); - for (cellIter->InitTraversal(); !cellIter->IsDoneWithTraversal(); - cellIter->GoToNextCell()) - { - npts = cellIter->GetNumberOfPoints(); - pts = cellIter->GetPointIds()->GetPointer(0); - int j; - if (npts != 8) - { - if (!this->GaveError) - { - vtkErrorMacro("Encountered non-hexahedral cell!"); - this->GaveError = 1; - } - continue; - } - - double p[3]; - input->GetPoint(pts[0], p); - double min[3] = {p[0],p[1],p[2]}, - max[3] = {p[0],p[1],p[2]}; - - for(j = 1; j < npts; j++) - { - input->GetPoint(pts[j], p); - - if (p[0]max[0]) - { - max[0] = p[0]; - } - if (p[1]>max[1]) - { - max[1] = p[1]; - } - if (p[2]>max[2]) - { - max[2] = p[2]; - } - } - - float size = static_cast( - vtkMath::Distance2BetweenPoints(min, max)); - if (size > this->MaxCellSize) - { - this->MaxCellSize = size; - } - } - - this->InputAnalyzedTime.Modified(); - } - - if (renderer->GetRenderWindow()->CheckAbortStatus() || this->GaveError) - { - return; - } - - // Check to see if we need to rebuild preintegartion texture. - if ( !this->PreintTexture - || (last_max_cell_size != this->MaxCellSize) - || (this->LastProperty != property) - || (this->PreintTextureTime < property->GetMTime()) ) - { - if (!this->PreintTexture) - { - GLuint texid; - glGenTextures(1, &texid); - this->PreintTexture = texid; - } - vtkDataArray *scalars = this->GetScalars(input, this->ScalarMode, - this->ArrayAccessMode, - this->ArrayId, this->ArrayName, - this->UsingCellColors); - if (!scalars) - { - vtkErrorMacro(<< "Can't use projected tetrahedra without scalars!"); - return; - } - - this->UpdatePreintegrationTexture(volume, scalars); - - this->PreintTextureTime.Modified(); - - this->LastProperty = property; - } - - if (renderer->GetRenderWindow()->CheckAbortStatus()) - { - return; - } - - this->Timer->StartTimer(); - - this->ProjectHexahedra(renderer, volume); - - this->Timer->StopTimer(); - this->TimeToDraw = this->Timer->GetElapsedTime(); - - vtkOpenGLCheckErrorMacro("failed after Render"); -} - -// ---------------------------------------------------------------------------- -void vtkOpenGLProjectedAAHexahedraMapper::UpdatePreintegrationTexture( - vtkVolume *volume, - vtkDataArray *scalars) -{ - vtkOpenGLClearErrorMacro(); - - // rebuild the preintegration texture - vtkUnstructuredGridPreIntegration *pi= - vtkUnstructuredGridPreIntegration::New(); - pi->Initialize(volume, scalars); - // We only render the first field - float *table = pi->GetPreIntegrationTable(0); - int ScalarSize = pi->GetIntegrationTableScalarResolution(); - int LengthSize = pi->GetIntegrationTableLengthResolution(); - - this->ScalarScale = - static_cast(pi->GetIntegrationTableScalarScale()); - this->ScalarResolution= - static_cast(pi->GetIntegrationTableScalarResolution()); - this->ScalarShift= - static_cast(pi->GetIntegrationTableScalarShift()); - this->LengthScale = static_cast( - (pi->GetIntegrationTableLengthResolution() - 2) / - pi->GetIntegrationTableLengthScale()); - - glBindTexture(vtkgl::TEXTURE_3D, this->PreintTexture); - glTexParameteri(vtkgl::TEXTURE_3D,vtkgl::TEXTURE_WRAP_R, - vtkgl::CLAMP_TO_EDGE); - glTexParameteri(vtkgl::TEXTURE_3D, GL_TEXTURE_WRAP_S, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(vtkgl::TEXTURE_3D, GL_TEXTURE_WRAP_T, vtkgl::CLAMP_TO_EDGE); - glTexParameteri(vtkgl::TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(vtkgl::TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - vtkgl::TexImage3D(vtkgl::TEXTURE_3D, 0, vtkgl::RGBA16_EXT, ScalarSize, - ScalarSize, LengthSize, 0, GL_RGBA, GL_FLOAT, table); - - pi->Delete(); - - vtkOpenGLCheckErrorMacro("failed after UpdatePreintegrationTexture"); -} - -// ---------------------------------------------------------------------------- -void vtkOpenGLProjectedAAHexahedraMapper::CreateProgram(vtkRenderWindow *w) -{ - this->Shader=vtkShaderProgram2::New(); - this->Shader->SetContext(static_cast(w)); - - vtkShader2Collection *shaders=this->Shader->GetShaders(); - - vtkShader2 *vs=vtkShader2::New(); - vs->SetType(VTK_SHADER_TYPE_VERTEX); - vs->SetContext(this->Shader->GetContext()); - vs->SetSourceCode(vtkProjectedAAHexahedraMapper_VS); - shaders->AddItem(vs); - vs->Delete(); - - vtkShader2 *gs=vtkShader2::New(); - gs->SetType(VTK_SHADER_TYPE_GEOMETRY); - gs->SetContext(this->Shader->GetContext()); - gs->SetSourceCode(vtkProjectedAAHexahedraMapper_GS); - shaders->AddItem(gs); - gs->Delete(); - - vtkShader2 *fs=vtkShader2::New(); - fs->SetType(VTK_SHADER_TYPE_FRAGMENT); - fs->SetContext(this->Shader->GetContext()); - fs->SetSourceCode(vtkProjectedAAHexahedraMapper_FS); - shaders->AddItem(fs); - fs->Delete(); - - this->Shader->SetGeometryVerticesOut(24); - this->Shader->SetGeometryTypeIn(VTK_GEOMETRY_SHADER_IN_TYPE_POINTS); - this->Shader->SetGeometryTypeOut( - VTK_GEOMETRY_SHADER_OUT_TYPE_TRIANGLE_STRIP); - - this->Shader->Build(); -} - -// ---------------------------------------------------------------------------- -void vtkOpenGLProjectedAAHexahedraMapper::SetState(double *observer) -{ - vtkOpenGLClearErrorMacro(); - - glDepthMask(GL_FALSE); - - // save the default blend function. - glPushAttrib(GL_COLOR_BUFFER_BIT); - - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - - glEnable(GL_CULL_FACE); - glFrontFace(GL_CW); - glCullFace(GL_BACK); - glDepthFunc( GL_ALWAYS ); - glDisable( GL_DEPTH_TEST ); - - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - glBindTexture(vtkgl::TEXTURE_3D,this->PreintTexture); - - vtkUniformVariables *v=this->Shader->GetUniformVariables(); - - // preintegration table - int ivalue=0; - v->SetUniformi("preintegration_table",1,&ivalue); - - // observer position - float fvalue[3]; - fvalue[0]=static_cast(observer[0]); - fvalue[1]=static_cast(observer[1]); - fvalue[2]=static_cast(observer[2]); - v->SetUniformf("observer",3,fvalue); - - // max length of preint table - v->SetUniformf("length_max",1,&this->LengthScale); - - this->Shader->Use(); - - glEnableClientState( GL_VERTEX_ARRAY ); - glVertexPointer( 3, GL_FLOAT, 0, pos_points); - - vtkgl::ActiveTexture( vtkgl::TEXTURE0_ARB ); - vtkgl::ClientActiveTexture(vtkgl::TEXTURE0_ARB); - glEnableClientState( GL_TEXTURE_COORD_ARRAY ); - glTexCoordPointer( 3, GL_FLOAT, 0, min_points); - - vtkgl::ActiveTexture( vtkgl::TEXTURE1_ARB ); - vtkgl::ClientActiveTexture(vtkgl::TEXTURE1_ARB); - glEnableClientState( GL_TEXTURE_COORD_ARRAY ); - glTexCoordPointer( 4, GL_FLOAT, 0, node_data1); - - vtkgl::ActiveTexture( vtkgl::TEXTURE2_ARB ); - vtkgl::ClientActiveTexture(vtkgl::TEXTURE2_ARB); - glEnableClientState( GL_TEXTURE_COORD_ARRAY ); - glTexCoordPointer( 4, GL_FLOAT, 0, node_data2); - - this->num_points = 0; - - vtkOpenGLCheckErrorMacro("failed after SetState"); -} - -// ---------------------------------------------------------------------------- -void vtkOpenGLProjectedAAHexahedraMapper::RenderHexahedron(float vmin[3], - float vmax[3], - float scalars[8]) -{ - this->pos_points[num_points * 3 + 0] = vmin[0]; - this->pos_points[num_points * 3 + 1] = vmin[1]; - this->pos_points[num_points * 3 + 2] = vmin[2]; - - this->min_points[num_points * 3 + 0] = vmax[0]; - this->min_points[num_points * 3 + 1] = vmax[1]; - this->min_points[num_points * 3 + 2] = vmax[2]; - - this->node_data1[num_points * 4 + 0] = scalars[0]; - this->node_data1[num_points * 4 + 1] = scalars[1]; - this->node_data1[num_points * 4 + 2] = scalars[2]; - this->node_data1[num_points * 4 + 3] = scalars[3]; - - this->node_data2[num_points * 4 + 0] = scalars[4]; - this->node_data2[num_points * 4 + 1] = scalars[5]; - this->node_data2[num_points * 4 + 2] = scalars[6]; - this->node_data2[num_points * 4 + 3] = scalars[7]; - - num_points++; - - // need to flush? - if (num_points >= max_points) - { - glDrawArrays(GL_POINTS, 0, num_points); - num_points=0; - } -} - -// ---------------------------------------------------------------------------- -void vtkOpenGLProjectedAAHexahedraMapper::UnsetState() -{ - vtkOpenGLClearErrorMacro(); - - // flush what remains of our points - if (this->num_points>0) - { - glDrawArrays(GL_POINTS, 0, this->num_points); - this->num_points = 0; - } - - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - - this->Shader->Restore(); - - // Restore the blend function. - glPopAttrib(); - - glBindTexture(vtkgl::TEXTURE_3D, 0); - - glDepthMask(GL_TRUE); - - vtkOpenGLCheckErrorMacro("failed fater UnsetState"); -} - -// ---------------------------------------------------------------------------- -template -void vtkOpenGLProjectedAAHexahedraMapperConvertScalars( - const point_type *in_scalars, - vtkIdType num_scalars, - float *out_scalars) -{ - for(int i=0;i(in_scalars[i]); - } -} - -// ---------------------------------------------------------------------------- -// convert all our scalars to floating point -float* vtkOpenGLProjectedAAHexahedraMapper::ConvertScalars( - vtkDataArray* inScalars) -{ - this->ConvertedScalars->SetNumberOfComponents(1); - this->ConvertedScalars->SetNumberOfTuples(inScalars->GetNumberOfTuples()); - switch (inScalars->GetDataType()) - { - vtkTemplateMacro(vtkOpenGLProjectedAAHexahedraMapperConvertScalars( - static_cast( - inScalars->GetVoidPointer(0)), - inScalars->GetNumberOfTuples(), - this->ConvertedScalars->GetPointer(0) ) ); - } - return this->ConvertedScalars->GetPointer(0); -} - -// ---------------------------------------------------------------------------- -template -void vtkOpenGLProjectedAAHexahedraMapperConvertPoints( - const point_type *in_points, - vtkIdType num_points, - float *out_points) -{ - for(int i=0;i(in_points[i]); - } -} - -// ---------------------------------------------------------------------------- -// convert all our points to floating point -float* vtkOpenGLProjectedAAHexahedraMapper::ConvertPoints(vtkPoints* inPoints) -{ - this->ConvertedPoints->SetNumberOfComponents(3); - this->ConvertedPoints->SetNumberOfTuples(inPoints->GetNumberOfPoints()); - switch (inPoints->GetDataType()) - { - vtkTemplateMacro(vtkOpenGLProjectedAAHexahedraMapperConvertPoints( - static_cast( - inPoints->GetVoidPointer(0)), - inPoints->GetNumberOfPoints(), - this->ConvertedPoints->GetPointer(0) ) ); - } - return this->ConvertedPoints->GetPointer(0); -} - -// ---------------------------------------------------------------------------- -void vtkOpenGLProjectedAAHexahedraMapper::ProjectHexahedra( - vtkRenderer *renderer, - vtkVolume *volume) -{ - vtkUnstructuredGridBase *input = this->GetInput(); - - this->VisibilitySort->SetInput(input); - this->VisibilitySort->SetDirectionToBackToFront(); - this->VisibilitySort->SetModelTransform(volume->GetMatrix()); - this->VisibilitySort->SetCamera(renderer->GetActiveCamera()); - this->VisibilitySort->SetMaxCellsReturned(1000); - - double* observer = renderer->GetActiveCamera()->GetPosition(); - - this->VisibilitySort->InitTraversal(); - - float* points = ConvertPoints(input->GetPoints()); - - float* scalars = ConvertScalars(this->GetScalars(input, this->ScalarMode, - this->ArrayAccessMode, - this->ArrayId, - this->ArrayName, - this->UsingCellColors) ); - - if (renderer->GetRenderWindow()->CheckAbortStatus()) - { - return; - } - - this->SetState(observer); - - vtkIdType totalnumcells = input->GetNumberOfCells(); - vtkIdType numcellsrendered = 0; - - // Let's do it! - vtkNew cellPtIds; - for (vtkIdTypeArray *sorted_cell_ids = this->VisibilitySort->GetNextCells(); - sorted_cell_ids != NULL; - sorted_cell_ids = this->VisibilitySort->GetNextCells()) - { - this->UpdateProgress(static_cast(numcellsrendered)/ - static_cast(totalnumcells)); - if (renderer->GetRenderWindow()->CheckAbortStatus()) - { - break; - } - vtkIdType *cell_ids = sorted_cell_ids->GetPointer(0); - vtkIdType num_cell_ids = sorted_cell_ids->GetNumberOfTuples(); - for (vtkIdType i = 0; i < num_cell_ids; i++) - { - vtkIdType cell = cell_ids[i]; - input->GetCellPoints(cell, cellPtIds.GetPointer()); - - float corner_scalars[8]; - - // get the data for the current hexahedron - vtkIdType index = cellPtIds->GetId(0); - float* p = points + 3 * index; - - float vmin[3] = {p[0],p[1],p[2]}, - vmax[3] = {p[0],p[1],p[2]}; - - int j; - for(j = 1; j < 8; j++) - { - index = cellPtIds->GetId(j); - - p = points + 3 * index; - if (p[0]vmax[0]) - { - vmax[0] = p[0]; - } - if (p[1]>vmax[1]) - { - vmax[1] = p[1]; - } - if (p[2]>vmax[2]) - { - vmax[2] = p[2]; - } - } - - - float s = static_cast( - (scalars[index] * this->ScalarScale+this->ScalarShift + 0.5) - /this->ScalarResolution); - float mins = s; - float maxs = s; - - corner_scalars[0] = s; - - for(j = 0; j < 8; j++) - { - index = cellPtIds->GetId(j); - - p = points + 3 * index; - int corner = 0; - if (p[0]==vmax[0]) - { - corner += 4; - } - if (p[1]==vmax[1]) - { - corner += 2; - } - if (p[2]==vmax[2]) - { - corner += 1; - } - static const int corner_tbl[] = {0, 4, 1, 5, 3, 7, 2, 6}; - - s = static_cast( - (scalars[index] * this->ScalarScale + this->ScalarShift + 0.5) - /this->ScalarResolution); - if (s < mins) - { - mins = s; - } - if (s > maxs) - { - maxs = s; - } - - corner_scalars[corner_tbl[corner]] = s; - - } - - this->RenderHexahedron(vmin,vmax,corner_scalars); - - } - - numcellsrendered += num_cell_ids; - } - - this->UnsetState(); - - this->UpdateProgress(1.0); -} - -// ---------------------------------------------------------------------------- -void vtkOpenGLProjectedAAHexahedraMapper::ReleaseGraphicsResources( - vtkWindow *win) -{ - if (this->PreintTexture) - { - GLuint texid = this->PreintTexture; - glDeleteTextures(1, &texid); - vtkOpenGLCheckErrorMacro("failed at glDeleteTextures"); - this->PreintTexture = 0; - } - this->Superclass::ReleaseGraphicsResources(win); - if(this->Initialized) - { - delete[] pos_points; - delete[] min_points; - delete[] node_data1; - delete[] node_data2; - this->Initialized=false; - } - if(this->Shader!=0) - { - this->Shader->ReleaseGraphicsResources(); - } -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLProjectedAAHexahedraMapper.h paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLProjectedAAHexahedraMapper.h --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLProjectedAAHexahedraMapper.h 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLProjectedAAHexahedraMapper.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,157 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkOpenGLProjectedAAHexahedraMapper.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -/** - * @class vtkOpenGLProjectedAAHexahedraMapper - * @brief OpenGL implementation of a volume mapper for axis-aligned hexahedra - * - * High quality volume renderer for axis-aligned hexahedra - * - * @par Implementation: - * Implementation by Stephane Marchesin (stephane.marchesin@gmail.com) - * CEA/DIF - Commissariat a l'Energie Atomique, Centre DAM Ile-De-France - * BP12, F-91297 Arpajon, France. - * - * @par Implementation: - * This mapper implements the paper - * "High-Quality, Semi-Analytical Volume Rendering for AMR Data", - * Stephane Marchesin and Guillaume Colin de Verdiere, IEEE Vis 2009. -*/ - -#ifndef vtkOpenGLProjectedAAHexahedraMapper_h -#define vtkOpenGLProjectedAAHexahedraMapper_h - -#include "vtkRenderingVolumeOpenGLModule.h" // For export macro -#include "vtkProjectedAAHexahedraMapper.h" - -class vtkFloatArray; -class vtkPoints; -class vtkUnsignedCharArray; -class vtkVisibilitySort; -class vtkVolumeProperty; -class vtkRenderWindow; -class vtkShaderProgram2; - -class VTKRENDERINGVOLUMEOPENGL_EXPORT vtkOpenGLProjectedAAHexahedraMapper - : public vtkProjectedAAHexahedraMapper -{ -public: - vtkTypeMacro(vtkOpenGLProjectedAAHexahedraMapper, - vtkProjectedAAHexahedraMapper); - static vtkOpenGLProjectedAAHexahedraMapper *New(); - void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE; - - /** - * Check if the required OpenGL extensions are supported by the OpenGL - * context attached to the render window `w'. - */ - bool IsRenderSupported(vtkRenderWindow *w) VTK_OVERRIDE; - - void Render(vtkRenderer *renderer, vtkVolume *volume) VTK_OVERRIDE; - - void ReleaseGraphicsResources(vtkWindow *window) VTK_OVERRIDE; - -protected: - vtkOpenGLProjectedAAHexahedraMapper(); - ~vtkOpenGLProjectedAAHexahedraMapper() VTK_OVERRIDE; - - /** - * Convert the input scalar values to floats. - */ - float* ConvertScalars(vtkDataArray* inScalars); - - /** - * Convert the input cell coordinates to floats. - */ - float* ConvertPoints(vtkPoints* inPoints); - - /** - * Iterate over all the hexahedal input cells, - * sort and render them. - */ - virtual void ProjectHexahedra(vtkRenderer *renderer, vtkVolume *volume); - - /** - * Load the OpenGL extensions and allocate the vertex arrays. - */ - void Initialize(vtkRenderer *renderer, vtkVolume *volume); - - /** - * Update the preintegration texture; this is needed whenever the mesh - * changes. - */ - void UpdatePreintegrationTexture(vtkVolume *vome, vtkDataArray *scalars); - - /** - * Create the OpenGL geometry/vertex/fragment programs for - * hexahedral cell rendering. - */ - void CreateProgram(vtkRenderWindow *w); - - /** - * Set the OpenGL state for hexahedral cell rendering. - */ - void SetState(double* observer); - - /** - * Render a single axis-aligned hexahedal cell. - */ - void RenderHexahedron(float min[3], float max[3], float scalars[8]); - - /** - * Restore the OpenGL state touched by SetState(). - */ - void UnsetState(); - - - bool Initialized; - - int UsingCellColors; - - float MaxCellSize; - vtkTimeStamp InputAnalyzedTime; - vtkTimeStamp PreintTextureTime; - vtkTimeStamp ColorsMappedTime; - - unsigned int PreintTexture; - - // OpenGL arrays for primitive submission - float* pos_points; - float* min_points; - float* node_data1; - float* node_data2; - - // number of pending points - int num_points; - static const int max_points = 4096; - - // our shader - vtkShaderProgram2 *Shader; - - int GaveError; - - float ScalarScale, ScalarShift, ScalarResolution; - float LengthScale; - - vtkVolumeProperty *LastProperty; - - vtkFloatArray *ConvertedPoints; - vtkFloatArray *ConvertedScalars; - -private: - vtkOpenGLProjectedAAHexahedraMapper(const vtkOpenGLProjectedAAHexahedraMapper &) VTK_DELETE_FUNCTION; - void operator=(const vtkOpenGLProjectedAAHexahedraMapper &) VTK_DELETE_FUNCTION; -}; - -#endif diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLProjectedTetrahedraMapper.cxx paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLProjectedTetrahedraMapper.cxx --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLProjectedTetrahedraMapper.cxx 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLProjectedTetrahedraMapper.cxx 1970-01-01 00:00:00.000000000 +0000 @@ -1,1110 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkOpenGLProjectedTetrahedraMapper.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -/* - * Copyright 2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the - * U.S. Government. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that this Notice and any - * statement of authorship are reproduced on all copies. - */ - -#include "vtkOpenGLProjectedTetrahedraMapper.h" - -#include "vtkCamera.h" -#include "vtkCellArray.h" -#include "vtkCellData.h" -#include "vtkCellIterator.h" -#include "vtkFloatArray.h" -#include "vtkIdList.h" -#include "vtkIdTypeArray.h" -#include "vtkMath.h" -#include "vtkMatrix4x4.h" -#include "vtkNew.h" -#include "vtkObjectFactory.h" -#include "vtkPointData.h" -#include "vtkRenderer.h" -#include "vtkOpenGLRenderWindow.h" -#include "vtkOpenGLExtensionManager.h" -#include "vtkSmartPointer.h" -#include "vtkTimerLog.h" -#include "vtkUnsignedCharArray.h" -#include "vtkUnstructuredGrid.h" -#include "vtkVisibilitySort.h" -#include "vtkVolume.h" -#include "vtkVolumeProperty.h" - -#include "vtkOpenGL.h" -#include "vtkOpenGLError.h" - -#include "vtkgl.h" - -#include -#include - -// static int tet_faces[4][3] = { {1,2,3}, {2,0,3}, {0,1,3}, {0,2,1} }; -static int tet_edges[6][2] = { {0,1}, {1,2}, {2,0}, - {0,3}, {1,3}, {2,3} }; - -const int SqrtTableSize = 2048; - -//----------------------------------------------------------------------------- -class vtkOpenGLProjectedTetrahedraMapper::vtkInternals -{ -public: - vtkInternals() - { - this->FrameBufferObjectId = 0; - this->RenderBufferObjectIds[0] = 0; - this->RenderBufferObjectIds[1] = 0; - this->OpacityTexture = 0; - } - GLuint FrameBufferObjectId; - GLuint RenderBufferObjectIds[2]; - GLuint OpacityTexture; -}; - -//----------------------------------------------------------------------------- -vtkStandardNewMacro(vtkOpenGLProjectedTetrahedraMapper); - -//----------------------------------------------------------------------------- -vtkOpenGLProjectedTetrahedraMapper::vtkOpenGLProjectedTetrahedraMapper() -{ - this->TransformedPoints = vtkFloatArray::New(); - this->Colors = vtkUnsignedCharArray::New(); - this->LastProperty = NULL; - this->MaxCellSize = 0; - this->GaveError = 0; - this->SqrtTable = new float[SqrtTableSize]; - this->SqrtTableBias = 0.0; - this->Initialized = false; - this->CurrentFBOWidth = -1; - this->CurrentFBOHeight = -1; - this->FloatingPointFrameBufferResourcesAllocated = false; - this->Internals = new vtkOpenGLProjectedTetrahedraMapper::vtkInternals; - this->UseFloatingPointFrameBuffer = true; - this->CanDoFloatingPointFrameBuffer = false; - this->HasHardwareSupport = false; -} - -//----------------------------------------------------------------------------- -vtkOpenGLProjectedTetrahedraMapper::~vtkOpenGLProjectedTetrahedraMapper() -{ - this->ReleaseGraphicsResources(NULL); - this->TransformedPoints->Delete(); - this->Colors->Delete(); - delete this->Internals; - delete[] this->SqrtTable; -} - -//----------------------------------------------------------------------------- -void vtkOpenGLProjectedTetrahedraMapper::PrintSelf(ostream &os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - os << indent << "VisibilitySort: " << this->VisibilitySort << endl; - os << indent << "UseFloatingPointFrameBuffer: " - << (this->UseFloatingPointFrameBuffer ? "True" : "False") << endl; -} - -//----------------------------------------------------------------------------- -bool vtkOpenGLProjectedTetrahedraMapper::IsSupported(vtkRenderWindow *rwin) -{ - vtkOpenGLRenderWindow *context = vtkOpenGLRenderWindow::SafeDownCast(rwin); - if (!context) - { - vtkErrorMacro( - << "Support for " << rwin->GetClassName() << " not implemented"); - return false; - } - - vtkOpenGLExtensionManager *extensions = context->GetExtensionManager(); - bool texSupport - = (extensions->ExtensionSupported("GL_VERSION_1_3") != 0) || - (extensions->ExtensionSupported("GL_ARB_multitexture") != 0); - - // use render to FBO when it's supported - this->CanDoFloatingPointFrameBuffer = false; - if (this->UseFloatingPointFrameBuffer) - { - this->CanDoFloatingPointFrameBuffer - = (extensions->ExtensionSupported("GL_ARB_framebuffer_object") != 0) - && (extensions->ExtensionSupported("GL_ARB_draw_buffers") != 0) - && (extensions->ExtensionSupported("GL_ARB_texture_float") != 0); -#ifndef NDEBUG - if (!this->CanDoFloatingPointFrameBuffer) - { - vtkWarningMacro( - "Missing FBO support. The algorithm may produce visual artifacts."); - } -#endif - } - - // exclude ATI Radeon HD, except on Apple, because there seems to - // be a bug in ATI's legacy fixed function texturing support in recent - // drivers. The Radeon HD cards are identified here by the OpenGL version - // because the renderer string is inconsistent across platforms. - // win7 RHD5800, win7 RHD6750M, Linux RHD7870 all exhibit the bug. - bool driverSupport - #if defined(__APPLE__) - = true; - #else - = !(extensions->DriverIsATI() - && (extensions->GetDriverGLVersionMajor() >= 3)) - || extensions->GetIgnoreDriverBugs("ATI texturing bug"); - #endif - - return texSupport && driverSupport; -} - -//----------------------------------------------------------------------------- -void vtkOpenGLProjectedTetrahedraMapper::Initialize(vtkRenderer *renderer) -{ - if (this->Initialized) - { - return; - } - - this->Initialized = true; - - vtkOpenGLRenderWindow *renwin - = vtkOpenGLRenderWindow::SafeDownCast(renderer->GetRenderWindow()); - this->HasHardwareSupport = renwin != NULL && this->IsSupported(renwin); - if (!this->HasHardwareSupport) - { - // this is an error since there's no fallback. - vtkErrorMacro("The required extensions are not supported."); - } - - // load required extensions - vtkOpenGLExtensionManager *extensions = renwin->GetExtensionManager(); - if (extensions->LoadSupportedExtension("GL_VERSION_1_3") == 0) // for multitexture - { - extensions->LoadCorePromotedExtension("GL_ARB_multitexture"); - } - // used GL_ARB_texture_float but nothing to load for it - if ( this->UseFloatingPointFrameBuffer - && this->CanDoFloatingPointFrameBuffer) - { - extensions->LoadExtension("GL_ARB_framebuffer_object"); - extensions->LoadExtension("GL_ARB_draw_buffers"); - } -} - -//----------------------------------------------------------------------------- -bool vtkOpenGLProjectedTetrahedraMapper::AllocateFBOResources(vtkRenderer *r) -{ - vtkOpenGLClearErrorMacro(); - - int *size = r->GetSize(); - if ( this->UseFloatingPointFrameBuffer - && this->CanDoFloatingPointFrameBuffer - && (!this->FloatingPointFrameBufferResourcesAllocated - || (size[0] != this->CurrentFBOWidth) - || (size[0] != this->CurrentFBOHeight)) ) - { - this->CurrentFBOWidth = size[0]; - this->CurrentFBOHeight = size[1]; - - // reserver handles fbo and renderbuffers - if (!this->FloatingPointFrameBufferResourcesAllocated) - { - vtkgl::GenFramebuffers(1, &this->Internals->FrameBufferObjectId); - vtkOpenGLCheckErrorMacro("failed at glGenFramebuffers"); - - vtkgl::GenRenderbuffers(2, this->Internals->RenderBufferObjectIds); - vtkOpenGLCheckErrorMacro("failed at glGenRenderBuffers"); - - this->FloatingPointFrameBufferResourcesAllocated = true; - } - // handle multisampling - // the ARB says if SAMPLE_BUFFERS is greater than 1 - // on both READ and DRAW FBO then SAMPLES has to match. - // but if either have SAMPLE_BUFFERS zero then conversions - // are made. - vtkgl::BindFramebuffer(vtkgl::FRAMEBUFFER, 0); - - GLint winSampleBuffers = 0; - glGetIntegerv(vtkgl::SAMPLE_BUFFERS, &winSampleBuffers); - - GLint winSamples = 0; - glGetIntegerv(vtkgl::SAMPLES, &winSamples); - - vtkgl::BindFramebuffer( - vtkgl::FRAMEBUFFER, - this->Internals->FrameBufferObjectId); - - GLint fboSampleBuffers = 0; - glGetIntegerv(vtkgl::SAMPLE_BUFFERS, &fboSampleBuffers); - - vtkDebugMacro( - << "mutisample enabled " - << (glIsEnabled(vtkgl::MULTISAMPLE)?"yes":"no") - << " winSampleBuffers=" << winSampleBuffers - << " winSamples=" << winSamples - << " fboSampleBuffers=" << fboSampleBuffers); - - int fboSamples - = ((fboSampleBuffers >= 1) - && (winSampleBuffers >= 1) - && (winSamples >= 1))?winSamples:0; - - // allocate storage for renderbuffers - vtkgl::BindRenderbuffer( - vtkgl::RENDERBUFFER, - this->Internals->RenderBufferObjectIds[0]); - vtkOpenGLCheckErrorMacro("failed at glBindRenderBuffer color"); - - vtkgl::RenderbufferStorageMultisample( - vtkgl::RENDERBUFFER, - fboSamples, - vtkgl::RGBA32F_ARB, - this->CurrentFBOWidth, - this->CurrentFBOHeight); - vtkOpenGLCheckErrorMacro("failed at glRenderBufferStorage color"); - - vtkgl::BindRenderbuffer( - vtkgl::RENDERBUFFER, - this->Internals->RenderBufferObjectIds[1]); - vtkOpenGLCheckErrorMacro("failed at glBindRenderBuffer depth"); - - vtkgl::RenderbufferStorageMultisample( - vtkgl::RENDERBUFFER, - fboSamples, - GL_DEPTH_COMPONENT, - this->CurrentFBOWidth, - this->CurrentFBOHeight); - vtkOpenGLCheckErrorMacro("failed at glRenderBufferStorage depth"); - - // best way to make it complete: bind the fbo for both draw+read - // during setup - vtkgl::BindFramebuffer( - vtkgl::FRAMEBUFFER, - this->Internals->FrameBufferObjectId); - vtkOpenGLCheckErrorMacro("failed at glBindFramebuffer"); - - vtkgl::FramebufferRenderbuffer( - vtkgl::FRAMEBUFFER, - vtkgl::COLOR_ATTACHMENT0, - vtkgl::RENDERBUFFER, - this->Internals->RenderBufferObjectIds[0]); - vtkOpenGLCheckErrorMacro("failed at glFramebufferRenderBuffer for color"); - - vtkgl::FramebufferRenderbuffer( - vtkgl::FRAMEBUFFER, - vtkgl::DEPTH_ATTACHMENT, - vtkgl::RENDERBUFFER, - this->Internals->RenderBufferObjectIds[1]); - vtkOpenGLCheckErrorMacro("failed at glFramebufferRenderBuffer for depth"); - - // verify that it is usable - GLenum status = vtkgl::CheckFramebufferStatus(vtkgl::FRAMEBUFFER); - if(status != vtkgl::FRAMEBUFFER_COMPLETE) - { - vtkgl::BindFramebuffer(vtkgl::FRAMEBUFFER, 0); - vtkWarningMacro( - "Missing FBO support. The algorithm may produce visual artifacts."); - this->CanDoFloatingPointFrameBuffer = false; - return false; - } - vtkgl::BindFramebuffer(vtkgl::FRAMEBUFFER, 0); - this->CanDoFloatingPointFrameBuffer = true; - } - - return true; -} - -//----------------------------------------------------------------------------- -void vtkOpenGLProjectedTetrahedraMapper::ReleaseGraphicsResources(vtkWindow *win) -{ - this->Initialized = false; - - if (this->Internals->OpacityTexture) - { - glDeleteTextures(1, &this->Internals->OpacityTexture); - vtkOpenGLCheckErrorMacro("failed at glDeleteTextures"); - this->Internals->OpacityTexture = 0; - } - - if (this->FloatingPointFrameBufferResourcesAllocated) - { - this->FloatingPointFrameBufferResourcesAllocated = false; - - vtkgl::DeleteFramebuffers(1, &this->Internals->FrameBufferObjectId); - vtkOpenGLCheckErrorMacro("failed at glDeleteFramebuffers"); - this->Internals->FrameBufferObjectId = 0; - - vtkgl::DeleteRenderbuffers(2, this->Internals->RenderBufferObjectIds); - vtkOpenGLCheckErrorMacro("failed at glDeleteRenderbuffers"); - this->Internals->RenderBufferObjectIds[0] = 0; - this->Internals->RenderBufferObjectIds[1] = 0; - } - - this->Superclass::ReleaseGraphicsResources(win); -} - -//----------------------------------------------------------------------------- -void vtkOpenGLProjectedTetrahedraMapper::Render(vtkRenderer *renderer, - vtkVolume *volume) -{ - vtkOpenGLClearErrorMacro(); - - // load required extensions - this->Initialize(renderer); - - if (!this->HasHardwareSupport) - { - return; - } - - vtkUnstructuredGridBase *input = this->GetInput(); - vtkVolumeProperty *property = volume->GetProperty(); - - float last_max_cell_size = this->MaxCellSize; - - // Check to see if input changed. - if ( (this->InputAnalyzedTime < this->MTime) - || (this->InputAnalyzedTime < input->GetMTime()) ) - { - this->GaveError = 0; - float max_cell_size2 = 0; - - if (input->GetNumberOfCells() == 0) - { - // Apparently, the input has no cells. Just do nothing. - return; - } - - vtkSmartPointer cellIter = - vtkSmartPointer::Take(input->NewCellIterator()); - for (cellIter->InitTraversal(); !cellIter->IsDoneWithTraversal(); - cellIter->GoToNextCell()) - { - vtkIdType npts = cellIter->GetNumberOfPoints(); - if (npts != 4) - { - if (!this->GaveError) - { - vtkErrorMacro("Encountered non-tetrahedra cell!"); - this->GaveError = 1; - } - continue; - } - vtkIdType *pts = cellIter->GetPointIds()->GetPointer(0); - for (int j = 0; j < 6; j++) - { - double p1[3], p2[3]; - input->GetPoint(pts[tet_edges[j][0]], p1); - input->GetPoint(pts[tet_edges[j][1]], p2); - float size2 = (float)vtkMath::Distance2BetweenPoints(p1, p2); - if (size2 > max_cell_size2) - { - max_cell_size2 = size2; - } - } - } - - this->MaxCellSize = (float)sqrt(max_cell_size2); - - // Build a sqrt lookup table for measuring distances. During perspective - // modes we have to take a lot of square roots, and a table is much faster - // than calling the sqrt function. - this->SqrtTableBias = (SqrtTableSize-1)/max_cell_size2; - for (int i = 0; i < SqrtTableSize; i++) - { - this->SqrtTable[i] = (float)sqrt(i/this->SqrtTableBias); - } - - this->InputAnalyzedTime.Modified(); - } - - if (renderer->GetRenderWindow()->CheckAbortStatus() || this->GaveError) - { - vtkOpenGLCheckErrorMacro("failed during Render"); - return; - } - - // Check to see if we need to rebuild opacity texture. - if ( !this->Internals->OpacityTexture - || (last_max_cell_size != this->MaxCellSize) - || (this->LastProperty != property) - || (this->OpacityTextureTime < property->GetMTime()) ) - { - if (!this->Internals->OpacityTexture) - { - glGenTextures(1, &this->Internals->OpacityTexture); - } - vtkgl::ActiveTexture(vtkgl::TEXTURE0); - glBindTexture(GL_TEXTURE_2D, this->Internals->OpacityTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - - float unit_distance = property->GetScalarOpacityUnitDistance(); - -#define TEXRES 258 - float *texture = new float[TEXRES*TEXRES]; - for (int depthi = 0; depthi < TEXRES; depthi++) - { - float depth = depthi*this->MaxCellSize/(TEXRES); - for (int attenuationi = 0; attenuationi < TEXRES; attenuationi++) - { - float attenuation = (float)attenuationi/(TEXRES); - float alpha = 1 - (float)exp(-attenuation*depth/unit_distance); - texture[(depthi*TEXRES + attenuationi)] = alpha; - } - } - glTexImage2D(GL_TEXTURE_2D, 0, GL_INTENSITY, TEXRES, TEXRES, 1, GL_RED, - GL_FLOAT, texture); - delete[] texture; - - glBindTexture(GL_TEXTURE_2D, 0); - - this->OpacityTextureTime.Modified(); - } - if (renderer->GetRenderWindow()->CheckAbortStatus()) - { - vtkOpenGLCheckErrorMacro("failed during Render"); - return; - } - - // Check to see if we need to remap colors. - if ( (this->ColorsMappedTime < this->MTime) - || (this->ColorsMappedTime < input->GetMTime()) - || (this->LastProperty != property) - || (this->ColorsMappedTime < property->GetMTime()) ) - { - vtkDataArray *scalars = this->GetScalars(input, this->ScalarMode, - this->ArrayAccessMode, - this->ArrayId, this->ArrayName, - this->UsingCellColors); - if (!scalars) - { - vtkErrorMacro(<< "Can't use projected tetrahedra without scalars!"); - vtkOpenGLCheckErrorMacro("failed during Render"); - return; - } - - vtkProjectedTetrahedraMapper::MapScalarsToColors(this->Colors, property, - scalars); - - this->ColorsMappedTime.Modified(); - this->LastProperty = property; - } - if (renderer->GetRenderWindow()->CheckAbortStatus()) - { - vtkOpenGLCheckErrorMacro("failed during Render"); - return; - } - - this->Timer->StartTimer(); - - this->ProjectTetrahedra(renderer, volume); - - this->Timer->StopTimer(); - this->TimeToDraw = this->Timer->GetElapsedTime(); - vtkOpenGLCheckErrorMacro("failed after Render"); -} - -//----------------------------------------------------------------------------- - -inline float vtkOpenGLProjectedTetrahedraMapper::GetCorrectedDepth( - float x, float y, float z1, float z2, - const float inverse_projection_mat[16], - int use_linear_depth_correction, - float linear_depth_correction) -{ - if (use_linear_depth_correction) - { - float depth = linear_depth_correction*(z1 - z2); - if (depth < 0) depth = -depth; - return depth; - } - else - { - float eye1[3], eye2[3], invw; - -#if 0 - invw = 1/( inverse_projection_mat[ 3]*x - + inverse_projection_mat[ 7]*y - + inverse_projection_mat[11]*z1 - + inverse_projection_mat[15] ); - eye1[0] = invw*( inverse_projection_mat[ 0]*x - + inverse_projection_mat[ 4]*y - + inverse_projection_mat[ 8]*z1 - + inverse_projection_mat[12] ); - eye1[1] = invw*( inverse_projection_mat[ 1]*x - + inverse_projection_mat[ 5]*y - + inverse_projection_mat[ 9]*z1 - + inverse_projection_mat[13] ); - eye1[2] = invw*( inverse_projection_mat[ 2]*x - + inverse_projection_mat[ 6]*y - + inverse_projection_mat[10]*z1 - + inverse_projection_mat[14] ); - - invw = 1/( inverse_projection_mat[ 3]*x - + inverse_projection_mat[ 7]*y - + inverse_projection_mat[11]*z2 - + inverse_projection_mat[15] ); - eye2[0] = invw*( inverse_projection_mat[ 0]*x - + inverse_projection_mat[ 4]*y - + inverse_projection_mat[ 8]*z2 - + inverse_projection_mat[12] ); - eye2[1] = invw*( inverse_projection_mat[ 1]*x - + inverse_projection_mat[ 5]*y - + inverse_projection_mat[ 9]*z2 - + inverse_projection_mat[13] ); - eye2[2] = invw*( inverse_projection_mat[ 2]*x - + inverse_projection_mat[ 6]*y - + inverse_projection_mat[10]*z2 - + inverse_projection_mat[14] ); -#else - // This code does the same as the commented code above, but also collects - // common arithmetic between the two matrix x vector operations. An - // optimizing compiler may or may not pick up on that. - float common[4]; - - common[0] = ( inverse_projection_mat[ 0]*x - + inverse_projection_mat[ 4]*y - + inverse_projection_mat[12] ); - common[1] = ( inverse_projection_mat[ 1]*x - + inverse_projection_mat[ 5]*y - + inverse_projection_mat[13] ); - common[2] = ( inverse_projection_mat[ 2]*x - + inverse_projection_mat[ 6]*y - + inverse_projection_mat[10]*z1 - + inverse_projection_mat[14] ); - common[3] = ( inverse_projection_mat[ 3]*x - + inverse_projection_mat[ 7]*y - + inverse_projection_mat[15] ); - - invw = 1/(common[3] + inverse_projection_mat[11]*z1); - eye1[0] = invw*(common[0] + inverse_projection_mat[ 8]*z1); - eye1[1] = invw*(common[1] + inverse_projection_mat[ 9]*z1); - eye1[2] = invw*(common[2] + inverse_projection_mat[10]*z1); - - invw = 1/(common[3] + inverse_projection_mat[11]*z2); - eye2[0] = invw*(common[0] + inverse_projection_mat[ 8]*z2); - eye2[1] = invw*(common[1] + inverse_projection_mat[ 9]*z2); - eye2[2] = invw*(common[2] + inverse_projection_mat[10]*z2); -#endif - - float dist2 = vtkMath::Distance2BetweenPoints(eye1, eye2); - return this->SqrtTable[(int)(dist2*this->SqrtTableBias)]; - } -} - -//----------------------------------------------------------------------------- -void vtkOpenGLProjectedTetrahedraMapper::ProjectTetrahedra(vtkRenderer *renderer, - vtkVolume *volume) -{ - vtkOpenGLClearErrorMacro(); - - // after mucking about with FBO bindings be sure - // we're saving the default fbo attributes/blend function - glPushAttrib(GL_COLOR_BUFFER_BIT); - vtkOpenGLCheckErrorMacro("failed at glPushAttrib"); - - this->AllocateFBOResources(renderer); - - if (this->UseFloatingPointFrameBuffer - && this->CanDoFloatingPointFrameBuffer) - { - // bind draw+read to set it up - vtkgl::BindFramebuffer( - vtkgl::FRAMEBUFFER, - this->Internals->FrameBufferObjectId); - - glReadBuffer(GL_NONE); - GLenum dbuf = vtkgl::COLOR_ATTACHMENT0; - vtkgl::DrawBuffersARB(1, &dbuf); - - GLenum status = vtkgl::CheckFramebufferStatus(vtkgl::DRAW_FRAMEBUFFER); - if (status!=vtkgl::FRAMEBUFFER_COMPLETE) - { - vtkErrorMacro("FBO is incomplete " << status); - } - - // read from default - vtkgl::BindFramebuffer(vtkgl::READ_FRAMEBUFFER, 0); - // draw to fbo - vtkgl::BindFramebuffer(vtkgl::DRAW_FRAMEBUFFER, - this->Internals->FrameBufferObjectId); - - vtkgl::BlitFramebuffer(0, 0, - this->CurrentFBOWidth, this->CurrentFBOHeight, - 0, 0, - this->CurrentFBOWidth, this->CurrentFBOHeight, - GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, - GL_NEAREST); - - vtkOpenGLCheckErrorMacro("failed at glBlitFramebuffer"); - } - - // TODO: - // There are some caching optimizations that could be used - // here to skip various expensive operations (eg sorting - // cells could be skipped if input data and MVP matrices - // haven't changed). - - vtkUnstructuredGridBase *input = this->GetInput(); - this->VisibilitySort->SetInput(input); - this->VisibilitySort->SetDirectionToBackToFront(); - this->VisibilitySort->SetModelTransform(volume->GetMatrix()); - this->VisibilitySort->SetCamera(renderer->GetActiveCamera()); - this->VisibilitySort->SetMaxCellsReturned(1000); - - this->VisibilitySort->InitTraversal(); - - if (renderer->GetRenderWindow()->CheckAbortStatus()) - { - return; - } - - float projection_mat[16]; - float modelview_mat[16]; - glGetFloatv(GL_PROJECTION_MATRIX, projection_mat); - glGetFloatv(GL_MODELVIEW_MATRIX, modelview_mat); - - // Get the inverse projection matrix so that we can convert distances in - // clipping space to distances in world or eye space. - float inverse_projection_mat[16]; - float linear_depth_correction = 1; - int use_linear_depth_correction; - double tmp_mat[16]; - - // VTK's matrix functions use doubles. - std::copy(projection_mat, projection_mat+16, tmp_mat); - // VTK and OpenGL store their matrices differently. Correct. - vtkMatrix4x4::Transpose(tmp_mat, tmp_mat); - // Take the inverse. - vtkMatrix4x4::Invert(tmp_mat, tmp_mat); - // Restore back to OpenGL form. - vtkMatrix4x4::Transpose(tmp_mat, tmp_mat); - // Copy back to float for faster computation. - std::copy(tmp_mat, tmp_mat+16, inverse_projection_mat); - - // Check to see if we can just do a linear depth correction from clipping - // space to eye space. - use_linear_depth_correction = ( (projection_mat[ 3] == 0.0) - && (projection_mat[ 7] == 0.0) - && (projection_mat[11] == 0.0) - && (projection_mat[15] == 1.0) ); - if (use_linear_depth_correction) - { - float pos1[3], *pos2; - - pos1[0] = inverse_projection_mat[8] + inverse_projection_mat[12]; - pos1[1] = inverse_projection_mat[9] + inverse_projection_mat[13]; - pos1[2] = inverse_projection_mat[10] + inverse_projection_mat[14]; - - pos2 = inverse_projection_mat + 12; - - linear_depth_correction = sqrt(vtkMath::Distance2BetweenPoints(pos1, pos2)); - } - // Transform all the points. - vtkProjectedTetrahedraMapper::TransformPoints(input->GetPoints(), - projection_mat, modelview_mat, - this->TransformedPoints); - float *points = this->TransformedPoints->GetPointer(0); - - if (renderer->GetRenderWindow()->CheckAbortStatus()) - { - return; - } - - glDisable(GL_LIGHTING); - glDepthMask(GL_FALSE); - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, this->Internals->OpacityTexture); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - glShadeModel(GL_SMOOTH); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glDisable(GL_CULL_FACE); - - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - - // Establish vertex arrays. - // tets have 4 points, 5th point here is used - // to insert a point in case of intersections - float tet_points[5*3] = {0.0f}; - glVertexPointer(3, GL_FLOAT, 0, tet_points); - glEnableClientState(GL_VERTEX_ARRAY); - - unsigned char tet_colors[5*3] = {'\0'}; - glColorPointer(3, GL_UNSIGNED_BYTE, 0, tet_colors); - glEnableClientState(GL_COLOR_ARRAY); - - float tet_texcoords[5*2] = {0.0f}; - glTexCoordPointer(2, GL_FLOAT, 0, tet_texcoords); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - - // Since we had to transform the points on the CPU, replace the OpenGL - // transforms with the identity matrix. - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - unsigned char *colors = this->Colors->GetPointer(0); - vtkIdType totalnumcells = input->GetNumberOfCells(); - vtkIdType numcellsrendered = 0; - vtkNew cellPointIds; - // Let's do it! - for (vtkIdTypeArray *sorted_cell_ids = this->VisibilitySort->GetNextCells(); - sorted_cell_ids != NULL; - sorted_cell_ids = this->VisibilitySort->GetNextCells()) - { - this->UpdateProgress((double)numcellsrendered/totalnumcells); - if (renderer->GetRenderWindow()->CheckAbortStatus()) - { - break; - } - vtkIdType *cell_ids = sorted_cell_ids->GetPointer(0); - vtkIdType num_cell_ids = sorted_cell_ids->GetNumberOfTuples(); - for (vtkIdType i = 0; i < num_cell_ids; i++) - { - vtkIdType cell = cell_ids[i]; - input->GetCellPoints(cell, cellPointIds.GetPointer()); - int j; - - // Get the data for the tetrahedra. - for (j = 0; j < 4; j++) - { - // Assuming we only have tetrahedra, each entry in cells has 5 - // components. - const float *p = points + 3 * cellPointIds->GetId(j); - tet_points[j*3 + 0] = p[0]; - tet_points[j*3 + 1] = p[1]; - tet_points[j*3 + 2] = p[2]; - - const unsigned char *c; - if (this->UsingCellColors) - { - c = colors + 4*cell; - } - else - { - c = colors + 4 * cellPointIds->GetId(j); - } - - tet_colors[j*3 + 0] = c[0]; - tet_colors[j*3 + 1] = c[1]; - tet_colors[j*3 + 2] = c[2]; - - tet_texcoords[j*2 + 0] = static_cast(c[3])/255.0f; - tet_texcoords[j*2 + 1] = 0; - } - - // Do not render this cell if it is outside of the cutting planes. For - // most planes, cut if all points are outside. For the near plane, cut if - // any points are outside because things can go very wrong if one of the - // points is behind the view. - if ( ( (tet_points[0*3+0] > 1.0f) && (tet_points[1*3+0] > 1.0f) - && (tet_points[2*3+0] > 1.0f) && (tet_points[3*3+0] > 1.0f) ) - || ( (tet_points[0*3+0] < -1.0f) && (tet_points[1*3+0] < -1.0f) - && (tet_points[2*3+0] < -1.0f) && (tet_points[3*3+0] < -1.0f) ) - || ( (tet_points[0*3+1] > 1.0f) && (tet_points[1*3+1] > 1.0f) - && (tet_points[2*3+1] > 1.0f) && (tet_points[3*3+1] > 1.0f) ) - || ( (tet_points[0*3+1] < -1.0f) && (tet_points[1*3+1] < -1.0f) - && (tet_points[2*3+1] < -1.0f) && (tet_points[3*3+1] < -1.0f) ) - || ( (tet_points[0*3+2] > 1.0f) && (tet_points[1*3+2] > 1.0f) - && (tet_points[2*3+2] > 1.0f) && (tet_points[3*3+2] > 1.0f) ) - || ( (tet_points[0*3+2] < -1.0f) || (tet_points[1*3+2] < -1.0f) - || (tet_points[2*3+2] < -1.0f) || (tet_points[3*3+2] < -1.0f) ) ) - { - continue; - } - - // The classic PT algorithm uses face normals to determine the - // projection class and then do calculations individually. However, - // Wylie 2002 shows how to use the intersection of two segments to - // calculate the depth of the thick part for any case. Here, we use - // face normals to determine which segments to use. One segment - // should be between two faces that are either both front facing or - // back facing. Obviously, we only need to test three faces to find - // two such faces. We test the three faces connected to point 0. - vtkIdType segment1[2]; - vtkIdType segment2[2]; - - float v1[2], v2[2], v3[3]; - v1[0] = tet_points[1*3 + 0] - tet_points[0*3 + 0]; - v1[1] = tet_points[1*3 + 1] - tet_points[0*3 + 1]; - v2[0] = tet_points[2*3 + 0] - tet_points[0*3 + 0]; - v2[1] = tet_points[2*3 + 1] - tet_points[0*3 + 1]; - v3[0] = tet_points[3*3 + 0] - tet_points[0*3 + 0]; - v3[1] = tet_points[3*3 + 1] - tet_points[0*3 + 1]; - - float face_dir1 = v3[0]*v2[1] - v3[1]*v2[0]; - float face_dir2 = v1[0]*v3[1] - v1[1]*v3[0]; - float face_dir3 = v2[0]*v1[1] - v2[1]*v1[0]; - - if ( (face_dir1 * face_dir2 >= 0) - && ( (face_dir1 != 0) // Handle a special case where 2 faces - || (face_dir2 != 0) ) ) // are perpendicular to the view plane. - { - segment1[0] = 0; segment1[1] = 3; - segment2[0] = 1; segment2[1] = 2; - } - else if (face_dir1 * face_dir3 >= 0) - { - segment1[0] = 0; segment1[1] = 2; - segment2[0] = 1; segment2[1] = 3; - } - else // Unless the tet is degenerate, face_dir2*face_dir3 >= 0 - { - segment1[0] = 0; segment1[1] = 1; - segment2[0] = 2; segment2[1] = 3; - } - -#define VEC3SUB(Z,X,Y) \ - (Z)[0] = (X)[0] - (Y)[0]; \ - (Z)[1] = (X)[1] - (Y)[1]; \ - (Z)[2] = (X)[2] - (Y)[2]; -#define P1 (tet_points + 3*segment1[0]) -#define P2 (tet_points + 3*segment1[1]) -#define P3 (tet_points + 3*segment2[0]) -#define P4 (tet_points + 3*segment2[1]) -#define C1 (tet_colors + 3*segment1[0]) -#define C2 (tet_colors + 3*segment1[1]) -#define C3 (tet_colors + 3*segment2[0]) -#define C4 (tet_colors + 3*segment2[1]) -#define T1 (tet_texcoords + 2*segment1[0]) -#define T2 (tet_texcoords + 2*segment1[1]) -#define T3 (tet_texcoords + 2*segment2[0]) -#define T4 (tet_texcoords + 2*segment2[1]) - // Find the intersection of the projection of the two segments in the - // XY plane. This algorithm is based on that given in Graphics Gems - // III, pg. 199-202. - float A[3], B[3], C[3]; - // We can define the two lines parametrically as: - // P1 + alpha(A) - // P3 + beta(B) - // where A = P2 - P1 - // and B = P4 - P3. - // alpha and beta are in the range [0,1] within the line segment. - VEC3SUB(A, P2, P1); - VEC3SUB(B, P4, P3); - // The lines intersect when the values of the two parameteric equations - // are equal. Setting them equal and moving everything to one side: - // 0 = C + beta(B) - alpha(A) - // where C = P3 - P1. - VEC3SUB(C, P3, P1); - // When we project the lines to the xy plane (which we do by throwing - // away the z value), we have two equations and two unknowns. The - // following are the solutions for alpha and beta. - float denominator = (A[0]*B[1]-A[1]*B[0]); - if (denominator == 0) continue; // Must be degenerated tetrahedra. - float alpha = (B[1]*C[0]-B[0]*C[1])/denominator; - float beta = (A[1]*C[0]-A[0]*C[1])/denominator; - - if ((alpha >= 0) && (alpha <= 1)) - { - // The two segments intersect. This corresponds to class 2 in - // Shirley and Tuchman (or one of the degenerate cases). - - // Make new point at intersection. - tet_points[3*4 + 0] = P1[0] + alpha*A[0]; - tet_points[3*4 + 1] = P1[1] + alpha*A[1]; - tet_points[3*4 + 2] = P1[2] + alpha*A[2]; - - // Find depth at intersection. - float depth = this->GetCorrectedDepth( - tet_points[3*4 + 0], - tet_points[3*4 + 1], - tet_points[3*4 + 2], - P3[2] + beta*B[2], - inverse_projection_mat, - use_linear_depth_correction, - linear_depth_correction); - - // Find color at intersection. - tet_colors[3*4 + 0] = static_cast - (0.5f*(C1[0] + alpha*(C2[0]-C1[0]) - + C3[0] + beta*(C4[0]-C3[0]))); - - tet_colors[3*4 + 1] = static_cast - (0.5f*(C1[1] + alpha*(C2[1]-C1[1]) - + C3[1] + beta*(C4[1]-C3[1]))); - - tet_colors[3*4 + 2] = static_cast - (0.5f*(C1[2] + alpha*(C2[2]-C1[2]) - + C3[2] + beta*(C4[2]-C3[2]))); - -// tet_colors[3*0 + 0] = 255; -// tet_colors[3*0 + 1] = 0; -// tet_colors[3*0 + 2] = 0; -// tet_colors[3*1 + 0] = 255; -// tet_colors[3*1 + 1] = 0; -// tet_colors[3*1 + 2] = 0; -// tet_colors[3*2 + 0] = 255; -// tet_colors[3*2 + 1] = 0; -// tet_colors[3*2 + 2] = 0; -// tet_colors[3*3 + 0] = 255; -// tet_colors[3*3 + 1] = 0; -// tet_colors[3*3 + 2] = 0; -// tet_colors[3*4 + 0] = 255; -// tet_colors[3*4 + 1] = 0; -// tet_colors[3*4 + 2] = 0; - - // Find the opacity at intersection. - tet_texcoords[2*4 + 0] = 0.5f*( T1[0] + alpha*(T2[0]-T1[0]) - + T3[0] + alpha*(T4[0]-T3[0])); - - // Record the depth at the intersection. - tet_texcoords[2*4 + 1] = depth/this->MaxCellSize; - - // Establish the order in which the points should be rendered. - unsigned char indices[6]; - indices[0] = 4; - indices[1] = segment1[0]; - indices[2] = segment2[0]; - indices[3] = segment1[1]; - indices[4] = segment2[1]; - indices[5] = segment1[0]; - // Render - glDrawElements(GL_TRIANGLE_FAN, 6, GL_UNSIGNED_BYTE, indices); - } - else - { - // The two segments do not intersect. This corresponds to class 1 - // in Shirley and Tuchman. - if (alpha <= 0) - { - // Flip segment1 so that alpha is >= 1. P1 and P2 are also - // flipped as are C1-C2 and T1-T2. Note that this will - // invalidate A. B and beta are unaffected. - std::swap(segment1[0], segment1[1]); - alpha = 1 - alpha; - } - // From here on, we can assume P2 is the "thick" point. - - // Find the depth under the thick point. Use the alpha and beta - // from intersection to determine location of face under thick - // point. - float edgez = P3[2] + beta*B[2]; - float pointz = P1[2]; - float facez = (edgez + (alpha-1)*pointz)/alpha; - float depth = GetCorrectedDepth(P2[0], P2[1], P2[2], facez, - inverse_projection_mat, - use_linear_depth_correction, - linear_depth_correction); - - // Fix color at thick point. Average color with color of opposite - // face. - for (j = 0; j < 3; j++) - { - float edgec = C3[j] + beta*(C4[j]-C3[j]); - float pointc = C1[j]; - float facec = (edgec + (alpha-1)*pointc)/alpha; - C2[j] = (unsigned char)(0.5f*(facec + C2[j])); - } - -// tet_colors[3*segment1[0] + 0] = 0; -// tet_colors[3*segment1[0] + 1] = 255; -// tet_colors[3*segment1[0] + 2] = 0; -// tet_colors[3*segment1[1] + 0] = 0; -// tet_colors[3*segment1[1] + 1] = 255; -// tet_colors[3*segment1[1] + 2] = 0; -// tet_colors[3*segment2[0] + 0] = 0; -// tet_colors[3*segment2[0] + 1] = 255; -// tet_colors[3*segment2[0] + 2] = 0; -// tet_colors[3*segment2[1] + 0] = 0; -// tet_colors[3*segment2[1] + 1] = 255; -// tet_colors[3*segment2[1] + 2] = 0; - - // Fix opacity at thick point. Average opacity with opacity of - // opposite face. - float edgea = T3[0] + beta*(T4[0]-T3[0]); - float pointa = T1[0]; - float facea = (edgea + (alpha-1)*pointa)/alpha; - T2[0] = 0.5f*(facea + T2[0]); - - // Record thickness at thick point. - T2[1] = depth/this->MaxCellSize; - - // Establish the order in which the points should be rendered. - unsigned char indices[5]; - indices[0] = segment1[1]; - indices[1] = segment1[0]; - indices[2] = segment2[0]; - indices[3] = segment2[1]; - indices[4] = segment1[0]; - // Render - glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_BYTE, indices); - } - } - numcellsrendered += num_cell_ids; - } - - if (this->UseFloatingPointFrameBuffer - && this->CanDoFloatingPointFrameBuffer) - { - // copy from our fbo to the default one - vtkgl::BindFramebuffer( - vtkgl::FRAMEBUFFER, - this->Internals->FrameBufferObjectId); - - glReadBuffer(vtkgl::COLOR_ATTACHMENT0); - glDrawBuffer(GL_NONE); - - GLenum status = vtkgl::CheckFramebufferStatus(vtkgl::READ_FRAMEBUFFER); - if (status!=vtkgl::FRAMEBUFFER_COMPLETE) - { - vtkErrorMacro("FBO is incomplete " << status); - } - - // read from fbo - vtkgl::BindFramebuffer(vtkgl::READ_FRAMEBUFFER, - this->Internals->FrameBufferObjectId); - // draw to default fbo - vtkgl::BindFramebuffer(vtkgl::DRAW_FRAMEBUFFER, 0); - - vtkgl::BlitFramebuffer(0, 0, this->CurrentFBOWidth, this->CurrentFBOHeight, - 0, 0, this->CurrentFBOWidth, this->CurrentFBOHeight, - GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); - - vtkOpenGLCheckErrorMacro("failed at glBlitFramebuffer"); - - // restore default fbo for both read+draw - vtkgl::BindFramebuffer(vtkgl::FRAMEBUFFER, 0); - } - - // Restore OpenGL state. - glMatrixMode(GL_PROJECTION); - glLoadMatrixf(projection_mat); - glMatrixMode(GL_MODELVIEW); - glLoadMatrixf(modelview_mat); - - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - - // Restore the blend function. - glPopAttrib(); - vtkOpenGLCheckErrorMacro("failed at glPopAttrib"); - - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - - glDepthMask(GL_TRUE); - glEnable(GL_LIGHTING); - - vtkOpenGLCheckErrorMacro("failed after ProjectTetrahedra"); - this->UpdateProgress(1.0); -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLProjectedTetrahedraMapper.h paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLProjectedTetrahedraMapper.h --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLProjectedTetrahedraMapper.h 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLProjectedTetrahedraMapper.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,122 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkOpenGLProjectedTetrahedraMapper.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -/* - * Copyright 2003 Sandia Corporation. - * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive - * license for use of this work by or on behalf of the - * U.S. Government. Redistribution and use in source and binary forms, with - * or without modification, are permitted provided that this Notice and any - * statement of authorship are reproduced on all copies. - */ - -/** - * @class vtkOpenGLProjectedTetrahedraMapper - * @brief OpenGL implementation of PT - * - * @bug - * This mapper relies highly on the implementation of the OpenGL pipeline. - * A typical hardware driver has lots of options and some settings can - * cause this mapper to produce artifacts. - * -*/ - -#ifndef vtkOpenGLProjectedTetrahedraMapper_h -#define vtkOpenGLProjectedTetrahedraMapper_h - -#include "vtkRenderingVolumeOpenGLModule.h" // For export macro -#include "vtkProjectedTetrahedraMapper.h" - -class vtkVisibilitySort; -class vtkUnsignedCharArray; -class vtkFloatArray; -class vtkRenderWindow; -class vtkOpenGLRenderWindow; - -class VTKRENDERINGVOLUMEOPENGL_EXPORT vtkOpenGLProjectedTetrahedraMapper - : public vtkProjectedTetrahedraMapper -{ -public: - vtkTypeMacro(vtkOpenGLProjectedTetrahedraMapper, - vtkProjectedTetrahedraMapper); - static vtkOpenGLProjectedTetrahedraMapper *New(); - void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE; - - void ReleaseGraphicsResources(vtkWindow *window) VTK_OVERRIDE; - - void Render(vtkRenderer *renderer, vtkVolume *volume) VTK_OVERRIDE; - - //@{ - /** - * Set/get whether to use floating-point rendering buffers rather - * than the default. - */ - vtkSetMacro(UseFloatingPointFrameBuffer,bool); - vtkGetMacro(UseFloatingPointFrameBuffer,bool); - vtkBooleanMacro(UseFloatingPointFrameBuffer,bool); - //@} - - /** - * Return true if the rendering context provides - * the nececessary functionality to use this class. - */ - bool IsSupported(vtkRenderWindow *context) VTK_OVERRIDE; - -protected: - vtkOpenGLProjectedTetrahedraMapper(); - ~vtkOpenGLProjectedTetrahedraMapper() VTK_OVERRIDE; - - void Initialize(vtkRenderer *ren); - bool Initialized; - int CurrentFBOWidth, CurrentFBOHeight; - bool AllocateFBOResources(vtkRenderer *ren); - bool CanDoFloatingPointFrameBuffer; - bool FloatingPointFrameBufferResourcesAllocated; - bool UseFloatingPointFrameBuffer; - bool HasHardwareSupport; - - vtkUnsignedCharArray *Colors; - int UsingCellColors; - - vtkFloatArray *TransformedPoints; - - float MaxCellSize; - vtkTimeStamp InputAnalyzedTime; - vtkTimeStamp OpacityTextureTime; - vtkTimeStamp ColorsMappedTime; - - int GaveError; - - vtkVolumeProperty *LastProperty; - - float *SqrtTable; - float SqrtTableBias; - - virtual void ProjectTetrahedra(vtkRenderer *renderer, vtkVolume *volume); - - float GetCorrectedDepth(float x, float y, float z1, float z2, - const float inverse_projection_mat[16], - int use_linear_depth_correction, - float linear_depth_correction); - -private: - vtkOpenGLProjectedTetrahedraMapper(const vtkOpenGLProjectedTetrahedraMapper &) VTK_DELETE_FUNCTION; - void operator=(const vtkOpenGLProjectedTetrahedraMapper &) VTK_DELETE_FUNCTION; - - class vtkInternals; - vtkInternals *Internals; -}; - -#endif diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLRayCastImageDisplayHelper.cxx paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLRayCastImageDisplayHelper.cxx --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLRayCastImageDisplayHelper.cxx 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLRayCastImageDisplayHelper.cxx 1970-01-01 00:00:00.000000000 +0000 @@ -1,563 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkOpenGLRayCastImageDisplayHelper.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -#include "vtkOpenGLRayCastImageDisplayHelper.h" - -#include "vtkMatrix4x4.h" -#include "vtkObjectFactory.h" -#include "vtkVolume.h" -#include "vtkRenderer.h" -#include "vtkTransform.h" -#include "vtkCamera.h" -#include "vtkFixedPointRayCastImage.h" - -#include "vtkOpenGL.h" -#include "vtkOpenGLError.h" - -#include - -vtkStandardNewMacro(vtkOpenGLRayCastImageDisplayHelper); - -// Construct a new vtkOpenGLRayCastImageDisplayHelper with default values -vtkOpenGLRayCastImageDisplayHelper::vtkOpenGLRayCastImageDisplayHelper() -{ -} - -// Destruct a vtkOpenGLRayCastImageDisplayHelper - clean up any memory used -vtkOpenGLRayCastImageDisplayHelper::~vtkOpenGLRayCastImageDisplayHelper() -{ -} - -// imageMemorySize is how big the texture is - this is always a power of two -// -// imageViewportSize is how big the renderer viewport is in pixels -// -// imageInUseSize is the rendered image - equal or smaller than imageMemorySize -// and imageViewportSize -// -// imageOrigin is the starting pixel of the imageInUseSize image on the -// the imageViewportSize viewport -// -void vtkOpenGLRayCastImageDisplayHelper::RenderTexture( vtkVolume *vol, - vtkRenderer *ren, - vtkFixedPointRayCastImage *image, - float requestedDepth ) -{ - this->RenderTextureInternal( vol, ren, image->GetImageMemorySize(), image->GetImageViewportSize(), - image->GetImageInUseSize(), image->GetImageOrigin(), - requestedDepth, VTK_UNSIGNED_SHORT, image->GetImage() ); -} - -void vtkOpenGLRayCastImageDisplayHelper::RenderTexture( vtkVolume *vol, - vtkRenderer *ren, - int imageMemorySize[2], - int imageViewportSize[2], - int imageInUseSize[2], - int imageOrigin[2], - float requestedDepth, - unsigned char *image ) -{ - this->RenderTextureInternal( vol, ren, imageMemorySize, imageViewportSize, - imageInUseSize, imageOrigin, requestedDepth, - VTK_UNSIGNED_CHAR, static_cast(image) ); -} - -void vtkOpenGLRayCastImageDisplayHelper::RenderTexture( vtkVolume *vol, - vtkRenderer *ren, - int imageMemorySize[2], - int imageViewportSize[2], - int imageInUseSize[2], - int imageOrigin[2], - float requestedDepth, - unsigned short *image ) -{ - this->RenderTextureInternal( vol, ren, imageMemorySize, imageViewportSize, - imageInUseSize, imageOrigin, requestedDepth, - VTK_UNSIGNED_SHORT, static_cast(image) ); -} - -void vtkOpenGLRayCastImageDisplayHelper::RenderTextureInternal( vtkVolume *vol, - vtkRenderer *ren, - int imageMemorySize[2], - int imageViewportSize[2], - int imageInUseSize[2], - int imageOrigin[2], - float requestedDepth, - int imageScalarType, - void *image ) -{ - vtkOpenGLClearErrorMacro(); - - int i; - float offsetX, offsetY; -#ifdef GL_VERSION_1_1 - float xMinOffset, xMaxOffset, yMinOffset, yMaxOffset; -#endif - float tcoords[8]; - - float depth; - if ( requestedDepth > 0.0 && requestedDepth <= 1.0 ) - { - depth = requestedDepth; - } - else - { - // Pass the center of the volume through the world to view function - // of the renderer to get the z view coordinate to use for the - // view to world transformation of the image bounds. This way we - // will draw the image at the depth of the center of the volume - ren->SetWorldPoint( vol->GetCenter()[0], - vol->GetCenter()[1], - vol->GetCenter()[2], - 1.0 ); - ren->WorldToView(); - depth = ren->GetViewPoint()[2]; - } - - // Convert the four corners of the image into world coordinates - float verts[12]; - vtkMatrix4x4 *viewToWorldMatrix = vtkMatrix4x4::New(); - float in[4], out[4]; - - vtkCamera *cam = ren->GetActiveCamera(); - ren->ComputeAspect(); - double *aspect = ren->GetAspect(); - - vtkTransform *perspectiveTransform = vtkTransform::New(); - perspectiveTransform->Identity(); - perspectiveTransform->Concatenate( - cam->GetProjectionTransformMatrix(aspect[0]/aspect[1], - 0.0, 1.0 )); - perspectiveTransform->Concatenate(cam->GetViewTransformMatrix()); - - // get the perspective transformation from the active camera - viewToWorldMatrix->DeepCopy( perspectiveTransform->GetMatrix() ); - perspectiveTransform->Delete(); - - // use the inverse matrix - viewToWorldMatrix->Invert(); - - // These two values never change - in[2] = depth; - in[3] = 1.0; - - // This is the lower left corner - in[0] = (float)imageOrigin[0]/imageViewportSize[0] * 2.0 - 1.0; - in[1] = (float)imageOrigin[1]/imageViewportSize[1] * 2.0 - 1.0; - - viewToWorldMatrix->MultiplyPoint( in, out ); - verts[0] = out[0] / out[3]; - verts[1] = out[1] / out[3]; - verts[2] = out[2] / out[3]; - - // This is the lower right corner - in[0] = (float)(imageOrigin[0]+imageInUseSize[0]) / - imageViewportSize[0] * 2.0 - 1.0; - in[1] = (float)imageOrigin[1]/imageViewportSize[1] * 2.0 - 1.0; - - viewToWorldMatrix->MultiplyPoint( in, out ); - verts[3] = out[0] / out[3]; - verts[4] = out[1] / out[3]; - verts[5] = out[2] / out[3]; - - // This is the upper right corner - in[0] = (float)(imageOrigin[0]+imageInUseSize[0]) / - imageViewportSize[0] * 2.0 - 1.0; - in[1] = (float)(imageOrigin[1]+imageInUseSize[1]) / - imageViewportSize[1] * 2.0 - 1.0; - - viewToWorldMatrix->MultiplyPoint( in, out ); - verts[6] = out[0] / out[3]; - verts[7] = out[1] / out[3]; - verts[8] = out[2] / out[3]; - - // This is the upper left corner - in[0] = (float)imageOrigin[0]/imageViewportSize[0] * 2.0 - 1.0; - in[1] = (float)(imageOrigin[1]+imageInUseSize[1]) / - imageViewportSize[1] * 2.0 - 1.0; - - viewToWorldMatrix->MultiplyPoint( in, out ); - verts[9] = out[0] / out[3]; - verts[10] = out[1] / out[3]; - verts[11] = out[2] / out[3]; - - viewToWorldMatrix->Delete(); - - // Save state - glPushAttrib(GL_ENABLE_BIT | - GL_COLOR_BUFFER_BIT | - GL_STENCIL_BUFFER_BIT | - GL_DEPTH_BUFFER_BIT | - GL_POLYGON_BIT | - GL_PIXEL_MODE_BIT | - GL_TEXTURE_BIT); - - glPixelTransferf( GL_RED_SCALE, this->PixelScale ); - glPixelTransferf( GL_GREEN_SCALE, this->PixelScale ); - glPixelTransferf( GL_BLUE_SCALE, this->PixelScale ); - glPixelTransferf( GL_ALPHA_SCALE, this->PixelScale ); - - glEnable( GL_BLEND ); - - if ( this->PreMultipliedColors ) - { - // Values in the texture map have already been pre-multiplied by alpha - glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ); - } - else - { - // Values in the texture map have not been pre-multiplied by alpha - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - } - - // Turn lighting off - the texture already has illumination in it - glDisable( GL_LIGHTING ); - - // Turn texturing on so that we can draw the textured hexagon - glEnable( GL_TEXTURE_2D ); - -#ifdef GL_VERSION_1_1 - GLuint tempIndex; - glGenTextures(1, &tempIndex); - glBindTexture(GL_TEXTURE_2D, tempIndex); -#endif - - // Don't write into the Zbuffer - just use it for comparisons - glDepthMask( 0 ); - - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - - // Specify the texture - glColor3f(1.0,1.0,1.0); - -#ifdef GL_VERSION_1_1 - int newTextureSize[2]; - - if ( imageScalarType == VTK_UNSIGNED_CHAR ) - { - // Test the texture to see if it fits in memory - glTexImage2D( GL_PROXY_TEXTURE_2D, 0, GL_RGBA8, - imageMemorySize[0], imageMemorySize[1], - 0, GL_RGBA, GL_UNSIGNED_BYTE, - static_cast(image) ); - } - else - { - // Test the texture to see if it fits in memory - glTexImage2D( GL_PROXY_TEXTURE_2D, 0, GL_RGBA8, - imageMemorySize[0], imageMemorySize[1], - 0, GL_RGBA, GL_UNSIGNED_SHORT, - static_cast(image) ); - } - - GLint params[1]; - glGetTexLevelParameteriv ( GL_PROXY_TEXTURE_2D, 0, - GL_TEXTURE_WIDTH, params ); - - // if it does, we will render it later. define the texture here - if ( params[0] != 0 ) - { - if ( imageScalarType == VTK_UNSIGNED_CHAR ) - { - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, - imageMemorySize[0], imageMemorySize[1], - 0, GL_RGBA, GL_UNSIGNED_BYTE, - static_cast(image) ); - } - else - { - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, - imageMemorySize[0], imageMemorySize[1], - 0, GL_RGBA, GL_UNSIGNED_SHORT, - static_cast(image) ); - } - } - // if it doesn't, we are going to break it up now and render it. - // That's because we want this in the ifdef because this only works in - // 1.1 and later. - else - { - // Figure out our new texture size. Keep dividing the big one in half until - // OpenGL says this texture is OK - newTextureSize[0] = imageMemorySize[0]; - newTextureSize[1] = imageMemorySize[1]; - - while ( params[0] == 0 && newTextureSize[0] >= 32 && - newTextureSize[1] >= 32 ) - { - if ( newTextureSize[0] > newTextureSize[1] ) - { - newTextureSize[0] /= 2; - } - else - { - newTextureSize[1] /= 2; - } - - if ( imageScalarType == VTK_UNSIGNED_CHAR ) - { - glTexImage2D( GL_PROXY_TEXTURE_2D, 0, GL_RGBA8, - newTextureSize[0], newTextureSize[1], - 0, GL_RGBA, GL_UNSIGNED_BYTE, - static_cast(image) ); - } - else - { - glTexImage2D( GL_PROXY_TEXTURE_2D, 0, GL_RGBA8, - newTextureSize[0], newTextureSize[1], - 0, GL_RGBA, GL_UNSIGNED_SHORT, - static_cast(image) ); - } - glGetTexLevelParameteriv ( GL_PROXY_TEXTURE_2D, 0, - GL_TEXTURE_WIDTH, params ); - } - - // If we got down to 32 by 32 and OpenGL still doesn't like it, something - // must be seriously wrong and we will ignore it. Otherwise, we have our - // new texture size and let's start chopping up the image - if ( newTextureSize[0] >= 32 && newTextureSize[1] >= 32 ) - { - // How many tiles in x? - int xLimit = 1 + static_cast( - static_cast(imageInUseSize[0]) / - static_cast((newTextureSize[0]-2))); - - // How many tiles in y? - int yLimit = 1 + static_cast( - static_cast(imageInUseSize[1]) / - static_cast((newTextureSize[1]-2))); - - // Create memory for the new texture - unsigned char *newTextureChar = NULL; - unsigned short *newTextureShort = NULL; - - if ( imageScalarType == VTK_UNSIGNED_CHAR ) - { - newTextureChar = - new unsigned char [newTextureSize[0] * newTextureSize[1] * 4]; - } - else - { - newTextureShort = - new unsigned short [newTextureSize[0] * newTextureSize[1] * 4]; - } - - - // This is the 1/2 pixel offset for texture coordinates - offsetX = .5 / static_cast(newTextureSize[0]); - offsetY = .5 / static_cast(newTextureSize[1]); - - int ii, jj; - float newVerts[12]; - float vx1, vx2, vy1, vy2; - int px1, py1, pxSize, pySize; - - - // loop through the tiles in y - for ( jj = 0; jj < yLimit; jj++ ) - { - vy1 = static_cast(jj) / static_cast(yLimit); - vy2 = static_cast(jj+1) / static_cast(yLimit); - - py1 = static_cast(vy1 * static_cast( - imageInUseSize[1])); - pySize = static_cast(2 - py1 + vy2 * static_cast( - imageInUseSize[1]-1)); - if ( py1 + pySize > imageInUseSize[1] ) - { - pySize = imageInUseSize[1] - py1; - } - - yMinOffset = 2.0 * offsetY * - (vy1*static_cast(imageInUseSize[1]-1)-static_cast(py1)); - - yMaxOffset = 2.0 * offsetY * - (static_cast(py1+pySize-1)-vy2*static_cast(imageInUseSize[1]-1)); - - // loop through the tiles in x - for ( ii = 0; ii < xLimit; ii++ ) - { - vx1 = static_cast(ii) / static_cast(xLimit); - vx2 = static_cast(ii+1) / static_cast(xLimit); - - px1 = static_cast(vx1 * static_cast( - imageInUseSize[0])); - pxSize = static_cast(2 - px1 + vx2 * static_cast( - imageInUseSize[0]-1)); - if ( px1 + pxSize > imageInUseSize[0] ) - { - pxSize = imageInUseSize[0] - px1; - } - - xMinOffset = 2.0 * offsetX * - (vx1*static_cast(imageInUseSize[0]-1) - - static_cast(px1)); - - xMaxOffset = 2.0 * offsetX * - (static_cast(px1+pxSize-1) - - vx2*static_cast(imageInUseSize[0]-1)); - - if ( px1 + pxSize > imageInUseSize[0] ) - { - pxSize = imageInUseSize[0] - px1; - } - - // copy subtexture of image into newTexture - int loop; - for ( loop = 0; loop < pySize; loop++ ) - { - if ( imageScalarType == VTK_UNSIGNED_CHAR ) - { - memcpy( newTextureChar + 4*loop*newTextureSize[0], - static_cast(image) + - 4*(py1+loop)*imageMemorySize[0] + 4*px1, - pxSize * sizeof(unsigned char) * 4 ); - } - else - { - memcpy( newTextureShort + 4*loop*newTextureSize[0], - static_cast(image) + - 4*(py1+loop)*imageMemorySize[0] + 4*px1, - pxSize * sizeof(unsigned short) * 4 ); - } - } - - newVerts[ 0] = verts[0] + vx1*(verts[3]-verts[0]) + vy1*(verts[ 9]-verts[0]); - newVerts[ 1] = verts[1] + vx1*(verts[4]-verts[1]) + vy1*(verts[10]-verts[1]); - newVerts[ 2] = verts[2] + vx1*(verts[5]-verts[2]) + vy1*(verts[11]-verts[2]); - - newVerts[ 3] = verts[0] + vx2*(verts[3]-verts[0]) + vy1*(verts[ 9]-verts[0]); - newVerts[ 4] = verts[1] + vx2*(verts[4]-verts[1]) + vy1*(verts[10]-verts[1]); - newVerts[ 5] = verts[2] + vx2*(verts[5]-verts[2]) + vy1*(verts[11]-verts[2]); - - newVerts[ 6] = verts[0] + vx2*(verts[3]-verts[0]) + vy2*(verts[ 9]-verts[0]); - newVerts[ 7] = verts[1] + vx2*(verts[4]-verts[1]) + vy2*(verts[10]-verts[1]); - newVerts[ 8] = verts[2] + vx2*(verts[5]-verts[2]) + vy2*(verts[11]-verts[2]); - - newVerts[ 9] = verts[0] + vx1*(verts[3]-verts[0]) + vy2*(verts[ 9]-verts[0]); - newVerts[10] = verts[1] + vx1*(verts[4]-verts[1]) + vy2*(verts[10]-verts[1]); - newVerts[11] = verts[2] + vx1*(verts[5]-verts[2]) + vy2*(verts[11]-verts[2]); - - tcoords[0] = offsetX + xMinOffset; - tcoords[1] = offsetY + yMinOffset; - tcoords[2] = (float)pxSize/(float)newTextureSize[0] - offsetX - xMaxOffset; - tcoords[3] = offsetY + yMinOffset; - tcoords[4] = (float)pxSize/(float)newTextureSize[0] - offsetX - xMaxOffset; - tcoords[5] = (float)pySize/(float)newTextureSize[1] - offsetY - yMaxOffset; - tcoords[6] = offsetX + xMaxOffset; - tcoords[7] = (float)pySize/(float)newTextureSize[1] - offsetY - yMaxOffset; - - if ( imageScalarType == VTK_UNSIGNED_CHAR ) - { - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, - newTextureSize[0], newTextureSize[1], - 0, GL_RGBA, GL_UNSIGNED_BYTE, newTextureChar ); - } - else - { - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, - newTextureSize[0], newTextureSize[1], - 0, GL_RGBA, GL_UNSIGNED_SHORT, newTextureShort ); - } - - // Render the polygon - glBegin( GL_POLYGON ); - - for ( i = 0; i < 4; i++ ) - { - glTexCoord2fv( tcoords+i*2 ); - glVertex3fv( newVerts+i*3 ); - } - - glEnd(); - } - } - - // Delete the memory we created - delete [] newTextureChar; - delete [] newTextureShort; - } - - glFlush(); - glFinish(); - glDeleteTextures(1, &tempIndex); - - // Restore state - glPopAttrib(); - - vtkOpenGLCheckErrorMacro("failed after RenderTextureInternal"); - return; - } - -#else - if ( imageScalarType == VTK_UNSIGNED_CHAR ) - { - glTexImage2D( GL_TEXTURE_2D, 0, 4, - imageMemorySize[0], imageMemorySize[1], - 0, GL_RGBA, GL_UNSIGNED_BYTE, - static_cast(image) ); - } - else - { - glTexImage2D( GL_TEXTURE_2D, 0, 4, - imageMemorySize[0], imageMemorySize[1], - 0, GL_RGBA, GL_UNSIGNED_SHORT, - static_cast(image) ); - } - -#endif - offsetX = .5 / static_cast(imageMemorySize[0]); - offsetY = .5 / static_cast(imageMemorySize[1]); - - tcoords[0] = 0.0 + offsetX; - tcoords[1] = 0.0 + offsetY; - tcoords[2] = - (float)imageInUseSize[0]/(float)imageMemorySize[0] - offsetX; - tcoords[3] = offsetY; - tcoords[4] = - (float)imageInUseSize[0]/(float)imageMemorySize[0] - offsetX; - tcoords[5] = - (float)imageInUseSize[1]/(float)imageMemorySize[1] - offsetY; - tcoords[6] = offsetX; - tcoords[7] = - (float)imageInUseSize[1]/(float)imageMemorySize[1] - offsetY; - - // Render the polygon - glBegin( GL_POLYGON ); - - for ( i = 0; i < 4; i++ ) - { - glTexCoord2fv( tcoords+i*2 ); - glVertex3fv( verts+i*3 ); - } - glEnd(); - - -#ifdef GL_VERSION_1_1 - glFlush(); - glFinish(); - glDeleteTextures(1, &tempIndex); -#endif - - // Restore state - glPopAttrib(); - - vtkOpenGLCheckErrorMacro("failed after RenderTextureInternal"); -} - -void vtkOpenGLRayCastImageDisplayHelper::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os,indent); -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLRayCastImageDisplayHelper.h paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLRayCastImageDisplayHelper.h --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLRayCastImageDisplayHelper.h 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLRayCastImageDisplayHelper.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkOpenGLRayCastImageDisplayHelper.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -/** - * @class vtkOpenGLRayCastImageDisplayHelper - * @brief OpenGL subclass that draws the image to the screen - * - * This is the concrete implementation of a ray cast image display helper - - * a helper class responsible for drawing the image to the screen. - * - * @sa - * vtkRayCastImageDisplayHelper -*/ - -#ifndef vtkOpenGLRayCastImageDisplayHelper_h -#define vtkOpenGLRayCastImageDisplayHelper_h - -#include "vtkRenderingVolumeOpenGLModule.h" // For export macro -#include "vtkRayCastImageDisplayHelper.h" - -class vtkVolume; -class vtkRenderer; -class vtkFixedPointRayCastImage; - -class VTKRENDERINGVOLUMEOPENGL_EXPORT vtkOpenGLRayCastImageDisplayHelper - : public vtkRayCastImageDisplayHelper -{ -public: - static vtkOpenGLRayCastImageDisplayHelper *New(); - vtkTypeMacro(vtkOpenGLRayCastImageDisplayHelper,vtkRayCastImageDisplayHelper); - void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; - - void RenderTexture( vtkVolume *vol, vtkRenderer *ren, - int imageMemorySize[2], - int imageViewportSize[2], - int imageInUseSize[2], - int imageOrigin[2], - float requestedDepth, - unsigned char *image ) VTK_OVERRIDE; - - void RenderTexture( vtkVolume *vol, vtkRenderer *ren, - int imageMemorySize[2], - int imageViewportSize[2], - int imageInUseSize[2], - int imageOrigin[2], - float requestedDepth, - unsigned short *image ) VTK_OVERRIDE; - - void RenderTexture( vtkVolume *vol, vtkRenderer *ren, - vtkFixedPointRayCastImage *image, - float requestedDepth ) VTK_OVERRIDE; - -protected: - vtkOpenGLRayCastImageDisplayHelper(); - ~vtkOpenGLRayCastImageDisplayHelper() VTK_OVERRIDE; - - void RenderTextureInternal( vtkVolume *vol, vtkRenderer *ren, - int imageMemorySize[2], - int imageViewportSize[2], - int imageInUseSize[2], - int imageOrigin[2], - float requestedDepth, - int imageScalarType, - void *image ); - -private: - vtkOpenGLRayCastImageDisplayHelper(const vtkOpenGLRayCastImageDisplayHelper&) VTK_DELETE_FUNCTION; - void operator=(const vtkOpenGLRayCastImageDisplayHelper&) VTK_DELETE_FUNCTION; -}; - -#endif diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLVolumeTextureMapper2D.cxx paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLVolumeTextureMapper2D.cxx --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLVolumeTextureMapper2D.cxx 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLVolumeTextureMapper2D.cxx 1970-01-01 00:00:00.000000000 +0000 @@ -1,191 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkOpenGLVolumeTextureMapper2D.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -#include "vtkOpenGLVolumeTextureMapper2D.h" - -#if !defined(VTK_LEGACY_REMOVE) - -#include "vtkMatrix4x4.h" -#include "vtkObjectFactory.h" -#include "vtkTimerLog.h" -#include "vtkVolume.h" - -#include "vtkOpenGL.h" -#include "vtkOpenGLError.h" - -vtkStandardNewMacro(vtkOpenGLVolumeTextureMapper2D); - -vtkOpenGLVolumeTextureMapper2D::vtkOpenGLVolumeTextureMapper2D() -{ - VTK_LEGACY_BODY(vtkOpenGLVolumeTextureMapper2D::vtkOpenGLVolumeTextureMapper2D,"VTK 7.0"); -} - -vtkOpenGLVolumeTextureMapper2D::~vtkOpenGLVolumeTextureMapper2D() -{ -} - -void vtkOpenGLVolumeTextureMapper2D::Render(vtkRenderer *ren, vtkVolume *vol) -{ - vtkOpenGLClearErrorMacro(); - - vtkMatrix4x4 *matrix; - double matrixForGL[16]; - int i, numClipPlanes = 0; - double planeEquation[4]; - - this->Timer->StartTimer(); - - // Let the superclass take care of some initialization - this->vtkVolumeTextureMapper2D::InitializeRender( ren, vol ); - - // compute transformation - matrix = vol->GetMatrix(); - vtkMatrix4x4::Transpose(*matrix->Element, matrixForGL); - - // insert model transformation - glMatrixMode( GL_MODELVIEW ); - glPushMatrix(); - glMultMatrixd(matrixForGL); - - // use the OpenGL clip planes - numClipPlanes = this->GetNumberOfClippingPlanes(); - if (numClipPlanes > 6) - { - vtkErrorMacro(<< "OpenGL has a limit of 6 clipping planes"); - numClipPlanes = 6; - } - - for (i = 0; i < numClipPlanes; i++) - { - glEnable(static_cast(GL_CLIP_PLANE0+i)); - this->GetClippingPlaneInDataCoords(matrix, i, planeEquation); - glClipPlane(static_cast(GL_CLIP_PLANE0+i), planeEquation); - } - - // Make sure that culling is turned off - glDisable( GL_CULL_FACE ); - - // Turn lighting off - the polygon textures already have illumination - glDisable( GL_LIGHTING ); - - // Turn texturing on so that we can draw the textured polygons - glEnable( GL_TEXTURE_2D ); - -#ifdef GL_VERSION_1_1 - GLuint tempIndex; - glGenTextures(1, &tempIndex); - glBindTexture(GL_TEXTURE_2D, tempIndex); -#endif - - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - - glColor3f( 1.0, 1.0, 1.0 ); - - this->GenerateTexturesAndRenderQuads( ren, vol ); - - // pop transformation matrix - glMatrixMode( GL_MODELVIEW ); - glPopMatrix(); - - glDisable( GL_TEXTURE_2D ); - -#ifdef GL_VERSION_1_1 - glFlush(); - glDeleteTextures(1, &tempIndex); -#endif - - // Turn lighting back on - glEnable( GL_LIGHTING ); - - for (i = 0; i < numClipPlanes; i++) - { - glDisable(static_cast(GL_CLIP_PLANE0+i)); - } - - this->Timer->StopTimer(); - - this->TimeToDraw = static_cast(this->Timer->GetElapsedTime()); - - // If the timer is not accurate enough, set it to a small - // time so that it is not zero - if ( this->TimeToDraw == 0.0 ) - { - this->TimeToDraw = 0.0001; - } - - vtkOpenGLCheckErrorMacro("failed after Render"); -} - -void vtkOpenGLVolumeTextureMapper2D::RenderQuads( int numQuads, - float *v, - float *t, - unsigned char *texture, - int size[2], int reverseFlag ) -{ - vtkOpenGLClearErrorMacro(); - -#ifdef GL_VERSION_1_1 - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, size[0], size[1], - 0, GL_RGBA, GL_UNSIGNED_BYTE, texture ); -#else - glTexImage2D( GL_TEXTURE_2D, 0, 4, size[0], size[1], - 0, GL_RGBA, GL_UNSIGNED_BYTE, texture ); -#endif - - glBegin( GL_QUADS ); - - float *tptr, *vptr; - int i, j; - - if ( reverseFlag ) - { - for ( i = 0; i < numQuads; i++ ) - { - tptr = t+2*4*(numQuads-i-1); - vptr = v+3*4*(numQuads-i-1); - for ( j = 0; j < 4; j++ ) - { - glTexCoord2fv( tptr ); - glVertex3fv( vptr ); - tptr += 2; - vptr += 3; - } - } - } - else - { - tptr = t; - vptr = v; - for ( i = 0; i < numQuads*4; i++ ) - { - glTexCoord2fv( tptr ); - glVertex3fv( vptr ); - tptr += 2; - vptr += 3; - } - } - - glEnd(); - - vtkOpenGLCheckErrorMacro("failed after RenderQuads"); -} - -// Print the vtkOpenGLVolumeTextureMapper2D -void vtkOpenGLVolumeTextureMapper2D::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os,indent); -} - -#endif // VTK_LEGACY_REMOVE diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLVolumeTextureMapper2D.h paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLVolumeTextureMapper2D.h --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLVolumeTextureMapper2D.h 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLVolumeTextureMapper2D.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkOpenGLVolumeTextureMapper2D.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -/** - * @class vtkOpenGLVolumeTextureMapper2D - * @brief Abstract class for a volume mapper - * - * - * vtkOpenGLVolumeTextureMapper2D renders a volume using 2D texture mapping. - * - * @sa - * vtkVolumeMapper - * @deprecated -*/ - -#ifndef vtkOpenGLVolumeTextureMapper2D_h -#define vtkOpenGLVolumeTextureMapper2D_h - -#include "vtkRenderingVolumeOpenGLModule.h" // For export macro -#include "vtkVolumeTextureMapper2D.h" - -#if !defined(VTK_LEGACY_REMOVE) -class VTKRENDERINGVOLUMEOPENGL_EXPORT vtkOpenGLVolumeTextureMapper2D - : public vtkVolumeTextureMapper2D -{ -public: - vtkTypeMacro(vtkOpenGLVolumeTextureMapper2D,vtkVolumeTextureMapper2D); - void PrintSelf( ostream& os, vtkIndent indent ) VTK_OVERRIDE; - - static vtkOpenGLVolumeTextureMapper2D *New(); - - /** - * WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE - * DO NOT USE THIS METHOD OUTSIDE OF THE RENDERING PROCESS - * Render the volume - */ - void Render(vtkRenderer *ren, vtkVolume *vol) VTK_OVERRIDE; - - void RenderQuads( int count, float *v, float *t, - unsigned char *texture, int size[2], int reverseFlag) VTK_OVERRIDE; - -protected: - vtkOpenGLVolumeTextureMapper2D(); - ~vtkOpenGLVolumeTextureMapper2D() VTK_OVERRIDE; - -private: - vtkOpenGLVolumeTextureMapper2D(const vtkOpenGLVolumeTextureMapper2D&) VTK_DELETE_FUNCTION; - void operator=(const vtkOpenGLVolumeTextureMapper2D&) VTK_DELETE_FUNCTION; -}; -#endif // VTK_LEGACY_REMOVE -#endif diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLVolumeTextureMapper3D.cxx paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLVolumeTextureMapper3D.cxx --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLVolumeTextureMapper3D.cxx 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLVolumeTextureMapper3D.cxx 1970-01-01 00:00:00.000000000 +0000 @@ -1,2127 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkOpenGLVolumeTextureMapper3D.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -#include "vtkWindows.h" -#include "vtkOpenGLVolumeTextureMapper3D.h" - -#if !defined(VTK_LEGACY_REMOVE) - -#include "vtkImageData.h" -#include "vtkMatrix4x4.h" -#include "vtkObjectFactory.h" -#include "vtkPointData.h" -#include "vtkRenderWindow.h" -#include "vtkRenderer.h" -#include "vtkTimerLog.h" -#include "vtkVolumeProperty.h" -#include "vtkTransform.h" -#include "vtkLightCollection.h" -#include "vtkLight.h" -#include "vtkCamera.h" -#include "vtkMath.h" -#include "vtkOpenGLExtensionManager.h" -#include "vtkgl.h" -#include "vtkOpenGLRenderWindow.h" -#include "vtkOpenGLError.h" - -#include "vtkVolumeTextureMapper3D_OneComponentShadeFP.h" -#include "vtkVolumeTextureMapper3D_OneComponentNoShadeFP.h" -#include "vtkVolumeTextureMapper3D_TwoDependentNoShadeFP.h" -#include "vtkVolumeTextureMapper3D_TwoDependentShadeFP.h" -#include "vtkVolumeTextureMapper3D_FourDependentNoShadeFP.h" -#include "vtkVolumeTextureMapper3D_FourDependentShadeFP.h" - -vtkStandardNewMacro(vtkOpenGLVolumeTextureMapper3D); - -vtkOpenGLVolumeTextureMapper3D::vtkOpenGLVolumeTextureMapper3D() -{ - this->Initialized = 0; - this->Volume1Index = 0; - this->Volume2Index = 0; - this->Volume3Index = 0; - this->ColorLookupIndex = 0; - this->AlphaLookupIndex = 0; - this->RenderWindow = NULL; - this->SupportsCompressedTexture = false; - VTK_LEGACY_BODY(vtkOpenGLVolumeTextureMapper3D::vtkOpenGLVolumeTextureMapper3D,"VTK 7.0"); -} - -vtkOpenGLVolumeTextureMapper3D::~vtkOpenGLVolumeTextureMapper3D() -{ -} - -// Release the graphics resources used by this texture. -void vtkOpenGLVolumeTextureMapper3D::ReleaseGraphicsResources(vtkWindow - *renWin) -{ - if (( this->Volume1Index || this->Volume2Index || - this->Volume3Index || this->ColorLookupIndex) && renWin) - { - static_cast(renWin)->MakeCurrent(); -#ifdef GL_VERSION_1_1 - // free any textures - this->DeleteTextureIndex( &this->Volume1Index ); - this->DeleteTextureIndex( &this->Volume2Index ); - this->DeleteTextureIndex( &this->Volume3Index ); - this->DeleteTextureIndex( &this->ColorLookupIndex ); - this->DeleteTextureIndex( &this->AlphaLookupIndex ); -#endif - } - this->Volume1Index = 0; - this->Volume2Index = 0; - this->Volume3Index = 0; - this->ColorLookupIndex = 0; - this->RenderWindow = NULL; - this->SupportsCompressedTexture=false; - this->SupportsNonPowerOfTwoTextures=false; - this->Modified(); -} - -void vtkOpenGLVolumeTextureMapper3D::Render(vtkRenderer *ren, vtkVolume *vol) -{ - ren->GetRenderWindow()->MakeCurrent(); - - if ( !this->Initialized ) - { - this->Initialize(ren); - } - - if ( this->RenderMethod == vtkVolumeTextureMapper3D::NO_METHOD ) - { - vtkErrorMacro( "required extensions not supported" ); - return; - } - - vtkOpenGLClearErrorMacro(); - - vtkMatrix4x4 *matrix; - double matrixForGL[16]; - int numClipPlanes = 0; - double planeEquation[4]; - - - // build transformation - matrix = vol->GetMatrix(); - vtkMatrix4x4::Transpose(*matrix->Element, matrixForGL); - - glPushAttrib(GL_ENABLE_BIT | - GL_COLOR_BUFFER_BIT | - GL_STENCIL_BUFFER_BIT | - GL_DEPTH_BUFFER_BIT | - GL_POLYGON_BIT | - GL_TEXTURE_BIT); - - int i; - - // insert model transformation - glMatrixMode( GL_MODELVIEW ); - glPushMatrix(); - glMultMatrixd(matrixForGL); - - // use the OpenGL clip planes - numClipPlanes = this->GetNumberOfClippingPlanes(); - if (numClipPlanes > 6) - { - vtkErrorMacro(<< "OpenGL has a limit of 6 clipping planes"); - numClipPlanes = 6; - } - - for (i = 0; i < numClipPlanes; i++) - { - glEnable(static_cast(GL_CLIP_PLANE0+i)); - this->GetClippingPlaneInDataCoords(matrix, i, planeEquation); - glClipPlane(static_cast(GL_CLIP_PLANE0+i), planeEquation); - } - - // If an actor turned on culling, it must be turned off here - glDisable (GL_CULL_FACE); - - glColor4f( 1.0, 1.0, 1.0, 1.0 ); - - // Turn lighting off - the polygon textures already have illumination - glDisable( GL_LIGHTING ); - - if(this->UseCompressedTexture && SupportsCompressedTexture) - { - this->InternalAlpha=vtkgl::COMPRESSED_ALPHA; - this->InternalLA=vtkgl::COMPRESSED_LUMINANCE_ALPHA; - this->InternalRGB=vtkgl::COMPRESSED_RGB; - this->InternalRGBA=vtkgl::COMPRESSED_RGBA; - } - else - { - this->InternalAlpha=GL_ALPHA8; - this->InternalLA=GL_LUMINANCE8_ALPHA8; - this->InternalRGB=GL_RGB8; - this->InternalRGBA=GL_RGBA8; - } - - vtkOpenGLCheckErrorMacro("Before actual render method"); - switch ( this->RenderMethod ) - { - case vtkVolumeTextureMapper3D::NVIDIA_METHOD: - this->RenderNV(ren,vol); - break; - case vtkVolumeTextureMapper3D::FRAGMENT_PROGRAM_METHOD: - this->RenderFP(ren,vol); - break; - } - - // pop transformation matrix - glMatrixMode( GL_MODELVIEW ); - glPopMatrix(); - - glPopAttrib(); - - - glFlush(); - glFinish(); - - vtkOpenGLCheckErrorMacro("failed after Render"); - - this->Timer->StopTimer(); - - this->TimeToDraw = static_cast(this->Timer->GetElapsedTime()); - - // If the timer is not accurate enough, set it to a small - // time so that it is not zero - if ( this->TimeToDraw == 0.0 ) - { - this->TimeToDraw = 0.0001; - } -} - -void vtkOpenGLVolumeTextureMapper3D::RenderFP(vtkRenderer *ren, - vtkVolume *vol) -{ - vtkOpenGLClearErrorMacro(); - - glAlphaFunc (GL_GREATER, static_cast(0)); - glEnable (GL_ALPHA_TEST); - - glEnable( GL_BLEND ); - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - - int components = this->GetInput()->GetNumberOfScalarComponents(); - switch ( components ) - { - case 1: - if ( !vol->GetProperty()->GetShade() ) - { - this->RenderOneIndependentNoShadeFP(ren,vol); - } - else - { - this->RenderOneIndependentShadeFP(ren,vol); - } - break; - - case 2: - if ( !vol->GetProperty()->GetShade() ) - { - this->RenderTwoDependentNoShadeFP(ren,vol); - } - else - { - this->RenderTwoDependentShadeFP(ren,vol); - } - break; - - case 3: - case 4: - if ( !vol->GetProperty()->GetShade() ) - { - this->RenderFourDependentNoShadeFP(ren,vol); - } - else - { - this->RenderFourDependentShadeFP(ren,vol); - } - } - - vtkgl::ActiveTexture( vtkgl::TEXTURE2); - glDisable( GL_TEXTURE_2D ); - glDisable( vtkgl::TEXTURE_3D ); - - vtkgl::ActiveTexture( vtkgl::TEXTURE1); - glDisable( GL_TEXTURE_2D ); - glDisable( vtkgl::TEXTURE_3D ); - - vtkgl::ActiveTexture( vtkgl::TEXTURE0); - glDisable( GL_TEXTURE_2D ); - glDisable( vtkgl::TEXTURE_3D ); - - vtkOpenGLCheckErrorMacro("failed after RenderFP"); -} - -void vtkOpenGLVolumeTextureMapper3D::RenderNV( vtkRenderer *ren, vtkVolume *vol ) -{ - vtkOpenGLClearErrorMacro(); - - glAlphaFunc (GL_GREATER, static_cast(0)); - glEnable (GL_ALPHA_TEST); - - glEnable( GL_BLEND ); - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - - int components = this->GetInput()->GetNumberOfScalarComponents(); - switch ( components ) - { - case 1: - if ( !vol->GetProperty()->GetShade() ) - { - this->RenderOneIndependentNoShadeNV(ren,vol); - } - else - { - this->RenderOneIndependentShadeNV(ren,vol); - } - break; - - case 2: - if ( !vol->GetProperty()->GetShade() ) - { - this->RenderTwoDependentNoShadeNV(ren,vol); - } - else - { - this->RenderTwoDependentShadeNV(ren,vol); - } - break; - - case 3: - case 4: - if ( !vol->GetProperty()->GetShade() ) - { - this->RenderFourDependentNoShadeNV(ren,vol); - } - else - { - this->RenderFourDependentShadeNV(ren,vol); - } - } - - vtkgl::ActiveTexture( vtkgl::TEXTURE2 ); - glDisable( GL_TEXTURE_2D ); - glDisable( vtkgl::TEXTURE_3D ); - - vtkgl::ActiveTexture( vtkgl::TEXTURE1 ); - glDisable( GL_TEXTURE_2D ); - glDisable( vtkgl::TEXTURE_3D ); - - vtkgl::ActiveTexture( vtkgl::TEXTURE0 ); - glDisable( GL_TEXTURE_2D ); - glDisable( vtkgl::TEXTURE_3D ); - - glDisable( vtkgl::TEXTURE_SHADER_NV ); - - glDisable(vtkgl::REGISTER_COMBINERS_NV); - - vtkOpenGLCheckErrorMacro("failed after RenderNV"); -} - -void vtkOpenGLVolumeTextureMapper3D::DeleteTextureIndex( GLuint *index ) -{ - if (glIsTexture(*index)) - { - GLuint tempIndex; - tempIndex = *index; - glDeleteTextures(1, &tempIndex); - vtkOpenGLCheckErrorMacro("failed at glDeleteTextures"); - *index = 0; - } -} - -void vtkOpenGLVolumeTextureMapper3D::CreateTextureIndex( GLuint *index ) -{ - GLuint tempIndex=0; - glGenTextures(1, &tempIndex); - *index = static_cast(tempIndex); -} - -void vtkOpenGLVolumeTextureMapper3D::RenderPolygons( vtkRenderer *ren, - vtkVolume *vol, - int stages[4] ) -{ - vtkRenderWindow *renWin = ren->GetRenderWindow(); - - if ( renWin->CheckAbortStatus() ) - { - return; - } - - vtkOpenGLClearErrorMacro(); - - double bounds[27][6]; - float distance2[27]; - - int numIterations; - int i, j, k; - - // No cropping case - render the whole thing - if ( !this->Cropping ) - { - // Use the input data bounds - we'll take care of the volume's - // matrix during rendering - this->GetInput()->GetBounds(bounds[0]); - numIterations = 1; - } - // Simple cropping case - render the subvolume - else if ( this->CroppingRegionFlags == 0x2000 ) - { - this->GetCroppingRegionPlanes(bounds[0]); - numIterations = 1; - } - // Complex cropping case - render each region in back-to-front order - else - { - // Get the camera position - double camPos[4]; - ren->GetActiveCamera()->GetPosition(camPos); - - double volBounds[6]; - this->GetInput()->GetBounds(volBounds); - - // Pass camera through inverse volume matrix - // so that we are in the same coordinate system - vtkMatrix4x4 *volMatrix = vtkMatrix4x4::New(); - vol->GetMatrix( volMatrix ); - camPos[3] = 1.0; - volMatrix->Invert(); - volMatrix->MultiplyPoint( camPos, camPos ); - volMatrix->Delete(); - if ( camPos[3] ) - { - camPos[0] /= camPos[3]; - camPos[1] /= camPos[3]; - camPos[2] /= camPos[3]; - } - - // These are the region limits for x (first four), y (next four) and - // z (last four). The first region limit is the lower bound for - // that axis, the next two are the region planes along that axis, and - // the final one in the upper bound for that axis. - float limit[12]; - for ( i = 0; i < 3; i++ ) - { - limit[i*4 ] = volBounds[i*2]; - limit[i*4+1] = this->CroppingRegionPlanes[i*2]; - limit[i*4+2] = this->CroppingRegionPlanes[i*2+1]; - limit[i*4+3] = volBounds[i*2+1]; - } - - // For each of the 27 possible regions, find out if it is enabled, - // and if so, compute the bounds and the distance from the camera - // to the center of the region. - int numRegions = 0; - int region; - for ( region = 0; region < 27; region++ ) - { - int regionFlag = 1<CroppingRegionFlags & regionFlag ) - { - // what is the coordinate in the 3x3x3 grid - int loc[3]; - loc[0] = region%3; - loc[1] = (region/3)%3; - loc[2] = (region/9)%3; - - // compute the bounds and center - float center[3]; - for ( i = 0; i < 3; i++ ) - { - bounds[numRegions][i*2 ] = limit[4*i+loc[i]]; - bounds[numRegions][i*2+1] = limit[4*i+loc[i]+1]; - center[i] = - (bounds[numRegions][i*2 ] + - bounds[numRegions][i*2+1])/2.0; - } - - // compute the distance squared to the center - distance2[numRegions] = - (camPos[0]-center[0])*(camPos[0]-center[0]) + - (camPos[1]-center[1])*(camPos[1]-center[1]) + - (camPos[2]-center[2])*(camPos[2]-center[2]); - - // we've added one region - numRegions++; - } - } - - // Do a quick bubble sort on distance - for ( i = 1; i < numRegions; i++ ) - { - for ( j = i; j > 0 && distance2[j] > distance2[j-1]; j-- ) - { - float tmpBounds[6]; - float tmpDistance2; - - for ( k = 0; k < 6; k++ ) - { - tmpBounds[k] = bounds[j][k]; - } - tmpDistance2 = distance2[j]; - - for ( k = 0; k < 6; k++ ) - { - bounds[j][k] = bounds[j-1][k]; - } - distance2[j] = distance2[j-1]; - - for ( k = 0; k < 6; k++ ) - { - bounds[j-1][k] = tmpBounds[k]; - } - distance2[j-1] = tmpDistance2; - - } - } - - numIterations = numRegions; - } - - // loop over all regions we need to render - for ( int loop = 0; - loop < numIterations; - loop++ ) - { - // Compute the set of polygons for this region - // according to the bounds - this->ComputePolygons( ren, vol, bounds[loop] ); - - // Loop over the polygons - for ( i = 0; i < this->NumberOfPolygons; i++ ) - { - if ( i%64 == 1 ) - { - glFlush(); - glFinish(); - } - - if ( renWin->CheckAbortStatus() ) - { - return; - } - - float *ptr = this->PolygonBuffer + 36*i; - - glBegin( GL_TRIANGLE_FAN ); - - for ( j = 0; j < 6; j++ ) - { - if ( ptr[0] < 0.0 ) - { - break; - } - - for ( k = 0; k < 4; k++ ) - { - if ( stages[k] ) - { - vtkgl::MultiTexCoord3fv( vtkgl::TEXTURE0 + k, ptr ); - } - } - glVertex3fv( ptr+3 ); - - ptr += 6; - } - glEnd(); - } - } - - vtkOpenGLCheckErrorMacro("failed after RenderPolygons"); -} - -void vtkOpenGLVolumeTextureMapper3D::Setup3DTextureParameters( vtkVolumeProperty *property ) -{ - vtkOpenGLClearErrorMacro(); - - if ( property->GetInterpolationType() == VTK_NEAREST_INTERPOLATION ) - { - glTexParameterf( vtkgl::TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); - glTexParameterf( vtkgl::TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); - } - else - { - glTexParameterf( vtkgl::TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameterf( vtkgl::TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - } - glTexParameterf( vtkgl::TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP ); - glTexParameterf( vtkgl::TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP ); - - vtkOpenGLCheckErrorMacro("failed after Setup3DTextureParameters"); -} - -void vtkOpenGLVolumeTextureMapper3D::SetupOneIndependentTextures( vtkRenderer *vtkNotUsed(ren), - vtkVolume *vol ) -{ - vtkOpenGLClearErrorMacro(); - - vtkgl::ActiveTexture( vtkgl::TEXTURE0 ); - glDisable( GL_TEXTURE_2D ); - glEnable( vtkgl::TEXTURE_3D ); - if ( this->RenderMethod == vtkVolumeTextureMapper3D::NVIDIA_METHOD ) - { - glEnable( vtkgl::TEXTURE_SHADER_NV ); - glTexEnvi(vtkgl::TEXTURE_SHADER_NV, vtkgl::SHADER_OPERATION_NV, vtkgl::TEXTURE_3D); - } - - vtkgl::ActiveTexture( vtkgl::TEXTURE2 ); - glDisable( GL_TEXTURE_2D ); - glEnable( vtkgl::TEXTURE_3D ); - if ( this->RenderMethod == vtkVolumeTextureMapper3D::NVIDIA_METHOD ) - { - glEnable( vtkgl::TEXTURE_SHADER_NV ); - glTexEnvi(vtkgl::TEXTURE_SHADER_NV, vtkgl::SHADER_OPERATION_NV, vtkgl::TEXTURE_3D); - } - - // Update the volume containing the 2 byte scalar / gradient magnitude - if ( this->UpdateVolumes( vol ) || !this->Volume1Index || !this->Volume2Index ) - { - int dim[3]; - this->GetVolumeDimensions(dim); - this->DeleteTextureIndex(&this->Volume3Index); - - vtkgl::ActiveTexture( vtkgl::TEXTURE0 ); - glBindTexture(vtkgl::TEXTURE_3D,0); - this->DeleteTextureIndex(&this->Volume1Index); - this->CreateTextureIndex(&this->Volume1Index); - glBindTexture(vtkgl::TEXTURE_3D, this->Volume1Index); - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,this->InternalLA,dim[0],dim[1], - dim[2],0,GL_LUMINANCE_ALPHA,GL_UNSIGNED_BYTE, - this->Volume1); - - - vtkgl::ActiveTexture( vtkgl::TEXTURE2 ); - glBindTexture(vtkgl::TEXTURE_3D,0); - this->DeleteTextureIndex(&this->Volume2Index); - this->CreateTextureIndex(&this->Volume2Index); - glBindTexture(vtkgl::TEXTURE_3D, this->Volume2Index); - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,this->InternalRGB,dim[0],dim[1], - dim[2],0,GL_RGB,GL_UNSIGNED_BYTE,this->Volume2); - } - - vtkgl::ActiveTexture( vtkgl::TEXTURE0 ); - glBindTexture(vtkgl::TEXTURE_3D, this->Volume1Index); - this->Setup3DTextureParameters( vol->GetProperty() ); - - vtkgl::ActiveTexture( vtkgl::TEXTURE2 ); - glBindTexture(vtkgl::TEXTURE_3D, this->Volume2Index); - this->Setup3DTextureParameters( vol->GetProperty() ); - - vtkgl::ActiveTexture( vtkgl::TEXTURE1 ); - glEnable( GL_TEXTURE_2D ); - glDisable( vtkgl::TEXTURE_3D ); - if ( this->RenderMethod == vtkVolumeTextureMapper3D::NVIDIA_METHOD ) - { - glTexEnvf ( vtkgl::TEXTURE_SHADER_NV, vtkgl::SHADER_OPERATION_NV, - vtkgl::DEPENDENT_AR_TEXTURE_2D_NV ); - glTexEnvi(vtkgl::TEXTURE_SHADER_NV, vtkgl::PREVIOUS_TEXTURE_INPUT_NV, vtkgl::TEXTURE0); - } - - // Update the dependent 2D color table mapping scalar value and - // gradient magnitude to RGBA - if ( this->UpdateColorLookup( vol ) || !this->ColorLookupIndex ) - { - this->DeleteTextureIndex( &this->ColorLookupIndex ); - this->DeleteTextureIndex( &this->AlphaLookupIndex ); - - this->CreateTextureIndex( &this->ColorLookupIndex ); - glBindTexture(GL_TEXTURE_2D, this->ColorLookupIndex); - - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); - - glTexImage2D( GL_TEXTURE_2D, 0,this->InternalRGBA, 256, 256, 0, - GL_RGBA, GL_UNSIGNED_BYTE, this->ColorLookup ); - } - - glBindTexture(GL_TEXTURE_2D, this->ColorLookupIndex); - - vtkOpenGLCheckErrorMacro("failed after SetupOneIndependentTextures"); -} - -void vtkOpenGLVolumeTextureMapper3D::SetupRegisterCombinersNoShadeNV( vtkRenderer *vtkNotUsed(ren), - vtkVolume *vtkNotUsed(vol), - int components ) -{ - vtkOpenGLClearErrorMacro(); - - if ( components < 3 ) - { - vtkgl::ActiveTexture(vtkgl::TEXTURE2); - glTexEnvi(vtkgl::TEXTURE_SHADER_NV, vtkgl::SHADER_OPERATION_NV, GL_NONE); - - if ( components == 1 ) - { - vtkgl::ActiveTexture(vtkgl::TEXTURE3); - glTexEnvi(vtkgl::TEXTURE_SHADER_NV, vtkgl::SHADER_OPERATION_NV, GL_NONE); - } - } - - - glEnable(vtkgl::REGISTER_COMBINERS_NV); - vtkgl::CombinerParameteriNV(vtkgl::NUM_GENERAL_COMBINERS_NV, 1); - vtkgl::CombinerParameteriNV(vtkgl::COLOR_SUM_CLAMP_NV, GL_TRUE); - - vtkgl::FinalCombinerInputNV(vtkgl::VARIABLE_A_NV, GL_ZERO, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::FinalCombinerInputNV(vtkgl::VARIABLE_B_NV, GL_ZERO, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::FinalCombinerInputNV(vtkgl::VARIABLE_C_NV, GL_ZERO, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - if ( components < 3 ) - { - vtkgl::FinalCombinerInputNV(vtkgl::VARIABLE_D_NV, vtkgl::TEXTURE1, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - } - else - { - vtkgl::FinalCombinerInputNV(vtkgl::VARIABLE_D_NV, vtkgl::TEXTURE0, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - } - - if ( components == 1 ) - { - vtkgl::FinalCombinerInputNV(vtkgl::VARIABLE_G_NV, vtkgl::TEXTURE1, vtkgl::UNSIGNED_IDENTITY_NV, GL_ALPHA); - } - else - { - vtkgl::FinalCombinerInputNV(vtkgl::VARIABLE_G_NV, vtkgl::TEXTURE3, vtkgl::UNSIGNED_IDENTITY_NV, GL_ALPHA); - } - - vtkOpenGLCheckErrorMacro("failed after SetupRegisterCombinersNoShadeNV"); -} - -void vtkOpenGLVolumeTextureMapper3D::SetupRegisterCombinersShadeNV( vtkRenderer *ren, - vtkVolume *vol, - int components ) -{ - vtkOpenGLClearErrorMacro(); - - if ( components == 1 ) - { - vtkgl::ActiveTexture(vtkgl::TEXTURE3); - glTexEnvi(vtkgl::TEXTURE_SHADER_NV, vtkgl::SHADER_OPERATION_NV, GL_NONE); - } - - GLfloat white[4] = {1,1,1,1}; - - GLfloat lightDirection[2][4]; - GLfloat lightDiffuseColor[2][4]; - GLfloat lightSpecularColor[2][4]; - GLfloat halfwayVector[2][4]; - GLfloat ambientColor[4]; - - // Gather information about the light sources. Although we gather info for multiple light sources, - // in this case we will only use the first one, and will duplicate it (in opposite direction) to - // approximate two-sided lighting. - this->GetLightInformation( ren, vol, lightDirection, lightDiffuseColor, - lightSpecularColor, halfwayVector, ambientColor ); - - float specularPower = vol->GetProperty()->GetSpecularPower(); - - glEnable(vtkgl::REGISTER_COMBINERS_NV); - glEnable( vtkgl::PER_STAGE_CONSTANTS_NV ); - vtkgl::CombinerParameteriNV(vtkgl::NUM_GENERAL_COMBINERS_NV, 8); - vtkgl::CombinerParameteriNV(vtkgl::COLOR_SUM_CLAMP_NV, GL_TRUE); - - // Stage 0 - // - // N dot L is computed into vtkgl::SPARE0_NV - // -N dot L is computed into vtkgl::SPARE1_NV - // - vtkgl::CombinerStageParameterfvNV( vtkgl::COMBINER0_NV, vtkgl::CONSTANT_COLOR0_NV, lightDirection[0] ); - - vtkgl::CombinerInputNV( vtkgl::COMBINER0_NV, GL_RGB, vtkgl::VARIABLE_A_NV, - vtkgl::CONSTANT_COLOR0_NV, vtkgl::EXPAND_NORMAL_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER0_NV, GL_RGB, vtkgl::VARIABLE_B_NV, - vtkgl::TEXTURE2, vtkgl::EXPAND_NORMAL_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER0_NV, GL_RGB, vtkgl::VARIABLE_C_NV, - vtkgl::CONSTANT_COLOR0_NV, vtkgl::EXPAND_NORMAL_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER0_NV, GL_RGB, vtkgl::VARIABLE_D_NV, - vtkgl::TEXTURE2, vtkgl::EXPAND_NEGATE_NV, GL_RGB ); - - vtkgl::CombinerOutputNV( vtkgl::COMBINER0_NV, GL_RGB, vtkgl::SPARE0_NV, vtkgl::SPARE1_NV, vtkgl::DISCARD_NV, - GL_NONE, GL_NONE, GL_TRUE, GL_TRUE, GL_FALSE ); - - // Stage 1 - // - // lightColor * max( 0, (N dot L)) + lightColor * max( 0, (-N dot L)) is computed into vtkgl::SPARE0_NV - // - vtkgl::CombinerStageParameterfvNV( vtkgl::COMBINER1_NV, vtkgl::CONSTANT_COLOR0_NV, lightDiffuseColor[0] ); - - vtkgl::CombinerInputNV( vtkgl::COMBINER1_NV, GL_RGB, vtkgl::VARIABLE_A_NV, - vtkgl::SPARE0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER1_NV, GL_RGB, vtkgl::VARIABLE_B_NV, - vtkgl::CONSTANT_COLOR0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER1_NV, GL_RGB, vtkgl::VARIABLE_C_NV, - vtkgl::SPARE1_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER1_NV, GL_RGB, vtkgl::VARIABLE_D_NV, - vtkgl::CONSTANT_COLOR0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - - vtkgl::CombinerOutputNV( vtkgl::COMBINER1_NV, GL_RGB, vtkgl::DISCARD_NV, vtkgl::DISCARD_NV, - vtkgl::SPARE0_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE ); - - // Stage 2 - // - // result from Stage 1 is added to the ambient color and stored in vtkgl::PRIMARY_COLOR_NV - // - vtkgl::CombinerStageParameterfvNV( vtkgl::COMBINER2_NV, vtkgl::CONSTANT_COLOR0_NV, white ); - vtkgl::CombinerStageParameterfvNV( vtkgl::COMBINER2_NV, vtkgl::CONSTANT_COLOR1_NV, ambientColor ); - - vtkgl::CombinerInputNV( vtkgl::COMBINER2_NV, GL_RGB, vtkgl::VARIABLE_A_NV, - vtkgl::SPARE0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER2_NV, GL_RGB, vtkgl::VARIABLE_B_NV, - vtkgl::CONSTANT_COLOR0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER2_NV, GL_RGB, vtkgl::VARIABLE_C_NV, - vtkgl::CONSTANT_COLOR0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER2_NV, GL_RGB, vtkgl::VARIABLE_D_NV, - vtkgl::CONSTANT_COLOR1_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - - vtkgl::CombinerOutputNV( vtkgl::COMBINER2_NV, GL_RGB, vtkgl::DISCARD_NV, vtkgl::DISCARD_NV, - vtkgl::PRIMARY_COLOR_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE ); - - // Stage 3 - // - // N dot H is computed into vtkgl::SPARE0_NV - // -N dot H is computed into vtkgl::SPARE1_NV - // - vtkgl::CombinerStageParameterfvNV( vtkgl::COMBINER3_NV, vtkgl::CONSTANT_COLOR0_NV, halfwayVector[0] ); - - vtkgl::CombinerInputNV( vtkgl::COMBINER3_NV, GL_RGB, vtkgl::VARIABLE_A_NV, - vtkgl::CONSTANT_COLOR0_NV, vtkgl::EXPAND_NORMAL_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER3_NV, GL_RGB, vtkgl::VARIABLE_B_NV, - vtkgl::TEXTURE2, vtkgl::EXPAND_NORMAL_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER3_NV, GL_RGB, vtkgl::VARIABLE_C_NV, - vtkgl::CONSTANT_COLOR0_NV, vtkgl::EXPAND_NORMAL_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER3_NV, GL_RGB, vtkgl::VARIABLE_D_NV, - vtkgl::TEXTURE2, vtkgl::EXPAND_NEGATE_NV, GL_RGB ); - - vtkgl::CombinerOutputNV( vtkgl::COMBINER3_NV, GL_RGB, vtkgl::SPARE0_NV, vtkgl::SPARE1_NV, - vtkgl::DISCARD_NV, GL_NONE, GL_NONE, GL_TRUE, GL_TRUE, GL_FALSE ); - - // Stage 4 - // - // if the specular power is greater than 1, then - // - // N dot H squared is computed into vtkgl::SPARE0_NV - // -N dot H squared is computed into vtkgl::SPARE1_NV - // - // otherwise these registers are simply multiplied by white - vtkgl::CombinerStageParameterfvNV( vtkgl::COMBINER4_NV, vtkgl::CONSTANT_COLOR0_NV, white ); - - vtkgl::CombinerInputNV( vtkgl::COMBINER4_NV, GL_RGB, vtkgl::VARIABLE_A_NV, - vtkgl::SPARE0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER4_NV, GL_RGB, vtkgl::VARIABLE_C_NV, - vtkgl::SPARE1_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - if ( specularPower > 1.0 ) - { - vtkgl::CombinerInputNV( vtkgl::COMBINER4_NV, GL_RGB, vtkgl::VARIABLE_B_NV, - vtkgl::SPARE0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER4_NV, GL_RGB, vtkgl::VARIABLE_D_NV, - vtkgl::SPARE1_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - } - else - { - vtkgl::CombinerInputNV( vtkgl::COMBINER4_NV, GL_RGB, vtkgl::VARIABLE_B_NV, - vtkgl::CONSTANT_COLOR0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER4_NV, GL_RGB, vtkgl::VARIABLE_D_NV, - vtkgl::CONSTANT_COLOR0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - } - - vtkgl::CombinerOutputNV( vtkgl::COMBINER4_NV, GL_RGB, vtkgl::SPARE0_NV, vtkgl::SPARE1_NV, vtkgl::DISCARD_NV, - GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE ); - - // Stage 5 - // - // if the specular power is greater than 3, then - // - // N dot H to the fourth is computed into vtkgl::SPARE0_NV - // -N dot H to the fourth is computed into vtkgl::SPARE1_NV - // - // otherwise these registers are simply multiplied by white - vtkgl::CombinerStageParameterfvNV( vtkgl::COMBINER5_NV, vtkgl::CONSTANT_COLOR0_NV, white ); - - vtkgl::CombinerInputNV( vtkgl::COMBINER5_NV, GL_RGB, vtkgl::VARIABLE_A_NV, - vtkgl::SPARE0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER5_NV, GL_RGB, vtkgl::VARIABLE_C_NV, - vtkgl::SPARE1_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - if ( specularPower > 3.0 ) - { - vtkgl::CombinerInputNV( vtkgl::COMBINER5_NV, GL_RGB, vtkgl::VARIABLE_B_NV, - vtkgl::SPARE0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER5_NV, GL_RGB, vtkgl::VARIABLE_D_NV, - vtkgl::SPARE1_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - } - else - { - vtkgl::CombinerInputNV( vtkgl::COMBINER5_NV, GL_RGB, vtkgl::VARIABLE_B_NV, - vtkgl::CONSTANT_COLOR0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER5_NV, GL_RGB, vtkgl::VARIABLE_D_NV, - vtkgl::CONSTANT_COLOR0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - } - - vtkgl::CombinerOutputNV( vtkgl::COMBINER5_NV, GL_RGB, vtkgl::SPARE0_NV, vtkgl::SPARE1_NV, vtkgl::DISCARD_NV, - GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE ); - - // Stage 6 - // - // if the specular power is greater than 6, then - // - // N dot H to the eighth is computed into vtkgl::SPARE0_NV - // -N dot H to the eighth is computed into vtkgl::SPARE1_NV - // - // otherwise these registers are simply multiplied by white - vtkgl::CombinerStageParameterfvNV( vtkgl::COMBINER6_NV, vtkgl::CONSTANT_COLOR0_NV, white ); - - vtkgl::CombinerInputNV( vtkgl::COMBINER6_NV, GL_RGB, vtkgl::VARIABLE_A_NV, - vtkgl::SPARE0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER6_NV, GL_RGB, vtkgl::VARIABLE_C_NV, - vtkgl::SPARE1_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - - if ( specularPower > 6.0 ) - { - vtkgl::CombinerInputNV( vtkgl::COMBINER6_NV, GL_RGB, vtkgl::VARIABLE_B_NV, - vtkgl::SPARE0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER6_NV, GL_RGB, vtkgl::VARIABLE_D_NV, - vtkgl::SPARE1_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - } - else - { - vtkgl::CombinerInputNV( vtkgl::COMBINER6_NV, GL_RGB, vtkgl::VARIABLE_B_NV, - vtkgl::CONSTANT_COLOR0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER6_NV, GL_RGB, vtkgl::VARIABLE_D_NV, - vtkgl::CONSTANT_COLOR0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - } - - vtkgl::CombinerOutputNV( vtkgl::COMBINER6_NV, GL_RGB, vtkgl::SPARE0_NV, vtkgl::SPARE1_NV, - vtkgl::DISCARD_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE ); - - - // Stage 7 - // - // Add the two specular contributions and multiply each by the specular color. - vtkgl::CombinerStageParameterfvNV( vtkgl::COMBINER7_NV, vtkgl::CONSTANT_COLOR0_NV, lightSpecularColor[0] ); - vtkgl::CombinerStageParameterfvNV( vtkgl::COMBINER7_NV, vtkgl::CONSTANT_COLOR1_NV, lightSpecularColor[1] ); - - vtkgl::CombinerInputNV( vtkgl::COMBINER7_NV, GL_RGB, vtkgl::VARIABLE_A_NV, - vtkgl::SPARE0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER7_NV, GL_RGB, vtkgl::VARIABLE_B_NV, - vtkgl::CONSTANT_COLOR0_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER7_NV, GL_RGB, vtkgl::VARIABLE_C_NV, - vtkgl::SPARE1_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::CombinerInputNV( vtkgl::COMBINER7_NV, GL_RGB, vtkgl::VARIABLE_D_NV, - vtkgl::CONSTANT_COLOR1_NV, vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - - vtkgl::CombinerOutputNV( vtkgl::COMBINER7_NV, GL_RGB, vtkgl::DISCARD_NV, - vtkgl::DISCARD_NV, vtkgl::SPARE0_NV, - GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE ); - - vtkgl::FinalCombinerInputNV(vtkgl::VARIABLE_A_NV, vtkgl::PRIMARY_COLOR_NV, - vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - if ( components < 3 ) - { - vtkgl::FinalCombinerInputNV(vtkgl::VARIABLE_B_NV, vtkgl::TEXTURE1, - vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - } - else - { - vtkgl::FinalCombinerInputNV(vtkgl::VARIABLE_B_NV, vtkgl::TEXTURE0, - vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - } - vtkgl::FinalCombinerInputNV(vtkgl::VARIABLE_C_NV, GL_ZERO, - vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - vtkgl::FinalCombinerInputNV(vtkgl::VARIABLE_D_NV, vtkgl::SPARE0_NV, - vtkgl::UNSIGNED_IDENTITY_NV, GL_RGB ); - - if ( components == 1 ) - { - vtkgl::FinalCombinerInputNV(vtkgl::VARIABLE_G_NV, vtkgl::TEXTURE1, - vtkgl::UNSIGNED_IDENTITY_NV, GL_ALPHA); - } - else - { - vtkgl::FinalCombinerInputNV(vtkgl::VARIABLE_G_NV, vtkgl::TEXTURE3, - vtkgl::UNSIGNED_IDENTITY_NV, GL_ALPHA); - } - - vtkOpenGLCheckErrorMacro("failed after SetupRegisterCombinersShadeNV"); -} - -void vtkOpenGLVolumeTextureMapper3D::RenderOneIndependentNoShadeNV( - vtkRenderer *ren, - vtkVolume *vol ) -{ - this->SetupOneIndependentTextures( ren, vol ); - - // Start the timer now - this->Timer->StartTimer(); - - this->SetupRegisterCombinersNoShadeNV( ren, vol, 1 ); - - int stages[4] = {1,0,0,0}; - this->RenderPolygons( ren, vol, stages ); -} - - -void vtkOpenGLVolumeTextureMapper3D::RenderOneIndependentShadeNV( - vtkRenderer *ren, - vtkVolume *vol ) -{ - this->SetupOneIndependentTextures( ren, vol ); - - // Start the timer now - this->Timer->StartTimer(); - - this->SetupRegisterCombinersShadeNV( ren, vol, 1 ); - - int stages[4] = {1,0,1,0}; - this->RenderPolygons( ren, vol, stages ); -} - - -void vtkOpenGLVolumeTextureMapper3D::SetupTwoDependentTextures( - vtkRenderer *vtkNotUsed(ren), - vtkVolume *vol ) -{ - vtkOpenGLClearErrorMacro(); - - vtkgl::ActiveTexture( vtkgl::TEXTURE0 ); - glDisable( GL_TEXTURE_2D ); - glEnable( vtkgl::TEXTURE_3D ); - if ( this->RenderMethod == vtkVolumeTextureMapper3D::NVIDIA_METHOD ) - { - glEnable( vtkgl::TEXTURE_SHADER_NV ); - glTexEnvi(vtkgl::TEXTURE_SHADER_NV, vtkgl::SHADER_OPERATION_NV, vtkgl::TEXTURE_3D); - } - - vtkgl::ActiveTexture( vtkgl::TEXTURE2 ); - glDisable( GL_TEXTURE_2D ); - glEnable( vtkgl::TEXTURE_3D ); - if ( this->RenderMethod == vtkVolumeTextureMapper3D::NVIDIA_METHOD ) - { - glEnable( vtkgl::TEXTURE_SHADER_NV ); - glTexEnvi(vtkgl::TEXTURE_SHADER_NV, vtkgl::SHADER_OPERATION_NV, vtkgl::TEXTURE_3D); - } - - // Update the volume containing the 3 byte scalars / gradient magnitude - if ( this->UpdateVolumes( vol ) || !this->Volume1Index || !this->Volume2Index ) - { - int dim[3]; - this->GetVolumeDimensions(dim); - this->DeleteTextureIndex(&this->Volume3Index); - - vtkgl::ActiveTexture( vtkgl::TEXTURE0 ); - glBindTexture(vtkgl::TEXTURE_3D,0); - this->DeleteTextureIndex(&this->Volume1Index); - this->CreateTextureIndex(&this->Volume1Index); - glBindTexture(vtkgl::TEXTURE_3D, this->Volume1Index); - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,this->InternalRGB,dim[0],dim[1], - dim[2],0,GL_RGB,GL_UNSIGNED_BYTE,this->Volume1); - - vtkgl::ActiveTexture( vtkgl::TEXTURE2 ); - glBindTexture(vtkgl::TEXTURE_3D,0); - this->DeleteTextureIndex(&this->Volume2Index); - this->CreateTextureIndex(&this->Volume2Index); - glBindTexture(vtkgl::TEXTURE_3D, this->Volume2Index); - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,this->InternalRGB,dim[0],dim[1], - dim[2],0,GL_RGB,GL_UNSIGNED_BYTE,this->Volume2); - } - - vtkgl::ActiveTexture( vtkgl::TEXTURE0 ); - glBindTexture(vtkgl::TEXTURE_3D, this->Volume1Index); - this->Setup3DTextureParameters( vol->GetProperty() ); - - vtkgl::ActiveTexture( vtkgl::TEXTURE2 ); - glBindTexture(vtkgl::TEXTURE_3D, this->Volume2Index); - this->Setup3DTextureParameters( vol->GetProperty() ); - - vtkgl::ActiveTexture( vtkgl::TEXTURE1 ); - glEnable( GL_TEXTURE_2D ); - glDisable( vtkgl::TEXTURE_3D ); - if ( this->RenderMethod == vtkVolumeTextureMapper3D::NVIDIA_METHOD ) - { - glTexEnvf ( vtkgl::TEXTURE_SHADER_NV, vtkgl::SHADER_OPERATION_NV, - vtkgl::DEPENDENT_AR_TEXTURE_2D_NV ); - glTexEnvi(vtkgl::TEXTURE_SHADER_NV, vtkgl::PREVIOUS_TEXTURE_INPUT_NV, vtkgl::TEXTURE0); - } - - vtkgl::ActiveTexture( vtkgl::TEXTURE3 ); - glEnable( GL_TEXTURE_2D ); - glDisable( vtkgl::TEXTURE_3D ); - if ( this->RenderMethod == vtkVolumeTextureMapper3D::NVIDIA_METHOD ) - { - glTexEnvf ( vtkgl::TEXTURE_SHADER_NV, vtkgl::SHADER_OPERATION_NV, - vtkgl::DEPENDENT_GB_TEXTURE_2D_NV ); - glTexEnvi(vtkgl::TEXTURE_SHADER_NV, vtkgl::PREVIOUS_TEXTURE_INPUT_NV, vtkgl::TEXTURE0); - } - - // Update the dependent 2D color table mapping scalar value and - // gradient magnitude to RGBA - if ( this->UpdateColorLookup( vol ) || - !this->ColorLookupIndex || !this->AlphaLookupIndex ) - { - vtkgl::ActiveTexture( vtkgl::TEXTURE1 ); - glBindTexture(GL_TEXTURE_2D,0); - this->DeleteTextureIndex(&this->ColorLookupIndex); - this->CreateTextureIndex(&this->ColorLookupIndex); - glBindTexture(GL_TEXTURE_2D, this->ColorLookupIndex); - - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); - - glTexImage2D(GL_TEXTURE_2D,0,this->InternalRGB, 256, 256, 0, - GL_RGB, GL_UNSIGNED_BYTE, this->ColorLookup ); - - vtkgl::ActiveTexture( vtkgl::TEXTURE3 ); - glBindTexture(GL_TEXTURE_2D,0); - this->DeleteTextureIndex(&this->AlphaLookupIndex); - this->CreateTextureIndex(&this->AlphaLookupIndex); - glBindTexture(GL_TEXTURE_2D, this->AlphaLookupIndex); - - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); - - glTexImage2D(GL_TEXTURE_2D, 0,this->InternalAlpha, 256, 256, 0, - GL_ALPHA, GL_UNSIGNED_BYTE, this->AlphaLookup ); - } - - vtkgl::ActiveTexture( vtkgl::TEXTURE1 ); - glBindTexture(GL_TEXTURE_2D, this->ColorLookupIndex); - - vtkgl::ActiveTexture( vtkgl::TEXTURE3 ); - glBindTexture(GL_TEXTURE_2D, this->AlphaLookupIndex); - - vtkOpenGLCheckErrorMacro("failed after SetupTwoDependentTextures"); -} - -void vtkOpenGLVolumeTextureMapper3D::RenderTwoDependentNoShadeNV( - vtkRenderer *ren, - vtkVolume *vol ) -{ - this->SetupTwoDependentTextures(ren, vol); - - // Start the timer now - this->Timer->StartTimer(); - - this->SetupRegisterCombinersNoShadeNV( ren, vol, 2 ); - - int stages[4] = {1,0,0,0}; - this->RenderPolygons( ren, vol, stages ); -} - -void vtkOpenGLVolumeTextureMapper3D::RenderTwoDependentShadeNV( - vtkRenderer *ren, - vtkVolume *vol ) -{ - this->SetupTwoDependentTextures( ren, vol ); - - // Start the timer now - this->Timer->StartTimer(); - - this->SetupRegisterCombinersShadeNV( ren, vol, 2 ); - - int stages[4] = {1,0,1,0}; - this->RenderPolygons( ren, vol, stages ); -} - -void vtkOpenGLVolumeTextureMapper3D::SetupFourDependentTextures( - vtkRenderer *vtkNotUsed(ren), - vtkVolume *vol ) -{ - vtkOpenGLClearErrorMacro(); - - vtkgl::ActiveTexture( vtkgl::TEXTURE0 ); - glDisable( GL_TEXTURE_2D ); - glEnable( vtkgl::TEXTURE_3D ); - if ( this->RenderMethod == vtkVolumeTextureMapper3D::NVIDIA_METHOD ) - { - glEnable( vtkgl::TEXTURE_SHADER_NV ); - glTexEnvi(vtkgl::TEXTURE_SHADER_NV, vtkgl::SHADER_OPERATION_NV, vtkgl::TEXTURE_3D); - } - - vtkgl::ActiveTexture( vtkgl::TEXTURE1 ); - glDisable( GL_TEXTURE_2D ); - glEnable( vtkgl::TEXTURE_3D ); - if ( this->RenderMethod == vtkVolumeTextureMapper3D::NVIDIA_METHOD ) - { - glEnable( vtkgl::TEXTURE_SHADER_NV ); - glTexEnvi(vtkgl::TEXTURE_SHADER_NV, vtkgl::SHADER_OPERATION_NV, vtkgl::TEXTURE_3D); - } - - vtkgl::ActiveTexture( vtkgl::TEXTURE2 ); - glDisable( GL_TEXTURE_2D ); - glEnable( vtkgl::TEXTURE_3D ); - if ( this->RenderMethod == vtkVolumeTextureMapper3D::NVIDIA_METHOD ) - { - glEnable( vtkgl::TEXTURE_SHADER_NV ); - glTexEnvi(vtkgl::TEXTURE_SHADER_NV, vtkgl::SHADER_OPERATION_NV, vtkgl::TEXTURE_3D); - } - - // Update the volume containing the 3 byte scalars / gradient magnitude - if ( this->UpdateVolumes( vol ) || !this->Volume1Index || - !this->Volume2Index || !this->Volume3Index ) - { - int dim[3]; - this->GetVolumeDimensions(dim); - - vtkgl::ActiveTexture( vtkgl::TEXTURE0 ); - glBindTexture(vtkgl::TEXTURE_3D,0); - this->DeleteTextureIndex(&this->Volume1Index); - this->CreateTextureIndex(&this->Volume1Index); - glBindTexture(vtkgl::TEXTURE_3D, this->Volume1Index); - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,this->InternalRGB,dim[0],dim[1], - dim[2],0,GL_RGB,GL_UNSIGNED_BYTE,this->Volume1); - - vtkgl::ActiveTexture( vtkgl::TEXTURE1 ); - glBindTexture(vtkgl::TEXTURE_3D,0); - this->DeleteTextureIndex(&this->Volume2Index); - this->CreateTextureIndex(&this->Volume2Index); - glBindTexture(vtkgl::TEXTURE_3D, this->Volume2Index); - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,this->InternalLA,dim[0],dim[1], - dim[2],0,GL_LUMINANCE_ALPHA,GL_UNSIGNED_BYTE, - this->Volume2); - - vtkgl::ActiveTexture( vtkgl::TEXTURE2 ); - glBindTexture(vtkgl::TEXTURE_3D,0); - this->DeleteTextureIndex(&this->Volume3Index); - this->CreateTextureIndex(&this->Volume3Index); - glBindTexture(vtkgl::TEXTURE_3D, this->Volume3Index); - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,this->InternalRGB,dim[0],dim[1], - dim[2],0,GL_RGB,GL_UNSIGNED_BYTE,this->Volume3); - } - - vtkgl::ActiveTexture( vtkgl::TEXTURE0 ); - glBindTexture(vtkgl::TEXTURE_3D, this->Volume1Index); - this->Setup3DTextureParameters( vol->GetProperty() ); - - vtkgl::ActiveTexture( vtkgl::TEXTURE1 ); - glBindTexture(vtkgl::TEXTURE_3D, this->Volume2Index); - this->Setup3DTextureParameters( vol->GetProperty() ); - - vtkgl::ActiveTexture( vtkgl::TEXTURE2 ); - glBindTexture(vtkgl::TEXTURE_3D_EXT, this->Volume3Index); - this->Setup3DTextureParameters( vol->GetProperty() ); - - vtkgl::ActiveTexture( vtkgl::TEXTURE3 ); - glEnable( GL_TEXTURE_2D ); - glDisable( vtkgl::TEXTURE_3D ); - if ( this->RenderMethod == vtkVolumeTextureMapper3D::NVIDIA_METHOD ) - { - glTexEnvf ( vtkgl::TEXTURE_SHADER_NV, vtkgl::SHADER_OPERATION_NV, - vtkgl::DEPENDENT_AR_TEXTURE_2D_NV ); - glTexEnvi(vtkgl::TEXTURE_SHADER_NV, vtkgl::PREVIOUS_TEXTURE_INPUT_NV, - vtkgl::TEXTURE1); - } - - // Update the dependent 2D table mapping scalar value and - // gradient magnitude to opacity - if ( this->UpdateColorLookup( vol ) || !this->AlphaLookupIndex ) - { - this->DeleteTextureIndex(&this->ColorLookupIndex); - - vtkgl::ActiveTexture( vtkgl::TEXTURE3 ); - glBindTexture(GL_TEXTURE_2D,0); - this->DeleteTextureIndex(&this->AlphaLookupIndex); - this->CreateTextureIndex(&this->AlphaLookupIndex); - glBindTexture(GL_TEXTURE_2D, this->AlphaLookupIndex); - - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); - - glTexImage2D(GL_TEXTURE_2D,0,this->InternalAlpha, 256, 256, 0, - GL_ALPHA, GL_UNSIGNED_BYTE, this->AlphaLookup ); - } - - vtkgl::ActiveTexture( vtkgl::TEXTURE3 ); - glBindTexture(GL_TEXTURE_2D, this->AlphaLookupIndex); - - vtkOpenGLCheckErrorMacro("failed after SetupFourDependentTextures"); -} - -void vtkOpenGLVolumeTextureMapper3D::RenderFourDependentNoShadeNV( - vtkRenderer *ren, - vtkVolume *vol ) -{ - this->SetupFourDependentTextures(ren, vol); - - // Start the timer now - this->Timer->StartTimer(); - - this->SetupRegisterCombinersNoShadeNV( ren, vol, 4 ); - - int stages[4] = {1,1,0,0}; - this->RenderPolygons( ren, vol, stages ); -} - -void vtkOpenGLVolumeTextureMapper3D::RenderFourDependentShadeNV( - vtkRenderer *ren, - vtkVolume *vol ) -{ - this->SetupFourDependentTextures( ren, vol ); - - // Start the timer now - this->Timer->StartTimer(); - - this->SetupRegisterCombinersShadeNV( ren, vol, 4 ); - - int stages[4] = {1,1,1,0}; - this->RenderPolygons( ren, vol, stages ); -} - -void vtkOpenGLVolumeTextureMapper3D::RenderOneIndependentNoShadeFP( - vtkRenderer *ren, - vtkVolume *vol ) -{ - vtkOpenGLClearErrorMacro(); - - glEnable( vtkgl::FRAGMENT_PROGRAM_ARB ); - - GLuint fragmentProgram; - vtkgl::GenProgramsARB( 1, &fragmentProgram ); - - - vtkgl::BindProgramARB( vtkgl::FRAGMENT_PROGRAM_ARB, fragmentProgram ); - - vtkgl::ProgramStringARB( vtkgl::FRAGMENT_PROGRAM_ARB, - vtkgl::PROGRAM_FORMAT_ASCII_ARB, - static_cast(strlen(vtkVolumeTextureMapper3D_OneComponentNoShadeFP)), - vtkVolumeTextureMapper3D_OneComponentNoShadeFP ); - - this->SetupOneIndependentTextures( ren, vol ); - - // Start the timer now - this->Timer->StartTimer(); - - int stages[4] = {1,0,0,0}; - this->RenderPolygons( ren, vol, stages ); - - glDisable( vtkgl::FRAGMENT_PROGRAM_ARB ); - - vtkgl::DeleteProgramsARB( 1, &fragmentProgram ); - - vtkOpenGLCheckErrorMacro("failed after RenderOneIndependentNoShadeFP"); -} - -void vtkOpenGLVolumeTextureMapper3D::RenderOneIndependentShadeFP( - vtkRenderer *ren, - vtkVolume *vol ) -{ - vtkOpenGLClearErrorMacro(); - - glEnable( vtkgl::FRAGMENT_PROGRAM_ARB ); - - GLuint fragmentProgram; - vtkgl::GenProgramsARB( 1, &fragmentProgram ); - - - vtkgl::BindProgramARB( vtkgl::FRAGMENT_PROGRAM_ARB, fragmentProgram ); - - vtkgl::ProgramStringARB( vtkgl::FRAGMENT_PROGRAM_ARB, - vtkgl::PROGRAM_FORMAT_ASCII_ARB, - static_cast(strlen(vtkVolumeTextureMapper3D_OneComponentShadeFP)), - vtkVolumeTextureMapper3D_OneComponentShadeFP ); - - this->SetupOneIndependentTextures( ren, vol ); - this->SetupProgramLocalsForShadingFP( ren, vol ); - - // Start the timer now - this->Timer->StartTimer(); - - int stages[4] = {1,1,1,0}; - this->RenderPolygons( ren, vol, stages ); - - glDisable( vtkgl::FRAGMENT_PROGRAM_ARB ); - - vtkgl::DeleteProgramsARB( 1, &fragmentProgram ); - - vtkOpenGLCheckErrorMacro("failed after RenderOneIndependentShadeFP"); -} - -void vtkOpenGLVolumeTextureMapper3D::RenderTwoDependentNoShadeFP( - vtkRenderer *ren, - vtkVolume *vol ) -{ - vtkOpenGLClearErrorMacro(); - - glEnable( vtkgl::FRAGMENT_PROGRAM_ARB ); - - GLuint fragmentProgram; - vtkgl::GenProgramsARB( 1, &fragmentProgram ); - - vtkgl::BindProgramARB( vtkgl::FRAGMENT_PROGRAM_ARB, fragmentProgram ); - - vtkgl::ProgramStringARB( vtkgl::FRAGMENT_PROGRAM_ARB, - vtkgl::PROGRAM_FORMAT_ASCII_ARB, - static_cast(strlen(vtkVolumeTextureMapper3D_TwoDependentNoShadeFP)), - vtkVolumeTextureMapper3D_TwoDependentNoShadeFP ); - - this->SetupTwoDependentTextures(ren, vol); - - // Start the timer now - this->Timer->StartTimer(); - - int stages[4] = {1,0,0,0}; - this->RenderPolygons( ren, vol, stages ); - - glDisable( vtkgl::FRAGMENT_PROGRAM_ARB ); - - vtkgl::DeleteProgramsARB( 1, &fragmentProgram ); - - vtkOpenGLCheckErrorMacro("failed after RenderTwoDependentNoShadeFP"); -} - - -void vtkOpenGLVolumeTextureMapper3D::RenderTwoDependentShadeFP( - vtkRenderer *ren, - vtkVolume *vol ) -{ - vtkOpenGLClearErrorMacro(); - - glEnable( vtkgl::FRAGMENT_PROGRAM_ARB ); - - GLuint fragmentProgram; - vtkgl::GenProgramsARB( 1, &fragmentProgram ); - - vtkgl::BindProgramARB( vtkgl::FRAGMENT_PROGRAM_ARB, fragmentProgram ); - - vtkgl::ProgramStringARB( vtkgl::FRAGMENT_PROGRAM_ARB, - vtkgl::PROGRAM_FORMAT_ASCII_ARB, - static_cast(strlen(vtkVolumeTextureMapper3D_TwoDependentShadeFP)), - vtkVolumeTextureMapper3D_TwoDependentShadeFP ); - - this->SetupTwoDependentTextures(ren, vol); - this->SetupProgramLocalsForShadingFP( ren, vol ); - - // Start the timer now - this->Timer->StartTimer(); - - int stages[4] = {1,0,1,0}; - this->RenderPolygons( ren, vol, stages ); - - glDisable( vtkgl::FRAGMENT_PROGRAM_ARB ); - - vtkgl::DeleteProgramsARB( 1, &fragmentProgram ); - - vtkOpenGLCheckErrorMacro("failed after RenderTwoDependentShadeFP"); -} - -void vtkOpenGLVolumeTextureMapper3D::RenderFourDependentNoShadeFP( - vtkRenderer *ren, - vtkVolume *vol ) -{ - vtkOpenGLClearErrorMacro(); - - glEnable( vtkgl::FRAGMENT_PROGRAM_ARB ); - - GLuint fragmentProgram; - vtkgl::GenProgramsARB( 1, &fragmentProgram ); - - vtkgl::BindProgramARB( vtkgl::FRAGMENT_PROGRAM_ARB, fragmentProgram ); - - vtkgl::ProgramStringARB( vtkgl::FRAGMENT_PROGRAM_ARB, - vtkgl::PROGRAM_FORMAT_ASCII_ARB, - static_cast(strlen(vtkVolumeTextureMapper3D_FourDependentNoShadeFP)), - vtkVolumeTextureMapper3D_FourDependentNoShadeFP ); - - this->SetupFourDependentTextures(ren, vol); - - // Start the timer now - this->Timer->StartTimer(); - - int stages[4] = {1,1,0,0}; - this->RenderPolygons( ren, vol, stages ); - - glDisable( vtkgl::FRAGMENT_PROGRAM_ARB ); - - vtkgl::DeleteProgramsARB( 1, &fragmentProgram ); - - vtkOpenGLCheckErrorMacro("failed after RenderFourDependentNoShadeFP"); -} - -void vtkOpenGLVolumeTextureMapper3D::RenderFourDependentShadeFP( - vtkRenderer *ren, - vtkVolume *vol ) -{ - vtkOpenGLClearErrorMacro(); - - glEnable( vtkgl::FRAGMENT_PROGRAM_ARB ); - - GLuint fragmentProgram; - vtkgl::GenProgramsARB( 1, &fragmentProgram ); - - vtkgl::BindProgramARB( vtkgl::FRAGMENT_PROGRAM_ARB, fragmentProgram ); - - vtkgl::ProgramStringARB( vtkgl::FRAGMENT_PROGRAM_ARB, - vtkgl::PROGRAM_FORMAT_ASCII_ARB, - static_cast(strlen(vtkVolumeTextureMapper3D_FourDependentShadeFP)), - vtkVolumeTextureMapper3D_FourDependentShadeFP ); - - this->SetupFourDependentTextures(ren, vol); - this->SetupProgramLocalsForShadingFP( ren, vol ); - - // Start the timer now - this->Timer->StartTimer(); - - int stages[4] = {1,1,1,0}; - this->RenderPolygons( ren, vol, stages ); - - glDisable( vtkgl::FRAGMENT_PROGRAM_ARB ); - - vtkgl::DeleteProgramsARB( 1, &fragmentProgram ); - - vtkOpenGLCheckErrorMacro("failed after RenderFourDependentShadeFP"); -} - - -void vtkOpenGLVolumeTextureMapper3D::GetLightInformation( - vtkRenderer *ren, - vtkVolume *vol, - GLfloat lightDirection[2][4], - GLfloat lightDiffuseColor[2][4], - GLfloat lightSpecularColor[2][4], - GLfloat halfwayVector[2][4], - GLfloat ambientColor[4] ) -{ - float ambient = vol->GetProperty()->GetAmbient(); - float diffuse = vol->GetProperty()->GetDiffuse(); - float specular = vol->GetProperty()->GetSpecular(); - - vtkTransform *volumeTransform = vtkTransform::New(); - - volumeTransform->SetMatrix( vol->GetMatrix() ); - volumeTransform->Inverse(); - - vtkLightCollection *lights = ren->GetLights(); - lights->InitTraversal(); - - vtkLight *light[2]; - light[0] = lights->GetNextItem(); - light[1] = lights->GetNextItem(); - - int lightIndex = 0; - - double cameraPosition[3]; - double cameraFocalPoint[3]; - - ren->GetActiveCamera()->GetPosition( cameraPosition ); - ren->GetActiveCamera()->GetFocalPoint( cameraFocalPoint ); - - double viewDirection[3]; - - volumeTransform->TransformPoint( cameraPosition, cameraPosition ); - volumeTransform->TransformPoint( cameraFocalPoint, cameraFocalPoint ); - - viewDirection[0] = cameraFocalPoint[0] - cameraPosition[0]; - viewDirection[1] = cameraFocalPoint[1] - cameraPosition[1]; - viewDirection[2] = cameraFocalPoint[2] - cameraPosition[2]; - - vtkMath::Normalize( viewDirection ); - - - ambientColor[0] = 0.0; - ambientColor[1] = 0.0; - ambientColor[2] = 0.0; - ambientColor[3] = 0.0; - - for ( lightIndex = 0; lightIndex < 2; lightIndex++ ) - { - float dir[3] = {0,0,0}; - float half[3] = {0,0,0}; - - if ( light[lightIndex] == NULL || - light[lightIndex]->GetSwitch() == 0 ) - { - lightDiffuseColor[lightIndex][0] = 0.0; - lightDiffuseColor[lightIndex][1] = 0.0; - lightDiffuseColor[lightIndex][2] = 0.0; - lightDiffuseColor[lightIndex][3] = 0.0; - - lightSpecularColor[lightIndex][0] = 0.0; - lightSpecularColor[lightIndex][1] = 0.0; - lightSpecularColor[lightIndex][2] = 0.0; - lightSpecularColor[lightIndex][3] = 0.0; - } - else - { - float lightIntensity = light[lightIndex]->GetIntensity(); - double lightAmbColor[3]; - double lightDiffColor[3]; - double lightSpecColor[3]; - light[lightIndex]->GetAmbientColor( lightAmbColor ); - light[lightIndex]->GetDiffuseColor( lightDiffColor ); - light[lightIndex]->GetSpecularColor( lightSpecColor ); - - double lightPosition[3]; - double lightFocalPoint[3]; - light[lightIndex]->GetTransformedPosition( lightPosition ); - light[lightIndex]->GetTransformedFocalPoint( lightFocalPoint ); - - volumeTransform->TransformPoint( lightPosition, lightPosition ); - volumeTransform->TransformPoint( lightFocalPoint, lightFocalPoint ); - - dir[0] = lightPosition[0] - lightFocalPoint[0]; - dir[1] = lightPosition[1] - lightFocalPoint[1]; - dir[2] = lightPosition[2] - lightFocalPoint[2]; - - vtkMath::Normalize( dir ); - - lightDiffuseColor[lightIndex][0] = lightDiffColor[0]*diffuse - *lightIntensity; - lightDiffuseColor[lightIndex][1] = lightDiffColor[1]*diffuse - *lightIntensity; - lightDiffuseColor[lightIndex][2] = lightDiffColor[2]*diffuse - *lightIntensity; - lightDiffuseColor[lightIndex][3] = 1.0; - - lightSpecularColor[lightIndex][0]= lightSpecColor[0]*specular - *lightIntensity; - lightSpecularColor[lightIndex][1]= lightSpecColor[1]*specular - *lightIntensity; - lightSpecularColor[lightIndex][2]= lightSpecColor[2]*specular - *lightIntensity; - lightSpecularColor[lightIndex][3] = 0.0; - - half[0] = dir[0] - viewDirection[0]; - half[1] = dir[1] - viewDirection[1]; - half[2] = dir[2] - viewDirection[2]; - - vtkMath::Normalize( half ); - - ambientColor[0] += ambient*lightAmbColor[0]; - ambientColor[1] += ambient*lightAmbColor[1]; - ambientColor[2] += ambient*lightAmbColor[2]; - } - - lightDirection[lightIndex][0] = (dir[0]+1.0)/2.0; - lightDirection[lightIndex][1] = (dir[1]+1.0)/2.0; - lightDirection[lightIndex][2] = (dir[2]+1.0)/2.0; - lightDirection[lightIndex][3] = 0.0; - - halfwayVector[lightIndex][0] = (half[0]+1.0)/2.0; - halfwayVector[lightIndex][1] = (half[1]+1.0)/2.0; - halfwayVector[lightIndex][2] = (half[2]+1.0)/2.0; - halfwayVector[lightIndex][3] = 0.0; - } - - volumeTransform->Delete(); - -} - -void vtkOpenGLVolumeTextureMapper3D::SetupProgramLocalsForShadingFP( - vtkRenderer *ren, - vtkVolume *vol ) -{ - vtkOpenGLClearErrorMacro(); - - GLfloat lightDirection[2][4]; - GLfloat lightDiffuseColor[2][4]; - GLfloat lightSpecularColor[2][4]; - GLfloat halfwayVector[2][4]; - GLfloat ambientColor[4]; - - float ambient = vol->GetProperty()->GetAmbient(); - float diffuse = vol->GetProperty()->GetDiffuse(); - float specular = vol->GetProperty()->GetSpecular(); - float specularPower = vol->GetProperty()->GetSpecularPower(); - - vtkTransform *volumeTransform = vtkTransform::New(); - - volumeTransform->SetMatrix( vol->GetMatrix() ); - volumeTransform->Inverse(); - - vtkLightCollection *lights = ren->GetLights(); - lights->InitTraversal(); - - vtkLight *light[2]; - light[0] = lights->GetNextItem(); - light[1] = lights->GetNextItem(); - - int lightIndex = 0; - - double cameraPosition[3]; - double cameraFocalPoint[3]; - - ren->GetActiveCamera()->GetPosition( cameraPosition ); - ren->GetActiveCamera()->GetFocalPoint( cameraFocalPoint ); - - volumeTransform->TransformPoint( cameraPosition, cameraPosition ); - volumeTransform->TransformPoint( cameraFocalPoint, cameraFocalPoint ); - - double viewDirection[4]; - - viewDirection[0] = cameraFocalPoint[0] - cameraPosition[0]; - viewDirection[1] = cameraFocalPoint[1] - cameraPosition[1]; - viewDirection[2] = cameraFocalPoint[2] - cameraPosition[2]; - viewDirection[3] = 0.0; - - vtkMath::Normalize( viewDirection ); - - ambientColor[0] = 0.0; - ambientColor[1] = 0.0; - ambientColor[2] = 0.0; - ambientColor[3] = 0.0; - - for ( lightIndex = 0; lightIndex < 2; lightIndex++ ) - { - float dir[3] = {0,0,0}; - float half[3] = {0,0,0}; - - if ( light[lightIndex] == NULL || - light[lightIndex]->GetSwitch() == 0 ) - { - lightDiffuseColor[lightIndex][0] = 0.0; - lightDiffuseColor[lightIndex][1] = 0.0; - lightDiffuseColor[lightIndex][2] = 0.0; - lightDiffuseColor[lightIndex][3] = 0.0; - - lightSpecularColor[lightIndex][0] = 0.0; - lightSpecularColor[lightIndex][1] = 0.0; - lightSpecularColor[lightIndex][2] = 0.0; - lightSpecularColor[lightIndex][3] = 0.0; - } - else - { - float lightIntensity = light[lightIndex]->GetIntensity(); - double lightAmbColor[3]; - double lightDiffColor[3]; - double lightSpecColor[3]; - light[lightIndex]->GetAmbientColor( lightAmbColor ); - light[lightIndex]->GetDiffuseColor( lightDiffColor ); - light[lightIndex]->GetSpecularColor( lightSpecColor ); - - double lightPosition[3]; - double lightFocalPoint[3]; - light[lightIndex]->GetTransformedPosition( lightPosition ); - light[lightIndex]->GetTransformedFocalPoint( lightFocalPoint ); - - volumeTransform->TransformPoint( lightPosition, lightPosition ); - volumeTransform->TransformPoint( lightFocalPoint, lightFocalPoint ); - - dir[0] = lightPosition[0] - lightFocalPoint[0]; - dir[1] = lightPosition[1] - lightFocalPoint[1]; - dir[2] = lightPosition[2] - lightFocalPoint[2]; - - vtkMath::Normalize( dir ); - - lightDiffuseColor[lightIndex][0] = lightDiffColor[0]*diffuse - *lightIntensity; - lightDiffuseColor[lightIndex][1] = lightDiffColor[1]*diffuse - *lightIntensity; - lightDiffuseColor[lightIndex][2] = lightDiffColor[2]*diffuse - *lightIntensity; - lightDiffuseColor[lightIndex][3] = 0.0; - - lightSpecularColor[lightIndex][0]= lightSpecColor[0]*specular - *lightIntensity; - lightSpecularColor[lightIndex][1]= lightSpecColor[1]*specular - *lightIntensity; - lightSpecularColor[lightIndex][2]= lightSpecColor[2]*specular - *lightIntensity; - lightSpecularColor[lightIndex][3] = 0.0; - - half[0] = dir[0] - viewDirection[0]; - half[1] = dir[1] - viewDirection[1]; - half[2] = dir[2] - viewDirection[2]; - - vtkMath::Normalize( half ); - - ambientColor[0] += ambient*lightAmbColor[0]; - ambientColor[1] += ambient*lightAmbColor[1]; - ambientColor[2] += ambient*lightAmbColor[2]; - } - - lightDirection[lightIndex][0] = dir[0]; - lightDirection[lightIndex][1] = dir[1]; - lightDirection[lightIndex][2] = dir[2]; - lightDirection[lightIndex][3] = 0.0; - - halfwayVector[lightIndex][0] = half[0]; - halfwayVector[lightIndex][1] = half[1]; - halfwayVector[lightIndex][2] = half[2]; - halfwayVector[lightIndex][3] = 0.0; - } - - volumeTransform->Delete(); - - vtkgl::ProgramLocalParameter4fARB( vtkgl::FRAGMENT_PROGRAM_ARB, 0, - lightDirection[0][0], - lightDirection[0][1], - lightDirection[0][2], - lightDirection[0][3] ); - - vtkgl::ProgramLocalParameter4fARB( vtkgl::FRAGMENT_PROGRAM_ARB, 1, - halfwayVector[0][0], - halfwayVector[0][1], - halfwayVector[0][2], - halfwayVector[0][3] ); - - vtkgl::ProgramLocalParameter4fARB( vtkgl::FRAGMENT_PROGRAM_ARB, 2, - ambient, diffuse, specular, specularPower ); - - vtkgl::ProgramLocalParameter4fARB( vtkgl::FRAGMENT_PROGRAM_ARB, 3, - lightDiffuseColor[0][0], - lightDiffuseColor[0][1], - lightDiffuseColor[0][2], - lightDiffuseColor[0][3] ); - - vtkgl::ProgramLocalParameter4fARB( vtkgl::FRAGMENT_PROGRAM_ARB, 4, - lightSpecularColor[0][0], - lightSpecularColor[0][1], - lightSpecularColor[0][2], - lightSpecularColor[0][3] ); - - vtkgl::ProgramLocalParameter4fARB( vtkgl::FRAGMENT_PROGRAM_ARB, 5, - viewDirection[0], - viewDirection[1], - viewDirection[2], - viewDirection[3] ); - - vtkgl::ProgramLocalParameter4fARB( vtkgl::FRAGMENT_PROGRAM_ARB, 6, - 2.0, -1.0, 0.0, 0.0 ); - - vtkOpenGLCheckErrorMacro("failed after SetupProgramLocalsForShadingFP"); -} - -int vtkOpenGLVolumeTextureMapper3D::IsRenderSupported( - vtkVolumeProperty *property, - vtkRenderer *r) -{ - if ( !this->Initialized ) - { - this->Initialize(r); - } - - // NO_METHOD occurs when required OpenGL extensions are - // not found during initialization - if ( this->RenderMethod == vtkVolumeTextureMapper3D::NO_METHOD ) - { - return 0; - } - - if ( !this->GetInput() ) - { - return 0; - } - - if ( this->GetInput()->GetNumberOfScalarComponents() > 1 && - property->GetIndependentComponents() ) - { - return 0; - } - - return 1; -} - -void vtkOpenGLVolumeTextureMapper3D::Initialize(vtkRenderer *r) -{ - this->Initialized = 1; - vtkOpenGLExtensionManager *extensions=static_cast( - r->GetRenderWindow())->GetExtensionManager(); - - int supports_texture3D=extensions->ExtensionSupported( "GL_VERSION_1_2" ); - if(supports_texture3D) - { - extensions->LoadExtension("GL_VERSION_1_2"); - } - else - { - supports_texture3D=extensions->ExtensionSupported( "GL_EXT_texture3D" ); - if(supports_texture3D) - { - extensions->LoadCorePromotedExtension("GL_EXT_texture3D"); - } - } - - int supports_multitexture=extensions->ExtensionSupported( "GL_VERSION_1_3" ); - if(supports_multitexture) - { - extensions->LoadExtension("GL_VERSION_1_3"); - } - else - { - supports_multitexture= - extensions->ExtensionSupported("GL_ARB_multitexture"); - if(supports_multitexture) - { - extensions->LoadCorePromotedExtension("GL_ARB_multitexture"); - } - } - - this->SupportsCompressedTexture= - extensions->ExtensionSupported("GL_VERSION_1_3")==1; - - if(!this->SupportsCompressedTexture) - { - this->SupportsCompressedTexture= - extensions->ExtensionSupported("GL_ARB_texture_compression")==1; - if(this->SupportsCompressedTexture) - { - extensions->LoadCorePromotedExtension("GL_ARB_texture_compression"); - } - } - - bool brokenMesa=false; - if(extensions->DriverIsMesa()) - { - // Workaround for broken Mesa - if (!extensions->GetIgnoreDriverBugs("Mesa compressed texture bugs")) - { - this->SupportsCompressedTexture=false; - } - - // Workaround Mesa 7.0.4 bug - // glGetIntegerv(vtkgl::MAX_3D_TEXTURE_SIZE,&maxSize) return some - // uninitialized value and a loading a Luminance-alpha 16x16x16 just - // crashes glx. - if ( extensions->DriverVersionIs(7,0,4) - && extensions->DriverGLVersionIs(1,4) ) - { - brokenMesa = true; - } - - // Workaround bug in Mesa 8 and OS Mesa renderers - // tests all pass however in ::Render causes glPopAttrib - // "Invalid enum". - if ( extensions->DriverGLRendererIsOSMesa() - && !extensions->DriverVersionAtLeast(9) - && !extensions->GetIgnoreDriverBugs("Mesa 8 OS Mesa invalid enum") ) - { - brokenMesa = true; - } - } - - this->SupportsNonPowerOfTwoTextures= - extensions->ExtensionSupported("GL_VERSION_2_0") - || extensions->ExtensionSupported("GL_ARB_texture_non_power_of_two"); - - int supports_GL_NV_texture_shader2 = extensions->ExtensionSupported( "GL_NV_texture_shader2" ); - int supports_GL_NV_register_combiners2 = extensions->ExtensionSupported( "GL_NV_register_combiners2" ); - int supports_GL_ATI_fragment_shader = extensions->ExtensionSupported( "GL_ATI_fragment_shader" ); - int supports_GL_ARB_fragment_program = extensions->ExtensionSupported( "GL_ARB_fragment_program" ); - int supports_GL_ARB_vertex_program = extensions->ExtensionSupported( "GL_ARB_vertex_program" ); - int supports_GL_NV_register_combiners = extensions->ExtensionSupported( "GL_NV_register_combiners" ); - - if(supports_GL_NV_texture_shader2) - { - extensions->LoadExtension("GL_NV_texture_shader2" ); - } - - if(supports_GL_NV_register_combiners2) - { - extensions->LoadExtension( "GL_NV_register_combiners2" ); - } - - if(supports_GL_ATI_fragment_shader) - { - extensions->LoadExtension( "GL_ATI_fragment_shader" ); - } - - if(supports_GL_ARB_fragment_program) - { - extensions->LoadExtension( "GL_ARB_fragment_program" ); - } - - if(supports_GL_ARB_vertex_program) - { - extensions->LoadExtension( "GL_ARB_vertex_program" ); - } - - if(supports_GL_NV_register_combiners) - { - extensions->LoadExtension( "GL_NV_register_combiners" ); - } - - int canDoFP = 0; - int canDoNV = 0; - - if ( !brokenMesa && - supports_texture3D && - supports_multitexture && - supports_GL_ARB_fragment_program && - supports_GL_ARB_vertex_program && - vtkgl::TexImage3D && - vtkgl::ActiveTexture && - vtkgl::MultiTexCoord3fv && - vtkgl::GenProgramsARB && - vtkgl::DeleteProgramsARB && - vtkgl::BindProgramARB && - vtkgl::ProgramStringARB && - vtkgl::ProgramLocalParameter4fARB ) - { - canDoFP = 1; - } - - if ( !brokenMesa && - supports_texture3D && - supports_multitexture && - supports_GL_NV_texture_shader2 && - supports_GL_NV_register_combiners2 && - supports_GL_NV_register_combiners && - vtkgl::TexImage3D && - vtkgl::ActiveTexture && - vtkgl::MultiTexCoord3fv && - vtkgl::CombinerParameteriNV && - vtkgl::CombinerStageParameterfvNV && - vtkgl::CombinerInputNV && - vtkgl::CombinerOutputNV && - vtkgl::FinalCombinerInputNV ) - { - canDoNV = 1; - } - - // can't do either - if ( !canDoFP && !canDoNV ) - { - this->RenderMethod = vtkVolumeTextureMapper3D::NO_METHOD; - } - // can only do FragmentProgram - else if ( canDoFP && !canDoNV ) - { - this->RenderMethod = vtkVolumeTextureMapper3D::FRAGMENT_PROGRAM_METHOD; - } - // can only do NVidia method - else if ( !canDoFP && canDoNV ) - { - this->RenderMethod = vtkVolumeTextureMapper3D::NVIDIA_METHOD; - } - // can do both - pick the preferred one - else - { - this->RenderMethod = this->PreferredRenderMethod; - } -} - -// ---------------------------------------------------------------------------- -int vtkOpenGLVolumeTextureMapper3D::IsTextureSizeSupported(int size[3], - int components) -{ - vtkOpenGLClearErrorMacro(); - - GLint maxSize; - glGetIntegerv(vtkgl::MAX_3D_TEXTURE_SIZE,&maxSize); - - if(size[0]>maxSize || size[1]>maxSize || size[2]>maxSize) - { - return 0; - } - - GLuint id1; - glGenTextures(1,&id1); - glBindTexture(vtkgl::TEXTURE_3D,id1); - if(components==1) - { - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,this->InternalLA,size[0], - size[1], size[2], 0, GL_LUMINANCE_ALPHA, - GL_UNSIGNED_BYTE,0); - } - else - { - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,this->InternalRGB,size[0], - size[1], size[2], 0, GL_RGB, - GL_UNSIGNED_BYTE,0); - } - bool result=glGetError()==GL_NO_ERROR; - if(result) // ie. not GL_OUT_OF_MEMORY - { - GLuint id2; - glGenTextures(1,&id2); - glBindTexture(vtkgl::TEXTURE_3D,id2); - if(components==4) - { - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,this->InternalLA,size[0], - size[1], size[2], 0, GL_LUMINANCE_ALPHA, - GL_UNSIGNED_BYTE,0); - } - else - { - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,this->InternalRGB,size[0], - size[1], size[2], 0, GL_RGB, - GL_UNSIGNED_BYTE,0); - } - result=glGetError()==GL_NO_ERROR; - if(result && components==4) // ie. not GL_OUT_OF_MEMORY - { - GLuint id3; - glGenTextures(1,&id3); - glBindTexture(vtkgl::TEXTURE_3D,id3); - vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,this->InternalRGB,size[0], - size[1], size[2], 0, GL_RGB, - GL_UNSIGNED_BYTE,0); - result=glGetError()==GL_NO_ERROR; - glBindTexture(vtkgl::TEXTURE_3D,0); // bind to default texture object. - glDeleteTextures(1,&id3); - } - glBindTexture(vtkgl::TEXTURE_3D,0); // bind to default texture object. - glDeleteTextures(1,&id2); - } - glBindTexture(vtkgl::TEXTURE_3D,0); // bind to default texture object. - glDeleteTextures(1,&id1); - - vtkOpenGLCheckErrorMacro("failed after IsTextureSizeSupported"); - return result; -} - -// ---------------------------------------------------------------------------- -// Print the vtkOpenGLVolumeTextureMapper3D -void vtkOpenGLVolumeTextureMapper3D::PrintSelf(ostream& os, vtkIndent indent) -{ - os << indent << "Initialized " << this->Initialized << endl; - if(this->RenderWindow!=0) - { - vtkOpenGLExtensionManager *extensions= - static_cast(this->RenderWindow) - ->GetExtensionManager(); - - if ( this->Initialized ) - { - os << indent << "Supports GL_VERSION_1_2:" - << extensions->ExtensionSupported( "GL_VERSION_1_2" ) << endl; - os << indent << "Supports GL_EXT_texture3D:" - << extensions->ExtensionSupported( "GL_EXT_texture3D" ) << endl; - os << indent << "Supports GL_VERSION_1_3:" - << extensions->ExtensionSupported( "GL_VERSION_1_3" ) << endl; - os << indent << "Supports GL_ARB_multitexture: " - << extensions->ExtensionSupported( "GL_ARB_multitexture" ) << endl; - os << indent << "Supports GL_NV_texture_shader2: " - << extensions->ExtensionSupported( "GL_NV_texture_shader2" ) << endl; - os << indent << "Supports GL_NV_register_combiners2: " - << extensions->ExtensionSupported( "GL_NV_register_combiners2" ) - << endl; - os << indent << "Supports GL_ATI_fragment_shader: " - << extensions->ExtensionSupported( "GL_ATI_fragment_shader" ) << endl; - os << indent << "Supports GL_ARB_fragment_program: " - << extensions->ExtensionSupported( "GL_ARB_fragment_program" ) - << endl; - os << indent << "Supports GL_ARB_texture_compression: " - << extensions->ExtensionSupported( "GL_ARB_texture_compression" ) - << endl; - os << indent << "Supports GL_VERSION_2_0:" - << extensions->ExtensionSupported( "GL_VERSION_2_0" ) - << endl; - os << indent << "Supports GL_ARB_texture_non_power_of_two:" - << extensions->ExtensionSupported( "GL_ARB_texture_non_power_of_two" ) - << endl; - } - } - - this->Superclass::PrintSelf(os,indent); -} - -#endif // VTK_LEGACY_REMOVE diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLVolumeTextureMapper3D.h paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLVolumeTextureMapper3D.h --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLVolumeTextureMapper3D.h 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkOpenGLVolumeTextureMapper3D.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,163 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkOpenGLVolumeTextureMapper3D.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -/** - * @class vtkOpenGLVolumeTextureMapper3D - * @brief concrete implementation of 3D volume texture mapping - * - * - * vtkOpenGLVolumeTextureMapper3D renders a volume using 3D texture mapping. - * See vtkVolumeTextureMapper3D for full description. - * - * @sa - * vtkVolumeTextureMapper3D vtkVolumeMapper - * @deprecated -*/ - -#ifndef vtkOpenGLVolumeTextureMapper3D_h -#define vtkOpenGLVolumeTextureMapper3D_h - -#include "vtkRenderingVolumeOpenGLModule.h" // For export macro -#include "vtkVolumeTextureMapper3D.h" -#include "vtkOpenGL.h" // GLfloat type is used in some method signatures. - -class vtkRenderWindow; -class vtkVolumeProperty; - -#if !defined(VTK_LEGACY_REMOVE) -class VTKRENDERINGVOLUMEOPENGL_EXPORT vtkOpenGLVolumeTextureMapper3D - : public vtkVolumeTextureMapper3D -{ -public: - vtkTypeMacro(vtkOpenGLVolumeTextureMapper3D,vtkVolumeTextureMapper3D); - void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; - - static vtkOpenGLVolumeTextureMapper3D *New(); - - /** - * Is hardware rendering supported? No if the input data is - * more than one independent component, or if the hardware does - * not support the required extensions - */ - int IsRenderSupported(vtkVolumeProperty *, - vtkRenderer *ren) VTK_OVERRIDE; - - /** - * WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE - * DO NOT USE THIS METHOD OUTSIDE OF THE RENDERING PROCESS - * Render the volume - */ - void Render(vtkRenderer *ren, vtkVolume *vol) VTK_OVERRIDE; - - // Desciption: - // Initialize when we go to render, or go to answer the - // IsRenderSupported question. Don't call unless we have - // a valid OpenGL context! - vtkGetMacro( Initialized, int ); - - /** - * Release any graphics resources that are being consumed by this texture. - * The parameter window could be used to determine which graphic - * resources to release. - */ - void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE; - -protected: - vtkOpenGLVolumeTextureMapper3D(); - ~vtkOpenGLVolumeTextureMapper3D() VTK_OVERRIDE; - - void GetLightInformation(vtkRenderer *ren, - vtkVolume *vol, - GLfloat lightDirection[2][4], - GLfloat lightDiffuseColor[2][4], - GLfloat lightSpecularColor[2][4], - GLfloat halfwayVector[2][4], - GLfloat *ambient ); - - int Initialized; - GLuint Volume1Index; - GLuint Volume2Index; - GLuint Volume3Index; - GLuint ColorLookupIndex; - GLuint AlphaLookupIndex; - vtkRenderWindow *RenderWindow; - - bool SupportsCompressedTexture; - bool SupportsNonPowerOfTwoTextures; - - // Actual internal texture format (uncompressed vs compressed) - // Computed in Render() - int InternalAlpha; // GLint - int InternalLA; // GLint - int InternalRGB; // GLint - int InternalRGBA; // GLint - - void Initialize(vtkRenderer *r); - - virtual void RenderNV(vtkRenderer *ren, vtkVolume *vol); - virtual void RenderFP(vtkRenderer *ren, vtkVolume *vol); - - void RenderOneIndependentNoShadeFP( vtkRenderer *ren, - vtkVolume *vol ); - void RenderOneIndependentShadeFP( vtkRenderer *ren, vtkVolume *vol ); - void RenderTwoDependentNoShadeFP( vtkRenderer *ren, vtkVolume *vol ); - void RenderTwoDependentShadeFP( vtkRenderer *ren, vtkVolume *vol ); - void RenderFourDependentNoShadeFP( vtkRenderer *ren, vtkVolume *vol ); - void RenderFourDependentShadeFP( vtkRenderer *ren, vtkVolume *vol ); - - void RenderOneIndependentNoShadeNV( vtkRenderer *ren, vtkVolume *vol ); - void RenderOneIndependentShadeNV( vtkRenderer *ren, vtkVolume *vol ); - void RenderTwoDependentNoShadeNV( vtkRenderer *ren, vtkVolume *vol ); - void RenderTwoDependentShadeNV( vtkRenderer *ren, vtkVolume *vol ); - void RenderFourDependentNoShadeNV( vtkRenderer *ren, vtkVolume *vol ); - void RenderFourDependentShadeNV( vtkRenderer *ren, vtkVolume *vol ); - - void SetupOneIndependentTextures( vtkRenderer *ren, vtkVolume *vol ); - void SetupTwoDependentTextures( vtkRenderer *ren, vtkVolume *vol ); - void SetupFourDependentTextures( vtkRenderer *ren, vtkVolume *vol ); - - void SetupRegisterCombinersNoShadeNV( vtkRenderer *ren, - vtkVolume *vol, - int components ); - - void SetupRegisterCombinersShadeNV( vtkRenderer *ren, - vtkVolume *vol, - int components ); - - void DeleteTextureIndex( GLuint *index ); - void CreateTextureIndex( GLuint *index ); - - void RenderPolygons( vtkRenderer *ren, - vtkVolume *vol, - int stages[4] ); - - void SetupProgramLocalsForShadingFP( vtkRenderer *ren, vtkVolume *vol ); - - /** - * Check if we can support this texture size for the number of components. - */ - int IsTextureSizeSupported(int size[3], - int components) VTK_OVERRIDE; - - /** - * Common code for setting up interpolation / clamping on 3D textures - */ - void Setup3DTextureParameters( vtkVolumeProperty *property ); - -private: - vtkOpenGLVolumeTextureMapper3D(const vtkOpenGLVolumeTextureMapper3D&) VTK_DELETE_FUNCTION; - void operator=(const vtkOpenGLVolumeTextureMapper3D&) VTK_DELETE_FUNCTION; -}; -#endif // VTK_LEGACY_REMOVE -#endif diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkProjectedAAHexahedraMapper_FS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkProjectedAAHexahedraMapper_FS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkProjectedAAHexahedraMapper_FS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkProjectedAAHexahedraMapper_FS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,300 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_HeaderFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// High quality volume renderer for axis-aligned hexahedra -// Implementation by Stephane Marchesin (stephane.marchesin@gmail.com) -// CEA/DIF - Commissariat a l'Energie Atomique, Centre DAM Ile-De-France -// BP12, F-91297 Arpajon, France. -// -// This file implements the paper -// "High-Quality, Semi-Analytical Volume Rendering for AMR Data", -// Stephane Marchesin and Guillaume Colin de Verdiere, IEEE Vis 2009. - -// inputs of FS -// texcoord0.xyz : position in the brick space [0,1]^3 -// texcoord0.w : cell size -// texcoord1.xyz : position in object space -// texcoord2.xyzw: node data 0,1,2,3 -// texcoord3.xyzw: node data 4,5,6,7 - -uniform sampler3D preintegration_table; -uniform vec3 observer; -uniform float length_max; - -vec4 sample(float sample0, float sample1, float length) -{ - float corrected_length = length * gl_TexCoord[0].w / length_max ; - return texture3D(preintegration_table, - vec3(sample0,sample1,corrected_length)); -} - -void main() -{ - vec3 pos = gl_TexCoord[0].xyz; - vec3 progression; - vec3 dist1,dist2,dist; - vec3 l=vec3(1.0,0.0,0.0); - float length; - float cell_length = gl_TexCoord[0].w; - - progression.xyz = gl_TexCoord[1].xyz - observer.xyz; - progression = normalize(progression); - - dist1.xyz = abs((1.0-pos.xyz)/progression.xyz); - dist2.xyz = abs((pos.xyz)/progression.xyz); - if (progression.x>0.0) - dist.x=dist1.x; - else - dist.x=dist2.x; - if (progression.y>0.0) - dist.y=dist1.y; - else - dist.y=dist2.y; - if (progression.z>0.0) - dist.z=dist1.z; - else - dist.z=dist2.z; - - length = min(dist.x,min(dist.y,dist.z)); - vec3 p1 = pos, p2 = pos + vec3(length) * progression; - - float s0 = gl_TexCoord[2].x; - float s1 = gl_TexCoord[2].y; - float s2 = gl_TexCoord[2].z; - float s3 = gl_TexCoord[2].w; - - float s4 = gl_TexCoord[3].x; - float s5 = gl_TexCoord[3].y; - float s6 = gl_TexCoord[3].z; - float s7 = gl_TexCoord[3].w; - float x0 = p1.x, - x1 = p2.x - p1.x, - y0 = p1.y, - y1 = p2.y - p1.y, - z0 = p1.z, - z1 = p2.z - p1.z; - float a = (s3 - s0 + s1 + s4 + s6 - s2 - s5 - s7) *x1*y1*z1; - float b = (-x0*y1*z1 - x1*y0*z1 - x1*y1*z0 + x1*z1)*s7 - + (x0*y1*z1 + x1*y0*z1 + x1*y1*z0)*s6 - + (y1*z1 - x0*y1*z1 - x1*y0*z1 - x1*y1*z0)*s5 - + (-x1*z1 + x1*y1*z0 - y1*z1 + x0*y1*z1 + x1*y0*z1)*s4 - + (-x1*z1 + x1*y0*z1 + x1*y1*z0 - x1*y1 + x0*y1*z1)*s3 - + (-x1*y0*z1 - x0*y1*z1 + x1*y1 - x1*y1*z0)*s2 - + (x1*y1 + y1*z1 - x1*y1*z0 + x1*z1 - x0*y1*z1 - x1*y0*z1)*s0 - + (x1*y1*z0 - y1*z1 - x1*y1 + x0*y1*z1 + x1*y0*z1)*s1; - float c = (-x0*y0*z1 + x0*z1 + x1*z0 - x1*y0*z0 - x0*y1*z0)*s7 - + (x1*y0*z0 + x0*y1*z0 + x0*y0*z1)*s6 - + (y0*z1 - x0*y1*z0 - x1*y0*z0 + y1*z0 - x0*y0*z1)*s5 - + (x0*y0*z1 + z1 - y0*z1 - y1*z0 - x0*z1 - x1*z0 + x0*y1*z0 + x1*y0*z0)*s4 - + (x1*y0*z0 + x0*y0*z1 + x0*y1*z0 - x1*z0 - x1*y0 - x0*z1 - x0*y1 + x1)*s3 - + (x0*y1 + x1*y0 - x0*y0*z1 - x0*y1*z0 - x1*y0*z0)*s2 - + (-x1*y0 + x0*y1*z0 - y0*z1 - x0*y1 + x0*y0*z1 + y1 + x1*y0*z0 - y1*z0)*s1 - + (-x0*y1*z0 - z1 + x1*y0 - x0*y0*z1 - x1*y0*z0 - y1 + y0*z1 + x1*z0 - + y1*z0 + x0*y1 - x1 + x0*z1)*s0; - float d = (x0*z0 - x0*y0*z0)*s7 + (y0*z0 - x0*y0*z0)*s5 - + (-x0*z0 - y0*z0 + x0*y0*z0 + z0)*s4 + (-x0*z0 + x0 + x0*y0*z0 - x0*y0)*s3 - + (x0*y0 - x0*y0*z0)*s2 + (-y0*z0 - x0*y0 + y0 + x0*y0*z0)*s1 - + (-y0 - z0 - x0*y0*z0 + x0*z0 + y0*z0 - x0 + x0*y0 + 1.0)*s0 - + s6*x0*y0*z0; - float r[4]; - r[0] = 0.0; - r[1] = 0.0; - r[2] = 0.0; - r[3] = 0.0; - int numsteps = 0; - - // at this point P(t) = a.t^3 + b.t^2 + c.t + d - - if ( (abs(a)<=0.00001) && (abs(b)<=0.00001) ) - { - // P(t) is linear - numsteps = 0; - } - else if (abs(a)<=0.00001) - { - // P(t) is quadratic - r[0] = -c/(2.0*b); - - if ((r[0] <= 0.0) || (r[0] >= 1.0)) - { - numsteps = 0; - } - else - { - numsteps = 1; - } - } - else - { - // P(t) is cubic - // small optimization here : we divide delta by 4, - // and simplify r[0]/r[1] by 2 - float delta = b*b - 3.0*a*c; - if (delta < 0.0) - { - numsteps = 0; - } else { - numsteps = 2; - r[0] = (-b - sqrt(delta))/(3.0*a); - r[1] = (-b + sqrt(delta))/(3.0*a); - - if ((r[1] <= 0.0) || (r[1] >= 1.0)) - { - numsteps--; - } - - if ((r[0] <= 0.0) || (r[0] >= 1.0)) - { - numsteps--; - r[0] = r[1]; - } - } - } - -#if 0 - // handle light extrema as well - if (abs(e)>0.00001) - { - // Q(t) is quadratic - if ((-f/(2.0*e) > 0.0) && (-f/(2.0*e) < 1.0)) - { - r[numsteps] = -f/(2.0*e); - numsteps++; - } - } -#endif - vec4 result, val0, val1, val2, val3; - float sample0,sample1,sample2,sample3,sample4; - if (numsteps==0) - { - // single preintegration over [0,1] - - // evaluate the scalar value at the 2 points : - // sample0 at t = 0.0; - // sample1 at t = 1.0; - sample0 = d; - sample1 = d + c + b + a; - - // preintegrate over [0,1.0] -> [sample0,sample1] - val0 = sample(sample0,sample1,length); - - // blend values - result.rgba = val0.rgba; - } - else if (numsteps==1) - { - // double preintegration over [0,r[0]] and [r[0],1.0] - - // evaluate the scalar value at the 3 points : - // sample0 at t = 0.0; - // sample1 at t = r[0]; - // sample2 at t = 1.0; - sample0 = d; - sample1 = d + r[0]* (c + r[0]* (b + r[0]*a)); - sample2 = d + c + b + a; - - // preintegrate over [0,r[0]] -> [sample0,sample1] - val0 = sample(sample0,sample1,r[0]*length); - // preintegrate over [r[0],1] -> [sample1,sample2] - val1 = sample(sample1,sample2,(1.0 - r[0])*length); - - // blend values - result.rgba = val0.rgba + vec4(1.0 - val0.a) * val1.rgba; - } - else if (numsteps==2) - { - // numsteps==2 - // triple preintegration over [0,r[0]], [r[0],r[1]] and [r[1],1.0] - - if (r[1] [sample0,sample1] - val0 = sample(sample0,sample1,r[0]*length); - // preintegrate over [r[0],r[1]] -> [sample1,sample2] - val1 = sample(sample1,sample2,(r[1] - r[0])*length); - // preintegrate over [r[1],1] -> [sample2,sample3] - val2 = sample(sample2,sample3,(1.0 - r[1])*length); - - // blend values - result.rgba = val0.rgba + vec4(1.0 - val0.a) * - (val1.rgba + vec4(1.0 - val1.a) * val2.rgba); - } - else - { - // numsteps==3 - // triple preintegration over [0,r[0]], [r[0],r[1]], [r[1],r[2]] - // and [r[2],1.0] - - if (r[0]>r[1]) - { - float tmp = r[0]; - r[0] = r[1]; - r[1] = tmp; - } - if (r[1]>r[2]) - { - float tmp = r[2]; - r[2] = r[1]; - r[1] = tmp; - } - if (r[0]>r[1]) - { - float tmp = r[0]; - r[0] = r[1]; - r[1] = tmp; - } - - // evaluate the scalar value at the 4 points : - // sample0 at t = 0.0; - // sample1 at t = r[0]; - // sample2 at t = r[1]; - // sample3 at t = 1.0; - sample0 = d; - sample1 = d + r[0]* (c + r[0]* (b + r[0]*a)); - sample2 = d + r[1]* (c + r[1]* (b + r[1]*a)); - sample3 = d + r[2]* (c + r[2]* (b + r[2]*a)); - sample4 = d + c + b + a; - - // preintegrate over [0,r[0]] -> [sample0,sample1] - val0 = sample(sample0,sample1,r[0]*length); - // preintegrate over [r[0],r[1]] -> [sample1,sample2] - val1 = sample(sample1,sample2,(r[1] - r[0])*length); - // preintegrate over [r[1],r[2]] -> [sample2,sample3] - val2 = sample(sample2,sample3,(r[2] - r[1])*length); - // preintegrate over [r[2],1] -> [sample3,sample4] - val3 = sample(sample3,sample4,(1.0 - r[2])*length); - - // blend values - result.rgba = val0.rgba + vec4(1.0 - val0.a) * - (val1.rgba + vec4(1.0 - val1.a) * - (val2.rgba + vec4(1.0 - val2.a) * val3.rgba)); - } - gl_FragColor.rgba = result.rgba; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkProjectedAAHexahedraMapper_GS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkProjectedAAHexahedraMapper_GS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkProjectedAAHexahedraMapper_GS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkProjectedAAHexahedraMapper_GS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,175 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_HeaderFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// High quality volume renderer for axis-aligned hexahedra -// Implementation by Stephane Marchesin (stephane.marchesin@gmail.com) -// CEA/DIF - Commissariat a l'Energie Atomique, Centre DAM Ile-De-France -// BP12, F-91297 Arpajon, France. -// -// This file implements the paper -// "High-Quality, Semi-Analytical Volume Rendering for AMR Data", -// Stephane Marchesin and Guillaume Colin de Verdiere, IEEE Vis 2009. - -#version 120 -#extension GL_EXT_geometry_shader4 : enable - -// inputs of GS -// vertexpos.xyz : cell position (xmin,ymin,zmin) -// texcoord0.xyz : cell position (xmax,ymax,zmax) -// texcoord1.xyzw: node data 0,1,2,3 -// texcoord2.xyzw: ode data 4,5,6,7 - -void draw_cell(vec4 scalars0, vec4 scalars1, vec3 m, vec3 M); - -// ---------------------------------------------------------------------------- -void main() -{ - draw_cell(gl_TexCoordIn[0][1],gl_TexCoordIn[0][2],gl_PositionIn[0].xyz, - gl_TexCoordIn[0][0].xyz); -} - -// ---------------------------------------------------------------------------- -void draw_cell(vec4 scalars0, vec4 scalars1, vec3 m, vec3 M) -{ - // common node data - gl_TexCoord[2].xyzw = scalars0; - gl_TexCoord[3].xyzw = scalars1; - float cs = M.x - m.x; - vec4 p0 = vec4(m.x,m.y,m.z,1.0); - vec4 p1 = vec4(m.x,m.y,M.z,1.0); - vec4 p2 = vec4(m.x,M.y,m.z,1.0); - vec4 p3 = vec4(m.x,M.y,M.z,1.0); - vec4 p4 = vec4(M.x,m.y,m.z,1.0); - vec4 p5 = vec4(M.x,m.y,M.z,1.0); - vec4 p6 = vec4(M.x,M.y,m.z,1.0); - vec4 p7 = vec4(M.x,M.y,M.z,1.0); - vec4 t0 = gl_ModelViewProjectionMatrix * p0; - vec4 t1 = gl_ModelViewProjectionMatrix * p1; - vec4 t2 = gl_ModelViewProjectionMatrix * p2; - vec4 t3 = gl_ModelViewProjectionMatrix * p3; - vec4 t4 = gl_ModelViewProjectionMatrix * p4; - vec4 t5 = gl_ModelViewProjectionMatrix * p5; - vec4 t6 = gl_ModelViewProjectionMatrix * p6; - vec4 t7 = gl_ModelViewProjectionMatrix * p7; - - // face 0 - gl_TexCoord[0] = vec4(1.0,0.0,0.0,cs); - gl_TexCoord[1] = p4; - gl_Position = t4; - EmitVertex(); - gl_TexCoord[0] = vec4(1.0,0.0,1.0,cs); - gl_TexCoord[1] = p5; - gl_Position = t5; - EmitVertex(); - gl_TexCoord[0] = vec4(1.0,1.0,0.0,cs); - gl_TexCoord[1] = p6; - gl_Position = t6; - EmitVertex(); - gl_TexCoord[0] = vec4(1.0,1.0,1.0,cs); - gl_TexCoord[1] = p7; - gl_Position = t7; - EmitVertex(); - EndPrimitive(); - // face 1 - gl_TexCoord[0] = vec4(0.0,1.0,0.0,cs); - gl_TexCoord[1] = p2; - gl_Position = t2; - EmitVertex(); - gl_TexCoord[0] = vec4(1.0,1.0,0.0,cs); - gl_TexCoord[1] = p6; - gl_Position = t6; - EmitVertex(); - gl_TexCoord[0] = vec4(0.0,1.0,1.0,cs); - gl_TexCoord[1] = p3; - gl_Position = t3; - EmitVertex(); - gl_TexCoord[0] = vec4(1.0,1.0,1.0,cs); - gl_TexCoord[1] = p7; - gl_Position = t7; - EmitVertex(); - EndPrimitive(); - // face 2 - gl_TexCoord[0] = vec4(0.0,1.0,1.0,cs); - gl_TexCoord[1] = p3; - gl_Position = t3; - EmitVertex(); - gl_TexCoord[0] = vec4(1.0,1.0,1.0,cs); - gl_TexCoord[1] = p7; - gl_Position = t7; - EmitVertex(); - gl_TexCoord[0] = vec4(0.0,0.0,1.0,cs); - gl_TexCoord[1] = p1; - gl_Position = t1; - EmitVertex(); - gl_TexCoord[0] = vec4(1.0,0.0,1.0,cs); - gl_TexCoord[1] = p5; - gl_Position = t5; - EmitVertex(); - EndPrimitive(); - // face 3 - gl_TexCoord[0] = vec4(0.0,1.0,0.0,cs); - gl_TexCoord[1] = p2; - gl_Position = t2; - EmitVertex(); - gl_TexCoord[0] = vec4(0.0,1.0,1.0,cs); - gl_TexCoord[1] = p3; - gl_Position = t3; - EmitVertex(); - gl_TexCoord[0] = vec4(0.0,0.0,0.0,cs); - gl_TexCoord[1] = p0; - gl_Position = t0; - EmitVertex(); - gl_TexCoord[0] = vec4(0.0,0.0,1.0,cs); - gl_TexCoord[1] = p1; - gl_Position = t1; - EmitVertex(); - EndPrimitive(); - // face 4 - gl_TexCoord[0] = vec4(0.0,0.0,0.0,cs); - gl_TexCoord[1] = p0; - gl_Position = t0; - EmitVertex(); - gl_TexCoord[0] = vec4(0.0,0.0,1.0,cs); - gl_TexCoord[1] = p1; - gl_Position = t1; - EmitVertex(); - gl_TexCoord[0] = vec4(1.0,0.0,0.0,cs); - gl_TexCoord[1] = p4; - gl_Position = t4; - EmitVertex(); - gl_TexCoord[0] = vec4(1.0,0.0,1.0,cs); - gl_TexCoord[1] = p5; - gl_Position = t5; - EmitVertex(); - EndPrimitive(); - // face 5 - gl_TexCoord[0] = vec4(0.0,1.0,0.0,cs); - gl_TexCoord[1] = p2; - gl_Position = t2; - EmitVertex(); - gl_TexCoord[0] = vec4(0.0,0.0,0.0,cs); - gl_TexCoord[1] = p0; - gl_Position = t0; - EmitVertex(); - gl_TexCoord[0] = vec4(1.0,1.0,0.0,cs); - gl_TexCoord[1] = p6; - gl_Position = t6; - EmitVertex(); - gl_TexCoord[0] = vec4(1.0,0.0,0.0,cs); - gl_TexCoord[1] = p4; - gl_Position = t4; - EmitVertex(); - EndPrimitive(); -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkProjectedAAHexahedraMapper_VS.glsl paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkProjectedAAHexahedraMapper_VS.glsl --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkProjectedAAHexahedraMapper_VS.glsl 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkProjectedAAHexahedraMapper_VS.glsl 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGPUVolumeRayCastMapper_HeaderFS.glsl - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - -// High quality volume renderer for axis-aligned hexahedra -// Implementation by Stephane Marchesin (stephane.marchesin@gmail.com) -// CEA/DIF - Commissariat a l'Energie Atomique, Centre DAM Ile-De-France -// BP12, F-91297 Arpajon, France. -// -// This file implements the paper -// "High-Quality, Semi-Analytical Volume Rendering for AMR Data", -// Stephane Marchesin and Guillaume Colin de Verdiere, IEEE Vis 2009. - -// inputs of VS -// vertexpos.xyz : cell position (xmin,ymin,zmin) -// texcoord0.xyz : cell position (xmax,ymax,zmax) -// texcoord1.xyzw: node data 0,1,2,3 -// texcoord2.xyzw: node data 4,5,6,7 - -#version 110 - -void main() -{ - gl_TexCoord[0] = gl_MultiTexCoord0; - gl_TexCoord[1] = gl_MultiTexCoord1; - gl_TexCoord[2] = gl_MultiTexCoord2; - gl_Position = gl_Vertex; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkSmartVolumeMapper.cxx paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkSmartVolumeMapper.cxx --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkSmartVolumeMapper.cxx 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkSmartVolumeMapper.cxx 1970-01-01 00:00:00.000000000 +0000 @@ -1,791 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkFixedPointRayCastImage.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -#include "vtkSmartVolumeMapper.h" - -#include "vtkObjectFactory.h" - -#include "vtkColorTransferFunction.h" -#include "vtkDataArray.h" -#include "vtkFixedPointVolumeRayCastMapper.h" -#include "vtkEventForwarderCommand.h" -#include "vtkImageData.h" -#include "vtkImageResample.h" -#include "vtkOSPRayVolumeInterface.h" -#include "vtkPiecewiseFunction.h" -#include "vtkRenderer.h" -#include "vtkRenderWindow.h" -#include "vtkVolume.h" -#include "vtkVolumeProperty.h" -#include "vtkVolumeTextureMapper3D.h" -#include "vtkSmartPointer.h" -#include - -#include "vtkGPUVolumeRayCastMapper.h" - -vtkStandardNewMacro( vtkSmartVolumeMapper ); - -// ---------------------------------------------------------------------------- -// Constructor -// ---------------------------------------------------------------------------- -vtkSmartVolumeMapper::vtkSmartVolumeMapper() -{ - // Default for Window / Level - no adjustment - this->FinalColorWindow = 1.0; - this->FinalColorLevel = 0.5; - - // Our render mode is undefined at this point - this->CurrentRenderMode = vtkSmartVolumeMapper::UndefinedRenderMode; - - // Nothing is initialized and we assume nothing is supported - this->Initialized = 0; - this->TextureSupported = 0; - this->GPUSupported = 0; - this->RayCastSupported = 0; - this->LowResGPUNecessary = 0; - this->InterpolationMode=VTK_RESLICE_CUBIC; - - // Create all the mappers we might need - this->RayCastMapper = vtkFixedPointVolumeRayCastMapper::New(); - - this->GPUMapper = vtkGPUVolumeRayCastMapper::New(); - this->MaxMemoryInBytes=this->GPUMapper->GetMaxMemoryInBytes(); - this->MaxMemoryFraction=this->GPUMapper->GetMaxMemoryFraction(); - -#if !defined(VTK_LEGACY_REMOVE) - this->TextureMapper = vtkVolumeTextureMapper3D::New(); -#endif // VTK_LEGACY_REMOVE - this->GPULowResMapper = vtkGPUVolumeRayCastMapper::New(); - - // If the render window has a desired update rate of at least 1 frame - // per second or more, we'll consider this interactive - this->InteractiveUpdateRate = 1.0; - - // This is the resample filter that may be used if we need - // a lower resolution version of the input for GPU rendering - this->GPUResampleFilter = vtkImageResample::New(); - - // Turn this on by default - this means that the sample spacing will be - // automatically computed from the spacing of the input data. This is - // also true for the GPU ray cast mapper. - this->RayCastMapper->LockSampleDistanceToInputSpacingOn(); - - // Default to the default mode - which will use the best option that - // is supported by the hardware - this->RequestedRenderMode = vtkSmartVolumeMapper::DefaultRenderMode; - - // Keep track of what blend mode we had when we initialized and - // checked for hardware support - we need to recheck if the blend - // mode changes - this->InitializedBlendMode = -1; - - // Create the forwarding command - vtkEventForwarderCommand *cb = vtkEventForwarderCommand::New(); - cb->SetTarget(this); - - // Now forward the ray caster's events - this->RayCastMapper->AddObserver(vtkCommand::VolumeMapperRenderStartEvent, cb); - this->RayCastMapper->AddObserver(vtkCommand::VolumeMapperRenderEndEvent, cb); - this->RayCastMapper->AddObserver(vtkCommand::VolumeMapperRenderProgressEvent, cb); - this->RayCastMapper->AddObserver(vtkCommand::VolumeMapperComputeGradientsStartEvent, cb); - this->RayCastMapper->AddObserver(vtkCommand::VolumeMapperComputeGradientsEndEvent, cb); - this->RayCastMapper->AddObserver(vtkCommand::VolumeMapperComputeGradientsProgressEvent, cb); - - // And the texture mapper's events -#if !defined(VTK_LEGACY_REMOVE) - this->TextureMapper->AddObserver(vtkCommand::StartEvent, cb); - this->TextureMapper->AddObserver(vtkCommand::EndEvent, cb); - this->TextureMapper->AddObserver(vtkCommand::ProgressEvent, cb); - this->TextureMapper->AddObserver(vtkCommand::VolumeMapperRenderStartEvent, cb); - this->TextureMapper->AddObserver(vtkCommand::VolumeMapperRenderEndEvent, cb); - this->TextureMapper->AddObserver(vtkCommand::VolumeMapperRenderProgressEvent, cb); - this->TextureMapper->AddObserver(vtkCommand::VolumeMapperComputeGradientsStartEvent, cb); - this->TextureMapper->AddObserver(vtkCommand::VolumeMapperComputeGradientsEndEvent, cb); - this->TextureMapper->AddObserver(vtkCommand::VolumeMapperComputeGradientsProgressEvent, cb); -#endif // VTK_LEGACY_REMOVE - - // And the GPU mapper's events - // Commented out because too many events are being forwwarded - // put back in after that is fixed - /*** - this->GPUMapper->AddObserver(vtkCommand::VolumeMapperRenderStartEvent, cb); - this->GPUMapper->AddObserver(vtkCommand::VolumeMapperRenderEndEvent, cb); - this->GPUMapper->AddObserver(vtkCommand::VolumeMapperRenderProgressEvent, cb); - ***/ - - // And the low res GPU mapper's events - // Commented out because too many events are being forwwarded - // put back in after that is fixed - /*** - this->GPULowResMapper->AddObserver(vtkCommand::VolumeMapperRenderStartEvent, cb); - this->GPULowResMapper->AddObserver(vtkCommand::VolumeMapperRenderEndEvent, cb); - this->GPULowResMapper->AddObserver(vtkCommand::VolumeMapperRenderProgressEvent, cb); - ***/ - - cb->Delete(); - - this->OSPRayMapper = NULL; -} - -// ---------------------------------------------------------------------------- -// Destructor -// ---------------------------------------------------------------------------- -vtkSmartVolumeMapper::~vtkSmartVolumeMapper() -{ - if (this->RayCastMapper) - { - this->RayCastMapper->Delete(); - this->RayCastMapper = 0; - } - if (this->GPUMapper) - { - this->GPUMapper->Delete(); - this->GPUMapper = 0; - } - if (this->GPULowResMapper) - { - this->GPULowResMapper->Delete(); - this->GPULowResMapper = 0; - } -#if !defined(VTK_LEGACY_REMOVE) - if (this->TextureMapper) - { - this->TextureMapper->Delete(); - this->TextureMapper = 0; - } -#endif // VTK_LEGACY_REMOVE - if (this->GPUResampleFilter) - { - this->GPUResampleFilter->Delete(); - this->GPUResampleFilter = 0; - } - if (this->OSPRayMapper) - { - this->OSPRayMapper->Delete(); - this->OSPRayMapper = 0; - } -} - - -// ---------------------------------------------------------------------------- -// The Render method will determine the render mode and then render using the -// appropriate mapper. If the render mode is invalid (the user explicitly -// chooses something that is not supported) the render will silently fail. -// ---------------------------------------------------------------------------- -void vtkSmartVolumeMapper::Render( vtkRenderer *ren, vtkVolume *vol ) -{ - // Compute the render mode based on the requested - // render mode, available hardware, and render window's - // desired update rate - this->ComputeRenderMode(ren,vol); - - vtkGPUVolumeRayCastMapper *usedMapper=0; - - switch ( this->CurrentRenderMode ) - { - case vtkSmartVolumeMapper::RayCastRenderMode: - this->RayCastMapper->Render(ren,vol); - break; -#if !defined(VTK_LEGACY_REMOVE) - case vtkSmartVolumeMapper::TextureRenderMode: - this->TextureMapper->Render(ren,vol); - break; -#endif // VTK_LEGACY_REMOVE - case vtkSmartVolumeMapper::GPURenderMode: - if(this->LowResGPUNecessary) - { - usedMapper=this->GPULowResMapper; - } - else - { - usedMapper=this->GPUMapper; - } - usedMapper->SetAutoAdjustSampleDistances( - ren->GetRenderWindow()->GetDesiredUpdateRate()>= - this->InteractiveUpdateRate); - usedMapper->Render(ren, vol); - break; - case vtkSmartVolumeMapper::OSPRayRenderMode: - if (!this->OSPRayMapper) - { - this->OSPRayMapper = vtkOSPRayVolumeInterface::New(); - } - this->OSPRayMapper->Render(ren, vol); - break; - case vtkSmartVolumeMapper::InvalidRenderMode: - // Silently fail - a render mode that is not - // valid was selected so we will render nothing - break; - default: - vtkErrorMacro("Internal Error!"); - break; - } -} - - -// ---------------------------------------------------------------------------- -// Initialize the rende -// We need to determine whether the texture mapper or GPU mapper are supported -// First we need to know what input scalar field we are working with to find -// out how many components it has. If it has more than one, and we are considering -// them to be independent components, then we know that neither the texture mapper -// nor the GPU mapper will work. -// ---------------------------------------------------------------------------- -void vtkSmartVolumeMapper::Initialize(vtkRenderer *ren, vtkVolume *vol) -{ - vtkImageData *input = this->GetInput(); - if (!input) - { - this->Initialized = 0; - return; - } - - int usingCellColors=0; - // In order to perform a GetScalars we need to make sure that the - // input is up to date -// input->UpdateInformation(); -// input->SetUpdateExtentToWholeExtent(); -// input->Update(); - - vtkDataArray *scalars = this->GetScalars(input, this->ScalarMode, - this->ArrayAccessMode, - this->ArrayId, this->ArrayName, - usingCellColors); - - if ( scalars->GetNumberOfComponents() != 1 ) - { - if ( vol->GetProperty()->GetIndependentComponents() ) - { - this->TextureSupported = 0; - this->GPUSupported = 0; - if ( usingCellColors ) - { - this->RayCastSupported = 0; - } - else - { - this->RayCastSupported = 1; - } - this->Initialized = 1; - this->SupportStatusCheckTime.Modified(); - return; - } - } - - if ( usingCellColors ) - { - this->RayCastSupported = 0; - } - else - { - this->RayCastSupported = 1; - } - - // Make the window current because we need the OpenGL context - vtkRenderWindow *win=ren->GetRenderWindow(); - win->MakeCurrent(); - -#if !defined(VTK_LEGACY_REMOVE) - // Have to give the texture mapper its input or else it won't report that - // it is supported. Texture mapper only supported for composite blend - if ( this->GetBlendMode() != vtkVolumeMapper::COMPOSITE_BLEND ) - { - this->TextureSupported = 0; - } - else - { - this->ConnectMapperInput(this->TextureMapper); - this->TextureSupported = this->TextureMapper->IsRenderSupported( - vol->GetProperty(),ren); - } -#endif // VTK_LEGACY_REMOVE - - this->GPUSupported = this->GPUMapper->IsRenderSupported(win, - vol->GetProperty()); - this->Initialized = 1; - this->InitializedBlendMode = this->GetBlendMode(); - this->SupportStatusCheckTime.Modified(); -} - -// ---------------------------------------------------------------------------- -// Compute the render mode based on what hardware is available, what the user -// requested as a render mode, and the desired update rate of the render window -// ---------------------------------------------------------------------------- -void vtkSmartVolumeMapper::ComputeRenderMode(vtkRenderer *ren, vtkVolume *vol) -{ - // If we are already initialized, and the volume, - // volume's input, and volume's property have not - // changed since last time we computed the render mode, - // then we don't need to initialize again - if (!( this->Initialized && - this->SupportStatusCheckTime.GetMTime() > this->GetMTime() && - this->SupportStatusCheckTime.GetMTime() > vol->GetProperty()->GetMTime() && - this->SupportStatusCheckTime.GetMTime() > this->GetInput()->GetMTime() && - this->InitializedBlendMode == this->GetBlendMode() ) ) - { - this->Initialize(ren,vol); - } - - - // Use this as the initial state to simplify the code below - this->CurrentRenderMode = vtkSmartVolumeMapper::InvalidRenderMode; - - if ( !this->GetInput() ) - { - return; - } - - double scale[3]; - double spacing[3]; - this->GetInput()->GetSpacing(spacing); - - vtkRenderWindow *win=ren->GetRenderWindow(); - - switch ( this->RequestedRenderMode ) - { - // Requested ray casting - OK as long as it is supported - // This ray caster is a software mapper so it is supported as - // we aren't attempting to render cell scalars - case vtkSmartVolumeMapper::RayCastRenderMode: - if ( this->RayCastSupported ) - { - this->CurrentRenderMode = vtkSmartVolumeMapper::RayCastRenderMode; - } - break; - -#if !defined(VTK_LEGACY_REMOVE) - // Requested 3D texture - OK as long as it is supported - case vtkSmartVolumeMapper::TextureRenderMode: - if ( this->TextureSupported ) - { - this->CurrentRenderMode = vtkSmartVolumeMapper::TextureRenderMode; - } - break; -#endif // VTK_LEGACY_REMOVE - - // Requested GPU - OK as long as it is supported - case vtkSmartVolumeMapper::GPURenderMode: - if ( this->GPUSupported ) - { - this->CurrentRenderMode = vtkSmartVolumeMapper::GPURenderMode; - } - break; - - // Requested OSPRay - case vtkSmartVolumeMapper::OSPRayRenderMode: - this->CurrentRenderMode = this->RequestedRenderMode; - break; - - // Requested default mode - select GPU if supported, otherwise - // select texture mapping for interactive rendering (if supported) - // and ray casting for still rendering. Make determination of - // still vs. interactive based on whether the desired update rate - // is at or above this->InteractiveUpdateRate - case vtkSmartVolumeMapper::DefaultRenderMode: - // Go with GPU rendering if it is supported - if ( this->GPUSupported ) - { - this->CurrentRenderMode = vtkSmartVolumeMapper::GPURenderMode; - } -#if !defined(VTK_LEGACY_REMOVE) - // If this is interactive, try for texture mapping - else if ( win->GetDesiredUpdateRate() >= this->InteractiveUpdateRate && - this->TextureSupported ) - { - this->CurrentRenderMode = vtkSmartVolumeMapper::TextureRenderMode; - } -#endif // VTK_LEGACY_REMOVE - else if ( this->RayCastSupported ) - { - this->CurrentRenderMode = vtkSmartVolumeMapper::RayCastRenderMode; - } - break; - -#if !defined(VTK_LEGACY_REMOVE) - // Requested the texture mapping / ray cast combo. If texture - // mapping is supported and this is an interactive render, then - // use it. Otherwise use ray casting. - case vtkSmartVolumeMapper::RayCastAndTextureRenderMode: - if (this->TextureSupported && - (win->GetDesiredUpdateRate() >= this->InteractiveUpdateRate)) - { - this->CurrentRenderMode = vtkSmartVolumeMapper::TextureRenderMode; - } - else if ( this->RayCastSupported ) - { - this->CurrentRenderMode = vtkSmartVolumeMapper::RayCastRenderMode; - } - break; -#endif // VTK_LEGACY_REMOVE - - // This should never happen since the SetRequestedRenderMode - // protects against invalid states - default: - vtkErrorMacro("Internal Error: Invalid RequestedRenderMode"); - break; - } - - switch ( this->CurrentRenderMode ) - { - // We are rendering with the vtkFixedPointVolumeRayCastMapper - case vtkSmartVolumeMapper::RayCastRenderMode: - if (this->ArrayAccessMode == VTK_GET_ARRAY_BY_NAME) - { - this->RayCastMapper->SelectScalarArray(this->ArrayName); - } - else if (this->ArrayAccessMode == VTK_GET_ARRAY_BY_ID) - { - this->RayCastMapper->SelectScalarArray(this->ArrayId); - } - this->RayCastMapper->SetScalarMode(this->GetScalarMode()); - this->ConnectMapperInput(this->RayCastMapper); - this->RayCastMapper->SetClippingPlanes(this->GetClippingPlanes()); - this->RayCastMapper->SetCropping(this->GetCropping()); - this->RayCastMapper->SetCroppingRegionPlanes( - this->GetCroppingRegionPlanes()); - this->RayCastMapper->SetCroppingRegionFlags( - this->GetCroppingRegionFlags()); - this->RayCastMapper->SetBlendMode( this->GetBlendMode() ); - this->RayCastMapper->SetFinalColorWindow(this->FinalColorWindow); - this->RayCastMapper->SetFinalColorLevel(this->FinalColorLevel); - break; - -#if !defined(VTK_LEGACY_REMOVE) - // We are rendering with the vtkVolumeTextureMapper3D - case vtkSmartVolumeMapper::TextureRenderMode: - if (this->ArrayAccessMode == VTK_GET_ARRAY_BY_NAME) - { - this->TextureMapper->SelectScalarArray(this->ArrayName); - } - else if (this->ArrayAccessMode == VTK_GET_ARRAY_BY_ID) - { - this->TextureMapper->SelectScalarArray(this->ArrayId); - } - this->TextureMapper->SetScalarMode(this->GetScalarMode()); - this->ConnectMapperInput(this->TextureMapper); - if ( this->RequestedRenderMode == vtkSmartVolumeMapper::DefaultRenderMode || - this->RequestedRenderMode == vtkSmartVolumeMapper::RayCastAndTextureRenderMode ) - { - this->TextureMapper->SetSampleDistance( static_cast((spacing[0] + spacing[1] + spacing[2] ) / 2.0) ); - } - else - { - this->TextureMapper->SetSampleDistance( static_cast((spacing[0] + spacing[1] + spacing[2] ) / 6.0) ); - } - this->TextureMapper->SetClippingPlanes(this->GetClippingPlanes()); - this->TextureMapper->SetCropping(this->GetCropping()); - this->TextureMapper->SetCroppingRegionPlanes( - this->GetCroppingRegionPlanes()); - this->TextureMapper->SetCroppingRegionFlags( - this->GetCroppingRegionFlags()); - // TextureMapper does not support FinalColor Window/Level. - break; -#endif // VTK_LEGACY_REMOVE - - // We are rendering with the vtkGPUVolumeRayCastMapper - case vtkSmartVolumeMapper::GPURenderMode: - if (this->ArrayAccessMode == VTK_GET_ARRAY_BY_NAME) - { - this->GPUMapper->SelectScalarArray(this->ArrayName); - } - else if (this->ArrayAccessMode == VTK_GET_ARRAY_BY_ID) - { - this->GPUMapper->SelectScalarArray(this->ArrayId); - } - this->GPUMapper->SetScalarMode(this->GetScalarMode()); - this->GPUMapper->SetMaxMemoryInBytes(this->MaxMemoryInBytes); - this->GPUMapper->SetMaxMemoryFraction(this->MaxMemoryFraction); - this->GPUMapper->SetSampleDistance( - static_cast((spacing[0] + spacing[1] + spacing[2] ) / 6.0) ); - this->ConnectMapperInput(this->GPUMapper); - this->GPUMapper->SetClippingPlanes(this->GetClippingPlanes()); - this->GPUMapper->SetCropping(this->GetCropping()); - this->GPUMapper->SetCroppingRegionPlanes( - this->GetCroppingRegionPlanes()); - this->GPUMapper->SetCroppingRegionFlags( - this->GetCroppingRegionFlags()); - this->GPUMapper->SetBlendMode( this->GetBlendMode() ); - this->GPUMapper->SetFinalColorWindow(this->FinalColorWindow); - this->GPUMapper->SetFinalColorLevel(this->FinalColorLevel); - - // Make the window current because we need the OpenGL context - win->MakeCurrent(); - - // Now we need to find out if we need to use a low resolution - // version of the mapper for interactive rendering. This is true - // if the GPU mapper cannot hand the size of the volume. - this->GPUMapper->GetReductionRatio(scale); - - // if any of the scale factors is not 1.0, then we do need - // to use the low res mapper for interactive rendering - if ( scale[0] != 1.0 || scale[1] != 1.0 || scale[2] != 1.0 ) - { - this->LowResGPUNecessary = 1; - this->ConnectFilterInput(this->GPUResampleFilter); - this->GPUResampleFilter->SetInterpolationMode(this->InterpolationMode); - this->GPUResampleFilter->SetAxisMagnificationFactor( 0, scale[0]/2.0 ); - this->GPUResampleFilter->SetAxisMagnificationFactor( 1, scale[1]/2.0 ); - this->GPUResampleFilter->SetAxisMagnificationFactor( 2, scale[2]/2.0 ); - - this->GPULowResMapper->SetMaxMemoryInBytes(this->MaxMemoryInBytes); - this->GPULowResMapper->SetMaxMemoryFraction(this->MaxMemoryFraction); - this->GPULowResMapper->SetSampleDistance( - static_cast((spacing[0] + spacing[1] + spacing[2] ) / 6.0) ); - - this->GPULowResMapper->SetInputConnection( - this->GPUResampleFilter->GetOutputPort()); - this->GPULowResMapper->SetClippingPlanes(this->GetClippingPlanes()); - this->GPULowResMapper->SetCropping(this->GetCropping()); - this->GPULowResMapper->SetCroppingRegionPlanes( - this->GetCroppingRegionPlanes()); - this->GPULowResMapper->SetCroppingRegionFlags( - this->GetCroppingRegionFlags()); - this->GPULowResMapper->SetBlendMode( this->GetBlendMode() ); - this->GPULowResMapper->SetFinalColorWindow(this->FinalColorWindow); - this->GPULowResMapper->SetFinalColorLevel(this->FinalColorLevel); - } - else - { - this->LowResGPUNecessary = 0; - } - - break; - - // render with OSPRay - case vtkSmartVolumeMapper::OSPRayRenderMode: - break; - - // The user selected a RequestedRenderMode that is - // not supported. In this case the mapper will just - // silently fail. - case vtkSmartVolumeMapper::InvalidRenderMode: - break; - - // This should never happen since we don't set the CurrentRenderMode - // to anything other than the above handled options - default: - vtkErrorMacro("Internal Error: Invalid CurrentRenderMode"); - break; - } -} - -// ---------------------------------------------------------------------------- -void vtkSmartVolumeMapper::ConnectMapperInput(vtkVolumeMapper *m) -{ - assert("pre: m_exists" && m!=0); - - vtkImageData *input2=m->GetInput(); - bool needShallowCopy=false; - if(input2==0) - { - // make sure we not create a shallow copy each time to avoid - // performance penalty. - input2=vtkImageData::New(); - m->SetInputDataObject(input2); - input2->Delete(); - needShallowCopy=true; - } - else - { - needShallowCopy=input2->GetMTime()GetInput()->GetMTime(); - } - if(needShallowCopy) - { - input2->ShallowCopy(this->GetInput()); - } -} - -// ---------------------------------------------------------------------------- -void vtkSmartVolumeMapper::ConnectFilterInput(vtkImageResample *f) -{ - assert("pre: f_exists" && f!=0); - - vtkImageData *input2=static_cast(f->GetInput()); - bool needShallowCopy=false; - if(input2==0) - { - // make sure we not create a shallow copy each time to avoid - // performance penalty. - input2=vtkImageData::New(); - f->SetInputDataObject(input2); - input2->Delete(); - needShallowCopy=true; - } - else - { - needShallowCopy=input2->GetMTime()GetInput()->GetMTime(); - } - if(needShallowCopy) - { - input2->ShallowCopy(this->GetInput()); - } -} - -// ---------------------------------------------------------------------------- -void vtkSmartVolumeMapper::SetRequestedRenderMode(int mode) -{ - // If we aren't actually changing it, just return - if ( this->RequestedRenderMode == mode ) - { - return; - } - - // Make sure it is a valid mode - if ( mode < vtkSmartVolumeMapper::DefaultRenderMode || - mode >= vtkSmartVolumeMapper::UndefinedRenderMode ) - { - vtkErrorMacro("Invalid Render Mode."); - return; - } - - this->RequestedRenderMode = mode; - this->Modified(); - -} - -// ---------------------------------------------------------------------------- -void vtkSmartVolumeMapper::SetRequestedRenderModeToDefault() -{ - this->SetRequestedRenderMode(vtkSmartVolumeMapper::DefaultRenderMode); -} - -// ---------------------------------------------------------------------------- -void vtkSmartVolumeMapper::SetRequestedRenderModeToGPU() -{ - this->SetRequestedRenderMode(vtkSmartVolumeMapper::GPURenderMode); -} - -// ---------------------------------------------------------------------------- -void vtkSmartVolumeMapper::SetRequestedRenderModeToOSPRay() -{ - this->SetRequestedRenderMode(vtkSmartVolumeMapper::OSPRayRenderMode); -} - -// ---------------------------------------------------------------------------- -#if !defined(VTK_LEGACY_REMOVE) -void vtkSmartVolumeMapper::SetRequestedRenderModeToTexture() -{ - this->SetRequestedRenderMode(vtkSmartVolumeMapper::TextureRenderMode); - VTK_LEGACY_BODY(vtkSmartVolumeMapper::SetRequestedRenderModeToTexture,"VTK 7.0"); -} -#endif // VTK_LEGACY_REMOVE - -// ---------------------------------------------------------------------------- -#if !defined(VTK_LEGACY_REMOVE) -void vtkSmartVolumeMapper::SetRequestedRenderModeToRayCastAndTexture() -{ - this->SetRequestedRenderMode( - vtkSmartVolumeMapper::RayCastAndTextureRenderMode ); - VTK_LEGACY_BODY(vtkSmartVolumeMapper::SetRequestedRenderModeToRayCastAndTexture,"VTK 7.0"); -} -#endif // VTK_LEGACY_REMOVE - -// ---------------------------------------------------------------------------- -void vtkSmartVolumeMapper::SetRequestedRenderModeToRayCast() -{ - this->SetRequestedRenderMode(vtkSmartVolumeMapper::RayCastRenderMode); -} - -// ---------------------------------------------------------------------------- -void vtkSmartVolumeMapper::ReleaseGraphicsResources(vtkWindow *w) -{ - this->RayCastMapper->ReleaseGraphicsResources(w); -#if !defined(VTK_LEGACY_REMOVE) - this->TextureMapper->ReleaseGraphicsResources(w); -#endif // VTK_LEGACY_REMOVE - this->GPUMapper->ReleaseGraphicsResources(w); - this->GPULowResMapper->ReleaseGraphicsResources(w); - - this->Initialized = 0; - this->TextureSupported = 0; - this->GPUSupported = 0; - this->RayCastSupported = 0; -} - -// ---------------------------------------------------------------------------- -void vtkSmartVolumeMapper::SetInterpolationModeToNearestNeighbor() -{ - this->SetInterpolationMode(VTK_RESLICE_NEAREST); -} - -// ---------------------------------------------------------------------------- -void vtkSmartVolumeMapper::SetInterpolationModeToLinear() -{ - this->SetInterpolationMode(VTK_RESLICE_LINEAR); -} - -// ---------------------------------------------------------------------------- -void vtkSmartVolumeMapper::SetInterpolationModeToCubic() -{ - this->SetInterpolationMode(VTK_RESLICE_CUBIC); -} - -// ---------------------------------------------------------------------------- -void vtkSmartVolumeMapper::CreateCanonicalView( - vtkRenderer *ren, - vtkVolume *volume, - vtkVolume *volume2, - vtkImageData *image, - int blend_mode, - double viewDirection[3], - double viewUp[3]) -{ - this->ComputeRenderMode(ren, volume); - - if ( this->CurrentRenderMode == vtkSmartVolumeMapper::GPURenderMode ) - { - vtkVolumeProperty *savedProperty = volume->GetProperty(); - volume->SetProperty(volume2->GetProperty()); - volume->GetProperty()->Modified(); - volume->GetProperty()->GetScalarOpacity()->Modified(); - volume->GetProperty()->GetRGBTransferFunction()->Modified(); - this->GPUMapper->CreateCanonicalView(ren, volume, - image, blend_mode, - viewDirection, viewUp); - volume->SetProperty(savedProperty); - volume->GetProperty()->Modified(); - volume->GetProperty()->GetScalarOpacity()->Modified(); - volume->GetProperty()->GetRGBTransferFunction()->Modified(); - } - else if ( this->RayCastSupported ) - { - this->RayCastMapper->CreateCanonicalView(volume2, - image, blend_mode, - viewDirection, viewUp); - } - else - { - vtkErrorMacro("Could not create image - no available mapper"); - } -} - -// ---------------------------------------------------------------------------- -int vtkSmartVolumeMapper::GetLastUsedRenderMode() -{ - return this->CurrentRenderMode; -} - -// ---------------------------------------------------------------------------- -void vtkSmartVolumeMapper::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os,indent); - - os << "FinalColorWindow: " << this->FinalColorWindow << endl; - os << "FinalColorLevel: " << this->FinalColorLevel << endl; - os << "RequestedRenderMode: " << this->RequestedRenderMode << endl; - os << "InteractiveUpdateRate: " << this->InteractiveUpdateRate << endl; - os << "InterpolationMode: " << this->InterpolationMode << endl; - os << "MaxMemoryInBytes:" << this->MaxMemoryInBytes << endl; - os << "MaxMemoryFraction:" << this->MaxMemoryFraction << endl; -} diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkSmartVolumeMapper.h paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkSmartVolumeMapper.h --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkSmartVolumeMapper.h 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkSmartVolumeMapper.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,410 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkSmartVolumeMapper.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -/** - * @class vtkSmartVolumeMapper - * @brief Adaptive volume mapper - * - * vtkSmartVolumeMapper is a volume mapper that will delegate to a specific - * volume mapper based on rendering parameters and available hardware. Use the - * SetRequestedRenderMode() method to control the behavior of the selection. - * The following options are available: - * - * @par vtkSmartVolumeMapper::DefaultRenderMode: - * Allow the vtkSmartVolumeMapper to select the best mapper based on - * rendering parameters and hardware support. If GPU ray casting is - * supported, this mapper will be used for all rendering. If not, - * then if 3D texture mapping is supported, it will be used for - * interactive rendering and the vtkFixedPointRayCastMapper will be - * used for still rendering. If 3D texture mapping is not supported, - * then the vtkFixedPointRayCastMapper will be used exclusively. - * This is the default requested render mode, and is generally the - * best option. When you use this option, your volume will always - * be rendered, but the method used to render it may vary based - * on parameters and platform. - * - * @par vtkSmartVolumeMapper::RayCastAndTextureRenderMode: - * Use the vtkVolumeTextureMapper3D for interactive rendering, - * and the vtkFixedPointVolumeRayCastMapper for still renders. - * If 3D texture mapping is not supported, then the ray - * caster will be used exclusively. When you use this option your - * volume will always be rendered, but the method used for - * interactive rendering will vary based on parameters and - * platform. The decision on whether a particular render is - * interactive or still is based on the adjustable parameter - * InteractiveUpdateRate. If the DesiredUpdateRate found in the - * vtkRenderWindow that initiated the Render is at or above - * the InteractiveUpdateRate value, then the render is considered - * interactive, otherwise it is considered a still render. - * - * @par vtkSmartVolumeMapper::RayCastRenderMode: - * Use the vtkFixedPointVolumeRayCastMapper for both interactive and - * still rendering. When you use this option your volume will always - * be rendered with the vtkFixedPointVolumeRayCastMapper. - * - * @par vtkSmartVolumeMapper::TextureRenderMode: - * Use the vtkVolumeTextureMapper3D, if supported, for both - * interactive and still rendering. If 3D texture mapping is not - * supported (either by the hardware, or due to the rendering - * parameters) then no image will be rendered. Use this option only - * if you have already checked for support based on the current - * hardware, number of scalar components, and rendering parameters - * in the vtkVolumeProperty. Also note that the - * vtkVolumeTextureMapper3D does not support window / level - * operations on the final image, so FinalColorWindow must be at - * the default value of 1.0 and FinalColorLevel must be at the - * default value of 0.5. - * - * @par vtkSmartVolumeMapper::GPURenderMode: - * Use the vtkGPUVolumeRayCastMapper, if supported, for both - * interactive and still rendering. If the GPU ray caster is not - * supported (due to hardware limitations or rendering parameters) - * then no image will be rendered. Use this option only if you have - * already checked for supported based on the current hardware, - * number of scalar components, and rendering parameters in the - * vtkVolumeProperty. - * - * @par vtkSmartVolumeMapper::GPURenderMode: - * You can adjust the contrast and brightness in the rendered image using the - * FinalColorWindow and FinalColorLevel ivars. By default the - * FinalColorWindow is set to 1.0, and the FinalColorLevel is set to 0.5, - * which applies no correction to the computed image. To apply the window / - * level operation to the computer image color, first a Scale and Bias - * value are computed: - *
- *  scale = 1.0 / this->FinalColorWindow
- *  bias  = 0.5 - this->FinalColorLevel / this->FinalColorWindow
- *  
- * To compute a new color (R', G', B', A') from an existing color (R,G,B,A) - * for a pixel, the following equation is used: - *
- *  R' = R*scale + bias*A
- *  G' = G*scale + bias*A
- *  B' = B*scale + bias*A
- *  A' = A
- *  
- * Note that bias is multiplied by the alpha component before adding because - * the red, green, and blue component of the color are already pre-multiplied - * by alpha. Also note that the window / level operation leaves the alpha - * component unchanged - it only adjusts the RGB values. -*/ - -#ifndef vtkSmartVolumeMapper_h -#define vtkSmartVolumeMapper_h - -#include "vtkRenderingVolumeOpenGLModule.h" // For export macro -#include "vtkVolumeMapper.h" -#include "vtkImageReslice.h" // for VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC - -class vtkFixedPointVolumeRayCastMapper; -class vtkGPUVolumeRayCastMapper; -class vtkImageResample; -class vtkOSPRayVolumeInterface; -class vtkRenderWindow; -class vtkVolume; -class vtkVolumeProperty; -#if !defined(VTK_LEGACY_REMOVE) -class vtkVolumeTextureMapper3D; -#endif // VTK_LEGACY_REMOVE - -class VTKRENDERINGVOLUMEOPENGL_EXPORT vtkSmartVolumeMapper : public vtkVolumeMapper -{ -public: - static vtkSmartVolumeMapper *New(); - vtkTypeMacro(vtkSmartVolumeMapper,vtkVolumeMapper); - void PrintSelf( ostream& os, vtkIndent indent ) VTK_OVERRIDE; - - //@{ - /** - * Set the final color window. This controls the contrast of - * the image. The default value is 1.0. The Window can be - * negative (this causes a "negative" effect on the image) - * Although Window can be set to 0.0, any value less than - * 0.00001 and greater than or equal to 0.0 will be set to - * 0.00001, and any value greater than -0.00001 but less - * than or equal to 0.0 will be set to -0.00001. - * Initial value is 1.0. - */ - vtkSetMacro( FinalColorWindow, float ); - //@} - - //@{ - /** - * Get the final color window. Initial value is 1.0. - */ - vtkGetMacro( FinalColorWindow, float ); - //@} - - //@{ - /** - * Set the final color level. The level controls the - * brightness of the image. The final color window will - * be centered at the final color level, and together - * represent a linear remapping of color values. The - * default value for the level is 0.5. - */ - vtkSetMacro( FinalColorLevel, float ); - //@} - - //@{ - /** - * Get the final color level. - */ - vtkGetMacro( FinalColorLevel, float ); - //@} - -// The possible values for the default and current render mode ivars - enum - { - DefaultRenderMode=0, - RayCastAndTextureRenderMode, - RayCastRenderMode, - TextureRenderMode, - GPURenderMode, - OSPRayRenderMode, - UndefinedRenderMode, - InvalidRenderMode - }; - - /** - * Set the requested render mode. The default is - * vtkSmartVolumeMapper::DefaultRenderMode. - */ - void SetRequestedRenderMode(int mode); - - /** - * Set the requested render mode to vtkSmartVolumeMapper::DefaultRenderMode. - * This is the best option for an application that must adapt to different - * data types, hardware, and rendering parameters. - */ - void SetRequestedRenderModeToDefault(); - - /** - * Set the requested render mode to vtkSmartVolumeMapper::GPURenderMode. - * This option will use hardware accelerated rendering exclusively. This is a - * good option if you know there is hardware acceleration. - */ - void SetRequestedRenderModeToGPU(); - - /** - * Set the requested render mode to - * vtkSmartVolumeMapper::TextureRenderMode. - */ -#if !defined(VTK_LEGACY_REMOVE) - void SetRequestedRenderModeToTexture(); -#endif // VTK_LEGACY_REMOVE - - /** - * Set the requested render mode to - * vtkSmartVolumeMapper::RayCastAndTextureRenderMode. - * This is a good option if you want to avoid using advanced OpenGL - * functionality, but would still like to used 3D texture mapping, if - * available, for interactive rendering. - */ -#if !defined(VTK_LEGACY_REMOVE) - void SetRequestedRenderModeToRayCastAndTexture(); -#endif // VTK_LEGACY_REMOVE - - /** - * Set the requested render mode to vtkSmartVolumeMapper::RayCastRenderMode. - * This option will use software rendering exclusively. This is a good option - * if you know there is no hardware acceleration. - */ - void SetRequestedRenderModeToRayCast(); - - /** - * Set the requested render mode to vtkSmartVolumeMapper::OSPRayRenderMode. - * This option will use intel OSPRay to do software rendering exclusively. - */ - void SetRequestedRenderModeToOSPRay(); - - //@{ - /** - * Get the requested render mode. - */ - vtkGetMacro( RequestedRenderMode, int ); - //@} - - //@{ - /** - * Set the rate at or above this render will be considered interactive. - * If the DesiredUpdateRate of the vtkRenderWindow that caused the Render - * falls at or above this rate, the render is considered interactive and - * the mapper may be adjusted (depending on the render mode). - * Initial value is 1.0. - */ - vtkSetClampMacro( InteractiveUpdateRate, double, 1.0e-10, 1.0e10 ); - //@} - - //@{ - /** - * Get the update rate at or above which this is considered an - * interactive render. - * Initial value is 1.0. - */ - vtkGetMacro( InteractiveUpdateRate, double ); - //@} - - /** - * This will return the render mode used during the previous call to - * Render(). - */ - int GetLastUsedRenderMode(); - - //@{ - /** - * Value passed to the GPU mapper. Ignored by other mappers. - * Maximum size of the 3D texture in GPU memory. - * Will default to the size computed from the graphics - * card. Can be adjusted by the user. - * Useful if the automatic detection is defective or missing. - */ - vtkSetMacro( MaxMemoryInBytes, vtkIdType ); - vtkGetMacro( MaxMemoryInBytes, vtkIdType ); - //@} - - //@{ - /** - * Value passed to the GPU mapper. Ignored by other mappers. - * Maximum fraction of the MaxMemoryInBytes that should - * be used to hold the texture. Valid values are 0.1 to - * 1.0. - */ - vtkSetClampMacro( MaxMemoryFraction, float, 0.1f, 1.0f ); - vtkGetMacro( MaxMemoryFraction, float ); - //@} - - //@{ - /** - * Set interpolation mode for downsampling (lowres GPU) - * (initial value: cubic). - */ - vtkSetClampMacro(InterpolationMode, int, - VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC); - vtkGetMacro(InterpolationMode, int); - void SetInterpolationModeToNearestNeighbor(); - void SetInterpolationModeToLinear(); - void SetInterpolationModeToCubic(); - //@} - - /** - * This method can be used to render a representative view of the input data - * into the supplied image given the supplied blending mode, view direction, - * and view up vector. - */ - void CreateCanonicalView( vtkRenderer *ren, - vtkVolume *volume, - vtkVolume *volume2, - vtkImageData *image, - int blend_mode, - double viewDirection[3], - double viewUp[3] ); - - /** - * WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE - * Initialize rendering for this volume. - */ - void Render( vtkRenderer *, vtkVolume * ) VTK_OVERRIDE; - - /** - * WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE - * Release any graphics resources that are being consumed by this mapper. - * The parameter window could be used to determine which graphic - * resources to release. - */ - void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE; - -protected: - vtkSmartVolumeMapper(); - ~vtkSmartVolumeMapper() VTK_OVERRIDE; - - /** - * Connect input of the vtkSmartVolumeMapper to the input of the - * internal volume mapper by doing a shallow to avoid memory leaks. - * \pre m_exists: m!=0 - */ - void ConnectMapperInput(vtkVolumeMapper *m); - - /** - * Connect input of the vtkSmartVolumeMapper to the input of the - * internal resample filter by doing a shallow to avoid memory leaks. - * \pre m_exists: f!=0 - */ - void ConnectFilterInput(vtkImageResample *f); - - // Window / level ivars - float FinalColorWindow; - float FinalColorLevel; - - // GPU mapper-specific memory ivars. - vtkIdType MaxMemoryInBytes; - float MaxMemoryFraction; - - // Used for downsampling. - int InterpolationMode; - - // The requested render mode is used to compute the current render mode. Note - // that the current render mode can be invalid if the requested mode is not - // supported. - int RequestedRenderMode; - int CurrentRenderMode; - - // Initialization variables. - int Initialized; - vtkTimeStamp SupportStatusCheckTime; - int TextureSupported; - int GPUSupported; - int RayCastSupported; - int LowResGPUNecessary; - - // This is the resample filter that may be used if we need to - // create a low resolution version of the volume for GPU rendering - vtkImageResample *GPUResampleFilter; - - // If the DesiredUpdateRate of the vtkRenderWindow causing the Render is at - // or above this value, the render is considered interactive. Otherwise it is - // considered still. - double InteractiveUpdateRate; - - // The initialize method. Called from ComputeRenderMode whenever something - // relevant has changed. - void Initialize(vtkRenderer *ren, - vtkVolume *vol); - - // The method that computes the render mode from the requested render mode - // based on the support status for each render method. - void ComputeRenderMode(vtkRenderer *ren, - vtkVolume *vol); - - // The three potential mappers - vtkGPUVolumeRayCastMapper *GPULowResMapper; - vtkGPUVolumeRayCastMapper *GPUMapper; - vtkFixedPointVolumeRayCastMapper *RayCastMapper; -#if !defined(VTK_LEGACY_REMOVE) - vtkVolumeTextureMapper3D *TextureMapper; -#endif // VTK_LEGACY_REMOVE - - // We need to keep track of the blend mode we had when we initialized - // because we need to reinitialize (and recheck hardware support) if - // it changes - int InitializedBlendMode; - -private: - vtkSmartVolumeMapper(const vtkSmartVolumeMapper&) VTK_DELETE_FUNCTION; - void operator=(const vtkSmartVolumeMapper&) VTK_DELETE_FUNCTION; - - vtkOSPRayVolumeInterface *OSPRayMapper; -}; - -#endif diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_FourDependentNoShadeFP.asm paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_FourDependentNoShadeFP.asm --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_FourDependentNoShadeFP.asm 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_FourDependentNoShadeFP.asm 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -!!ARBfp1.0 - -# This is the fragment program for four -# component dependent data with no shading - -# We need some temporary variables -TEMP temp1, temp2; -TEMP finalColor, finalOpacity; - -# We are going to use the first -# texture coordinate -ATTRIB tex0 = fragment.texcoord[0]; - -# This is our output color -OUTPUT out = result.color; - -# Look up the color in the first volume -TEX finalColor, tex0, texture[0], 3D; - -# Look up the fourth scalar / gradient -# magnitude in the second volume -TEX temp1, tex0, texture[1], 3D; - -# Swizzle this to use (a,r) as texture -# coordinates for color, and (g,b) for -# opacity -SWZ temp2, temp1, a, r, 1, 1; - -# Use the (a,r) coordinate to look up a -# final opacity in the fourth texture -# (this is a 2D texture) -TEX finalOpacity, temp2, texture[3], 2D; - -# Combine these into the result -MOV out, finalColor; -MOV out.w, finalOpacity.w; -END diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_FourDependentShadeFP.asm paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_FourDependentShadeFP.asm --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_FourDependentShadeFP.asm 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_FourDependentShadeFP.asm 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -!!ARBfp1.0 - -# This is the fragment program for two -# component dependent data with shading - -# We need some temporary variables -TEMP index1, index2, normal, finalColor; -TEMP temp1, temp2, temp3; -TEMP sampleColor, sampleOpacity; -TEMP ndotl, ndoth, ndotv; -TEMP lightInfo, lightResult; - -# We are going to use the first -# texture coordinate -ATTRIB tex0 = fragment.texcoord[0]; - -# This is the lighting information -PARAM lightDirection = program.local[0]; -PARAM halfwayVector = program.local[1]; -PARAM coefficient = program.local[2]; -PARAM lightDiffColor = program.local[3]; -PARAM lightSpecColor = program.local[4]; -PARAM viewVector = program.local[5]; -PARAM constants = program.local[6]; - -# This is our output color -OUTPUT out = result.color; - -# Look up color in the first volume -TEX sampleColor, tex0, texture[0], 3D; - -# Look up the fourth scalar value / gradient -# magnitude in the second volume -TEX temp1, tex0, texture[1], 3D; - -# Look up the gradient direction -# in the third volume -TEX temp2, tex0, texture[2], 3D; - -# This normal is stored 0 to 1, change to -1 to 1 -# by multiplying by 2.0 then adding -1.0. -MAD normal, temp2, constants.x, constants.y; - -# Swizzle this to use (a,r) as texture -# coordinates for opacity -SWZ index1, temp1, a, r, 1, 1; - -# Use this coordinate to look up a -# final opacity in the fourth texture -TEX sampleOpacity, index1, texture[3], 2D; - -# Take the dot product of the light -# direction and the normal -DP3 ndotl, normal, lightDirection; - -# Take the dot product of the halfway -# vector and the normal -DP3 ndoth, normal, halfwayVector; - -DP3 ndotv, normal, viewVector; - -# flip if necessary for two sided lighting -MUL temp3, ndotl, constants.y; -CMP ndotl, ndotv, ndotl, temp3; -MUL temp3, ndoth, constants.y; -CMP ndoth, ndotv, ndoth, temp3; - -# put the pieces together for a LIT operation -MOV lightInfo.x, ndotl.x; -MOV lightInfo.y, ndoth.x; -MOV lightInfo.w, coefficient.w; - -# compute the lighting -LIT lightResult, lightInfo; - -# This is the ambient contribution -MUL finalColor, coefficient.x, sampleColor; - -# This is the diffuse contribution -MUL temp3, lightDiffColor, sampleColor; -MUL temp3, temp3, lightResult.y; -ADD finalColor, finalColor, temp3; - -# This is th specular contribution -MUL temp3, lightSpecColor, lightResult.z; - -# Add specular into result so far, and replace -# with the original alpha. -ADD out, finalColor, temp3; -MOV out.w, sampleOpacity.w; - -END diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_OneComponentNoShadeFP.asm paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_OneComponentNoShadeFP.asm --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_OneComponentNoShadeFP.asm 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_OneComponentNoShadeFP.asm 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -!!ARBfp1.0 - -# This is the fragment program for one -# component data with no shading - -# We need some temporary variables -TEMP temp1, temp2, temp3; - -# We are going to use the first -# texture coordinate -ATTRIB tex0 = fragment.texcoord[0]; - -# This is our output color -OUTPUT out = result.color; - -# Look up the scalar value / gradient -# magnitude in the first volume -TEX temp1, tex0, texture[0], 3D; - -# Swizzle this to use (a,r) as texture -# coordinates -SWZ temp2, temp1, a, r, 1, 1; - -# Use this coordinate to look up a -# final color in the second texture -# (this is a 2D texture) -TEX temp3, temp2, texture[1], 2D; - -# That's our result and we are done -MOV out, temp3; -END diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_OneComponentShadeFP.asm paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_OneComponentShadeFP.asm --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_OneComponentShadeFP.asm 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_OneComponentShadeFP.asm 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ -!!ARBfp1.0 - -# This is the fragment program for one -# component data with shading - -# We need some temporary variables -TEMP index, normal, finalColor; -TEMP temp1, temp2, temp3; -TEMP sampleColor; -TEMP ndotl, ndoth, ndotv; -TEMP lightInfo, lightResult; - -# We are going to use the first -# texture coordinate -ATTRIB tex0 = fragment.texcoord[0]; - -# This is the lighting information -PARAM lightDirection = program.local[0]; -PARAM halfwayVector = program.local[1]; -PARAM coefficient = program.local[2]; -PARAM lightDiffColor = program.local[3]; -PARAM lightSpecColor = program.local[4]; -PARAM viewVector = program.local[5]; -PARAM constants = program.local[6]; - -# This is our output color -OUTPUT out = result.color; - -# Look up the scalar value / gradient -# magnitude in the first volume -TEX temp1, tex0, texture[0], 3D; - -# Look up the gradient direction -# in the third volume -TEX temp2, tex0, texture[2], 3D; - -# This normal is stored 0 to 1, change to -1 to 1 -# by multiplying by 2.0 then adding -1.0. -MAD normal, temp2, constants.x, constants.y; - -# Swizzle this to use (a,r) as texture -# coordinates -SWZ index, temp1, a, r, 1, 1; - -# Use this coordinate to look up a -# final color in the third texture -# (this is a 2D texture) -TEX sampleColor, index, texture[1], 2D; - -# Take the dot product of the light -# direction and the normal -DP3 ndotl, normal, lightDirection; - -# Take the dot product of the halfway -# vector and the normal -DP3 ndoth, normal, halfwayVector; - -DP3 ndotv, normal, viewVector; - -# flip if necessary for two sided lighting -MUL temp3, ndotl, constants.y; -CMP ndotl, ndotv, ndotl, temp3; -MUL temp3, ndoth, constants.y; -CMP ndoth, ndotv, ndoth, temp3; - -# put the pieces together for a LIT operation -MOV lightInfo.x, ndotl.x; -MOV lightInfo.y, ndoth.x; -MOV lightInfo.w, coefficient.w; - -# compute the lighting -LIT lightResult, lightInfo; - -# This is the ambient contribution -MUL finalColor, coefficient.x, sampleColor; - -# This is the diffuse contribution -MUL temp3, lightDiffColor, sampleColor; -MUL temp3, temp3, lightResult.y; -ADD finalColor, finalColor, temp3; - -# This is th specular contribution -MUL temp3, lightSpecColor, lightResult.z; - -# Add specular into result so far, and replace -# with the original alpha. -ADD out, finalColor, temp3; -MOV out.w, sampleColor.w; - -END diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_TwoDependentNoShadeFP.asm paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_TwoDependentNoShadeFP.asm --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_TwoDependentNoShadeFP.asm 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_TwoDependentNoShadeFP.asm 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -!!ARBfp1.0 - -# This is the fragment program for two -# component dependent data with no shading - -# We need some temporary variables -TEMP temp1, temp2, temp3; -TEMP finalColor, finalOpacity; - -# We are going to use the first -# texture coordinate -ATTRIB tex0 = fragment.texcoord[0]; - -# This is our output color -OUTPUT out = result.color; - -# Look up the scalar values / gradient -# magnitude in the first volume -TEX temp1, tex0, texture[0], 3D; - -# Swizzle this to use (a,r) as texture -# coordinates for color, and (g,b) for -# opacity -SWZ temp2, temp1, a, r, 1, 1; -SWZ temp3, temp1, g, b, 1, 1; - -# Use the (a,r) coordinate to look up a -# final color in the second texture -# (this is a 2D texture) -TEX finalColor, temp2, texture[1], 2D; - -# Use the (g,b) coordinate to look up a -# final opacity in the fourth texture -# (this is a 2D texture) -TEX finalOpacity, temp3, texture[3], 2D; - -# Combine these into the result -MOV out, finalColor; -MOV out.w, finalOpacity.w; -END diff -Nru paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_TwoDependentShadeFP.asm paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_TwoDependentShadeFP.asm --- paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_TwoDependentShadeFP.asm 2017-08-18 13:39:19.000000000 +0000 +++ paraview-5.4.1+dfsg4/VTK/Rendering/VolumeOpenGL/vtkVolumeTextureMapper3D_TwoDependentShadeFP.asm 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -!!ARBfp1.0 - -# This is the fragment program for two -# component dependent data with shading - -# We need some temporary variables -TEMP index1, index2, normal, finalColor; -TEMP temp1, temp2, temp3; -TEMP sampleColor, sampleOpacity; -TEMP ndotl, ndoth, ndotv; -TEMP lightInfo, lightResult; - -# We are going to use the first -# texture coordinate -ATTRIB tex0 = fragment.texcoord[0]; - -# This is the lighting information -PARAM lightDirection = program.local[0]; -PARAM halfwayVector = program.local[1]; -PARAM coefficient = program.local[2]; -PARAM lightDiffColor = program.local[3]; -PARAM lightSpecColor = program.local[4]; -PARAM viewVector = program.local[5]; -PARAM constants = program.local[6]; - -# This is our output color -OUTPUT out = result.color; - -# Look up the scalar values / gradient -# magnitude in the first volume -TEX temp1, tex0, texture[0], 3D; - -# Look up the gradient direction -# in the third volume -TEX temp2, tex0, texture[2], 3D; - -# This normal is stored 0 to 1, change to -1 to 1 -# by multiplying by 2.0 then adding -1.0. -MAD normal, temp2, constants.x, constants.y; - -# Swizzle this to use (a,r) as texture -# coordinates for color, and (g,b) for -# opacity -SWZ index1, temp1, a, r, 1, 1; -SWZ index2, temp1, g, b, 1, 1; - -# Use this coordinate to look up a -# final color in the second texture -# (this is a 2D texture) and the final -# opacity in the fourth texture. -TEX sampleColor, index1, texture[1], 2D; -TEX sampleOpacity, index2, texture[3], 2D; - -# Take the dot product of the light -# direction and the normal -DP3 ndotl, normal, lightDirection; - -# Take the dot product of the halfway -# vector and the normal -DP3 ndoth, normal, halfwayVector; - -DP3 ndotv, normal, viewVector; - -# flip if necessary for two sided lighting -MUL temp3, ndotl, constants.y; -CMP ndotl, ndotv, ndotl, temp3; -MUL temp3, ndoth, constants.y; -CMP ndoth, ndotv, ndoth, temp3; - -# put the pieces together for a LIT operation -MOV lightInfo.x, ndotl.x; -MOV lightInfo.y, ndoth.x; -MOV lightInfo.w, coefficient.w; - -# compute the lighting -LIT lightResult, lightInfo; - -# This is the ambient contribution -MUL finalColor, coefficient.x, sampleColor; - -# This is the diffuse contribution -MUL temp3, lightDiffColor, sampleColor; -MUL temp3, temp3, lightResult.y; -ADD finalColor, finalColor, temp3; - -# This is th specular contribution -MUL temp3, lightSpecColor, lightResult.z; - -# Add specular into result so far, and replace -# with the original alpha. -ADD out, finalColor, temp3; -MOV out.w, sampleOpacity.w; - -END