summaryrefslogtreecommitdiff
path: root/shaders
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2020-05-15 11:19:00 -0700
committerIan Romanick <ian.d.romanick@intel.com>2020-05-15 11:35:45 -0700
commit0c76a1c39e174bba9348167e5877d542f2c8ea33 (patch)
tree301a67a37aba93e4847b332dd44bcc9d7ae9d53d /shaders
parent9a8d5bb123cc84b9e5ac87e16b7c16d5e286f1ec (diff)
shaders: Import shaders from pts/paraview-1.0.3
In addition to removing duplicate shaders from each application, shaders that were the same across applications were removed. All of the shaders from the Wavelet Contour test were the same as the shaders from the Many Spheres test. I also removed trivial shaders. Each test had several shaders where the vertex shader was just 'gl_Position = mvp * gl_Vertex' and a fragment shader that copied inputs to outputs (possibly with a conditional discard). These kinds of shaders are already well represented in shader-db, IMHO.
Diffstat (limited to 'shaders')
-rw-r--r--shaders/pts/paraview-1.0.3/many-spheres/15.shader_test260
-rw-r--r--shaders/pts/paraview-1.0.3/many-spheres/6.shader_test297
-rw-r--r--shaders/pts/paraview-1.0.3/many-spheres/9.shader_test862
-rw-r--r--shaders/pts/paraview-1.0.3/wavelet-volume/6.shader_test627
-rw-r--r--shaders/pts/paraview-1.0.3/wavelet-volume/9.shader_test240
5 files changed, 2286 insertions, 0 deletions
diff --git a/shaders/pts/paraview-1.0.3/many-spheres/15.shader_test b/shaders/pts/paraview-1.0.3/many-spheres/15.shader_test
new file mode 100644
index 0000000..69b741d
--- /dev/null
+++ b/shaders/pts/paraview-1.0.3/many-spheres/15.shader_test
@@ -0,0 +1,260 @@
+[require]
+GLSL >= 1.50
+
+[vertex shader]
+#version 150
+#ifdef GL_ES
+#if __VERSION__ == 300
+#define attribute in
+#define varying out
+#endif // 300
+#else // GL_ES
+#define highp
+#define mediump
+#define lowp
+#if __VERSION__ == 150
+#define attribute in
+#define varying out
+#endif
+#endif // GL_ES
+
+
+/*=========================================================================
+
+ Program: Visualization Toolkit
+ Module: vtkPolyDataVS.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.
+
+=========================================================================*/
+
+attribute vec4 vertexMC;
+
+// frag position in VC
+varying vec4 vertexVCVSOutput;
+
+// optional normal declaration
+//VTK::Normal::Dec
+
+// extra lighting parameters
+//VTK::Light::Dec
+
+// Texture coordinates
+//VTK::TCoord::Dec
+
+// material property values
+//VTK::Color::Dec
+
+// clipping plane vars
+//VTK::Clip::Dec
+
+// camera and actor matrix values
+uniform mat4 MCDCMatrix;
+uniform mat4 MCVCMatrix;
+
+// Apple Bug
+//VTK::PrimID::Dec
+
+// Value raster
+//VTK::ValuePass::Dec
+
+void main()
+{
+ //VTK::Color::Impl
+
+ //VTK::Normal::Impl
+
+ //VTK::TCoord::Impl
+
+ //VTK::Clip::Impl
+
+ //VTK::PrimID::Impl
+
+ vertexVCVSOutput = MCVCMatrix * vertexMC;
+ gl_Position = MCDCMatrix * vertexMC;
+
+
+ //VTK::ValuePass::Impl
+
+ //VTK::Light::Impl
+}
+
+
+[fragment shader]
+#version 150
+#ifdef GL_ES
+#if __VERSION__ == 300
+#define varying in
+#ifdef GL_FRAGMENT_PRECISION_HIGH
+precision highp float;
+precision highp sampler2D;
+precision highp sampler3D;
+#else
+precision mediump float;
+precision mediump sampler2D;
+precision mediump sampler3D;
+#endif
+#define texelFetchBuffer texelFetch
+#define texture1D texture
+#define texture2D texture
+#define texture3D texture
+#endif // 300
+#if __VERSION__ == 100
+#extension GL_OES_standard_derivatives : enable
+#ifdef GL_FRAGMENT_PRECISION_HIGH
+precision highp float;
+#else
+precision mediump float;
+#endif
+#endif // 100
+#else // GL_ES
+#define highp
+#define mediump
+#define lowp
+#if __VERSION__ == 150
+#define varying in
+#define texelFetchBuffer texelFetch
+#define texture1D texture
+#define texture2D texture
+#define texture3D texture
+#endif
+#if __VERSION__ == 120
+#extension GL_EXT_gpu_shader4 : require
+#endif
+#endif // GL_ES
+
+
+/*=========================================================================
+
+ Program: Visualization Toolkit
+ Module: vtkPolyDataFS.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.
+
+=========================================================================*/
+// Template for the polydata mappers fragment shader
+
+uniform int PrimitiveIDOffset;
+
+// VC position of this fragment
+varying vec4 vertexVCVSOutput;
+
+// optional color passed in from the vertex shader, vertexColor
+uniform float opacityUniform; // the fragment opacity
+uniform vec3 ambientColorUniform; // intensity weighted color
+uniform vec3 diffuseColorUniform; // intensity weighted color
+uniform vec3 specularColorUniform; // intensity weighted color
+uniform float specularPowerUniform;
+
+
+// optional surface normal declaration
+uniform int cameraParallel;
+
+// extra lighting parameters
+//VTK::Light::Dec
+
+// Texture coordinates
+//VTK::TCoord::Dec
+
+// picking support
+//VTK::Picking::Dec
+
+// Depth Peeling Support
+//VTK::DepthPeeling::Dec
+
+// clipping plane vars
+//VTK::Clip::Dec
+
+// the output of this shader
+out vec4 fragOutput0;
+
+
+// Apple Bug
+//VTK::PrimID::Dec
+
+// handle coincident offsets
+uniform float coffset;
+
+// Value raster
+//VTK::ValuePass::Dec
+
+void main()
+{
+ // VC position of this fragment. This should not branch/return/discard.
+ vec4 vertexVC = vertexVCVSOutput;
+
+ // Place any calls that require uniform flow (e.g. dFdx) here.
+ vec3 fdx = vec3(dFdx(vertexVC.x),dFdx(vertexVC.y),dFdx(vertexVC.z));
+ vec3 fdy = vec3(dFdy(vertexVC.x),dFdy(vertexVC.y),dFdy(vertexVC.z));
+ //VTK::UniformFlow::Impl
+
+
+ // Set gl_FragDepth here (gl_FragCoord.z by default)
+ gl_FragDepth = gl_FragCoord.z + 0.000016*coffset;
+
+
+ // Early depth peeling abort:
+ //VTK::DepthPeeling::PreColor
+
+ // Apple Bug
+ //VTK::PrimID::Impl
+
+ //VTK::Clip::Impl
+
+ //VTK::ValuePass::Impl
+
+ vec3 ambientColor;
+ vec3 diffuseColor;
+ float opacity;
+ vec3 specularColor;
+ float specularPower;
+ ambientColor = ambientColorUniform;
+ diffuseColor = diffuseColorUniform;
+ opacity = opacityUniform;
+ specularColor = specularColorUniform;
+ specularPower = specularPowerUniform;
+
+
+ // Generate the normal if we are not passed in one
+ fdx = normalize(fdx);
+ fdy = normalize(fdy);
+ vec3 normalVCVSOutput = normalize(cross(fdx,fdy));
+ if (cameraParallel == 1 && normalVCVSOutput.z < 0.0) { normalVCVSOutput = -1.0*normalVCVSOutput; }
+ if (cameraParallel == 0 && dot(normalVCVSOutput,vertexVC.xyz) > 0.0) { normalVCVSOutput = -1.0*normalVCVSOutput; }
+
+ float df = max(0.0,normalVCVSOutput.z);
+ float sf = pow(df, specularPower);
+ vec3 diffuse = df * diffuseColor;
+ vec3 specular = sf * specularColor;
+ fragOutput0 = vec4(ambientColor + diffuse + specular, opacity);
+ //VTK::Light::Impl
+
+
+ //VTK::TCoord::Impl
+
+ if (fragOutput0.a <= 0.0)
+ {
+ discard;
+ }
+
+ //VTK::DepthPeeling::Impl
+
+ //VTK::Picking::Impl
+
+ // handle coincident offsets
+ //VTK::Coincident::Impl
+}
+
+
diff --git a/shaders/pts/paraview-1.0.3/many-spheres/6.shader_test b/shaders/pts/paraview-1.0.3/many-spheres/6.shader_test
new file mode 100644
index 0000000..ab8c7ae
--- /dev/null
+++ b/shaders/pts/paraview-1.0.3/many-spheres/6.shader_test
@@ -0,0 +1,297 @@
+[require]
+GLSL >= 1.50
+
+[vertex shader]
+#version 150
+#ifdef GL_ES
+#if __VERSION__ == 300
+#define attribute in
+#define varying out
+#endif // 300
+#else // GL_ES
+#define highp
+#define mediump
+#define lowp
+#if __VERSION__ == 150
+#define attribute in
+#define varying out
+#endif
+#endif // GL_ES
+
+
+/*=========================================================================
+
+ Program: Visualization Toolkit
+ Module: vtkPolyDataVS.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.
+
+=========================================================================*/
+
+attribute vec4 vertexMC;
+
+// frag position in VC
+varying vec4 vertexVCVSOutput;
+
+// optional normal declaration
+attribute vec3 normalMC;
+uniform mat3 normalMatrix;
+varying vec3 normalVCVSOutput;
+
+// extra lighting parameters
+//VTK::Light::Dec
+
+// Texture coordinates
+attribute vec2 tcoordMC;
+varying vec2 tcoordVCVSOutput;
+
+// material property values
+//VTK::Color::Dec
+
+// clipping plane vars
+//VTK::Clip::Dec
+
+// camera and actor matrix values
+uniform mat4 MCDCMatrix;
+uniform mat4 MCVCMatrix;
+
+// Apple Bug
+//VTK::PrimID::Dec
+
+// Value raster
+//VTK::ValuePass::Dec
+
+void main()
+{
+ //VTK::Color::Impl
+
+ normalVCVSOutput = normalMatrix * normalMC;
+
+ tcoordVCVSOutput = tcoordMC;
+
+ //VTK::Clip::Impl
+
+ //VTK::PrimID::Impl
+
+ vertexVCVSOutput = MCVCMatrix * vertexMC;
+ gl_Position = MCDCMatrix * vertexMC;
+
+
+ //VTK::ValuePass::Impl
+
+ //VTK::Light::Impl
+}
+
+
+[fragment shader]
+#version 150
+#ifdef GL_ES
+#if __VERSION__ == 300
+#define varying in
+#ifdef GL_FRAGMENT_PRECISION_HIGH
+precision highp float;
+precision highp sampler2D;
+precision highp sampler3D;
+#else
+precision mediump float;
+precision mediump sampler2D;
+precision mediump sampler3D;
+#endif
+#define texelFetchBuffer texelFetch
+#define texture1D texture
+#define texture2D texture
+#define texture3D texture
+#endif // 300
+#if __VERSION__ == 100
+#extension GL_OES_standard_derivatives : enable
+#ifdef GL_FRAGMENT_PRECISION_HIGH
+precision highp float;
+#else
+precision mediump float;
+#endif
+#endif // 100
+#else // GL_ES
+#define highp
+#define mediump
+#define lowp
+#if __VERSION__ == 150
+#define varying in
+#define texelFetchBuffer texelFetch
+#define texture1D texture
+#define texture2D texture
+#define texture3D texture
+#endif
+#if __VERSION__ == 120
+#extension GL_EXT_gpu_shader4 : require
+#endif
+#endif // GL_ES
+
+
+/*=========================================================================
+
+ Program: Visualization Toolkit
+ Module: vtkPolyDataFS.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.
+
+=========================================================================*/
+// Template for the polydata mappers fragment shader
+
+uniform int PrimitiveIDOffset;
+
+// VC position of this fragment
+varying vec4 vertexVCVSOutput;
+
+// optional color passed in from the vertex shader, vertexColor
+uniform bool OverridesColor;
+uniform float opacityUniform; // the fragment opacity
+uniform vec3 ambientColorUniform; // intensity weighted color
+uniform vec3 diffuseColorUniform; // intensity weighted color
+uniform vec3 specularColorUniform; // intensity weighted color
+uniform float specularPowerUniform;
+
+
+// optional surface normal declaration
+varying vec3 normalVCVSOutput;
+
+// extra lighting parameters
+uniform vec3 lightColor0;
+ uniform vec3 lightDirectionVC0; // normalized
+uniform vec3 lightColor1;
+ uniform vec3 lightDirectionVC1; // normalized
+uniform vec3 lightColor2;
+ uniform vec3 lightDirectionVC2; // normalized
+uniform vec3 lightColor3;
+ uniform vec3 lightDirectionVC3; // normalized
+uniform vec3 lightColor4;
+ uniform vec3 lightDirectionVC4; // normalized
+
+
+// Texture coordinates
+varying vec2 tcoordVCVSOutput;
+uniform sampler2D texture_0;
+
+
+// picking support
+//VTK::Picking::Dec
+
+// Depth Peeling Support
+//VTK::DepthPeeling::Dec
+
+// clipping plane vars
+//VTK::Clip::Dec
+
+// the output of this shader
+out vec4 fragOutput0;
+
+
+// Apple Bug
+//VTK::PrimID::Dec
+
+// handle coincident offsets
+uniform float coffset;
+
+// Value raster
+//VTK::ValuePass::Dec
+
+void main()
+{
+ // VC position of this fragment. This should not branch/return/discard.
+ vec4 vertexVC = vertexVCVSOutput;
+
+ // Place any calls that require uniform flow (e.g. dFdx) here.
+ //VTK::UniformFlow::Impl
+
+ // Set gl_FragDepth here (gl_FragCoord.z by default)
+ gl_FragDepth = gl_FragCoord.z + 0.000016*coffset;
+
+
+ // Early depth peeling abort:
+ //VTK::DepthPeeling::PreColor
+
+ // Apple Bug
+ //VTK::PrimID::Impl
+
+ //VTK::Clip::Impl
+
+ //VTK::ValuePass::Impl
+
+ vec3 ambientColor;
+ vec3 diffuseColor;
+ float opacity;
+ vec3 specularColor;
+ float specularPower;
+ ambientColor = ambientColorUniform;
+ diffuseColor = diffuseColorUniform;
+ opacity = opacityUniform;
+ specularColor = specularColorUniform;
+ specularPower = specularPowerUniform;
+ vec4 texColor = texture2D(texture_0, tcoordVCVSOutput.st);
+ diffuseColor = texColor.rgb;
+ opacity = opacity*texColor.a;
+ if (OverridesColor) {
+ ambientColor = ambientColorUniform;
+ diffuseColor = diffuseColorUniform; }
+
+
+ // Generate the normal if we are not passed in one
+ vec3 normalVCVSOutput = normalize(normalVCVSOutput);
+ if (gl_FrontFacing == false) { normalVCVSOutput = -normalVCVSOutput; }
+
+
+ vec3 diffuse = vec3(0,0,0);
+ vec3 specular = vec3(0,0,0);
+ float df;
+ float sf;
+ df = max(0.0, dot(normalVCVSOutput, -lightDirectionVC0));
+ diffuse += (df * lightColor0);
+ sf = sign(df)*pow(max(0.0, dot( reflect(lightDirectionVC0, normalVCVSOutput), normalize(-vertexVC.xyz))), specularPower);
+ specular += (sf * lightColor0);
+ df = max(0.0, dot(normalVCVSOutput, -lightDirectionVC1));
+ diffuse += (df * lightColor1);
+ sf = sign(df)*pow(max(0.0, dot( reflect(lightDirectionVC1, normalVCVSOutput), normalize(-vertexVC.xyz))), specularPower);
+ specular += (sf * lightColor1);
+ df = max(0.0, dot(normalVCVSOutput, -lightDirectionVC2));
+ diffuse += (df * lightColor2);
+ sf = sign(df)*pow(max(0.0, dot( reflect(lightDirectionVC2, normalVCVSOutput), normalize(-vertexVC.xyz))), specularPower);
+ specular += (sf * lightColor2);
+ df = max(0.0, dot(normalVCVSOutput, -lightDirectionVC3));
+ diffuse += (df * lightColor3);
+ sf = sign(df)*pow(max(0.0, dot( reflect(lightDirectionVC3, normalVCVSOutput), normalize(-vertexVC.xyz))), specularPower);
+ specular += (sf * lightColor3);
+ df = max(0.0, dot(normalVCVSOutput, -lightDirectionVC4));
+ diffuse += (df * lightColor4);
+ sf = sign(df)*pow(max(0.0, dot( reflect(lightDirectionVC4, normalVCVSOutput), normalize(-vertexVC.xyz))), specularPower);
+ specular += (sf * lightColor4);
+ diffuse = diffuse * diffuseColor;
+ specular = specular * specularColor;
+ fragOutput0 = vec4(ambientColor + diffuse + specular, opacity); //VTK::Light::Impl
+
+ //VTK::TCoord::Impl
+
+ if (fragOutput0.a <= 0.0)
+ {
+ discard;
+ }
+
+ //VTK::DepthPeeling::Impl
+
+ //VTK::Picking::Impl
+
+ // handle coincident offsets
+ //VTK::Coincident::Impl
+}
+
+
diff --git a/shaders/pts/paraview-1.0.3/many-spheres/9.shader_test b/shaders/pts/paraview-1.0.3/many-spheres/9.shader_test
new file mode 100644
index 0000000..98cd947
--- /dev/null
+++ b/shaders/pts/paraview-1.0.3/many-spheres/9.shader_test
@@ -0,0 +1,862 @@
+[require]
+GLSL >= 1.50
+
+[vertex shader]
+#version 150
+#ifdef GL_ES
+#if __VERSION__ == 300
+#define attribute in
+#define varying out
+#endif // 300
+#else // GL_ES
+#define highp
+#define mediump
+#define lowp
+#if __VERSION__ == 150
+#define attribute in
+#define varying out
+#endif
+#endif // GL_ES
+
+attribute vec4 ndCoordIn;
+attribute vec2 texCoordIn;
+varying vec2 texCoord;
+void main()
+{
+ gl_Position = ndCoordIn;
+ texCoord = texCoordIn;
+}
+
+[fragment shader]
+#version 150
+#ifdef GL_ES
+#if __VERSION__ == 300
+#define varying in
+#ifdef GL_FRAGMENT_PRECISION_HIGH
+precision highp float;
+precision highp sampler2D;
+precision highp sampler3D;
+#else
+precision mediump float;
+precision mediump sampler2D;
+precision mediump sampler3D;
+#endif
+#define texelFetchBuffer texelFetch
+#define texture1D texture
+#define texture2D texture
+#define texture3D texture
+#endif // 300
+#if __VERSION__ == 100
+#extension GL_OES_standard_derivatives : enable
+#ifdef GL_FRAGMENT_PRECISION_HIGH
+precision highp float;
+#else
+precision mediump float;
+#endif
+#endif // 100
+#else // GL_ES
+#define highp
+#define mediump
+#define lowp
+#if __VERSION__ == 150
+#define varying in
+#define texelFetchBuffer texelFetch
+#define texture1D texture
+#define texture2D texture
+#define texture3D texture
+#endif
+#if __VERSION__ == 120
+#extension GL_EXT_gpu_shader4 : require
+#endif
+#endif // GL_ES
+
+
+/*=========================================================================
+
+ Program: Visualization Toolkit
+ Module: vtkFXAAFilterFS.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 for vtkOpenGLFXAAFilter.
+//
+// Based on the following implementation and description:
+//
+// Whitepaper:
+// http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf
+//
+// Sample implementation:
+// https://github.com/NVIDIAGameWorks/GraphicsSamples/blob/master/samples/es3-kepler/FXAA/FXAA3_11.h
+
+out vec4 fragOutput0;
+
+
+//======================== Debugging Options: ==================================
+
+// Output a greyscale image showing the detected amount of subpixel aliasing.
+//#define FXAA_DEBUG_SUBPIXEL_ALIASING
+
+// Output vertical edges in red, and horizontal edges in blue.
+//#define FXAA_DEBUG_EDGE_DIRECTION
+
+// Output (number of steps taken) / (EndpointSearchIterations). Negative steps
+// in the red channel, positive steps in the blue.
+//#define FXAA_DEBUG_EDGE_NUM_STEPS
+
+// Output degrees of red if the edge is near the negative edge endpoint, or
+// shades of blue if near the positive edge endpoint. Pixels near an edge but
+// not eligible for edgeAA (e.g. they are on the unaliased side of an edge)
+// are shown in yellow.
+//#define FXAA_DEBUG_EDGE_DISTANCE
+
+// Output the length of the edge anti-aliasing offset vector in the red channel.
+//#define FXAA_DEBUG_EDGE_SAMPLE_OFFSET
+
+// Only apply a single form of anti-aliasing:
+// 1 - Only apply sub-pixel anti-aliasing.
+// 2 - Only apply edge anti-aliasing.
+// Other / undefined - Apply both sub-pixel and edge anti-aliasing.
+//#define FXAA_DEBUG_ONLY_SUBPIX_AA
+//#define FXAA_DEBUG_ONLY_EDGE_AA
+
+// Replacement stub for vtkShaderProgram::Substitute:
+//VTK::DebugOptions::Def
+
+//========================== Tuning Define: ====================================
+
+// Which edge search implementation to use. If defined, use VTK's endpoint
+// algorithm, otherwise use NVIDIA's.
+//
+// NVIDIA is faster, but gives poor results on single pixel lines (e.g.
+// vtkPolyDataMapper's wireframe/edges). VTK is slower, but gives nicer results
+// on single pixel lines.
+//#define FXAA_USE_HIGH_QUALITY_ENDPOINTS;
+
+// Replacement stub for vtkShaderProgram::Substitute:
+#define FXAA_USE_HIGH_QUALITY_ENDPOINTS
+
+//========================= Input Parameters: ==================================
+
+// Current fragment texture coordinate:
+in vec2 texCoord;
+
+// Aliased color buffer (should be sRGB, ideally)
+uniform sampler2D Input;
+
+// 1.f/Input.width, 1.f/Input.height:
+uniform vec2 InvTexSize;
+
+//======================== Tuning Parameters: ==================================
+
+// See the vtkOpenGLFXAAFilter class documentation for details on these.
+
+// Minimum change in luminosity (relative to maxLum) to use FXAA:
+uniform float RelativeContrastThreshold;
+
+// Absolute minimum lum change required for FXAA (overrides
+// RelativeContrastThreshold value, not scaled):
+uniform float HardContrastThreshold;
+
+// Maximum amount of lowpass blending for subpixel anti-aliasing:
+uniform float SubpixelBlendLimit;
+
+// Ignore subpixel anti-aliasing that contributes less than this amount to the
+// total contrast:
+uniform float SubpixelContrastThreshold;
+
+// Maximum number of steps to take when searching for line edges:
+uniform int EndpointSearchIterations;
+
+//============================ Helper Methods ==================================
+// Converts rgb to luminosity:
+const vec3 LUMINOSITY_VEC = vec3(0.299, 0.587, 0.114);
+float luminosity(vec3 rgb)
+{
+ return dot(rgb, LUMINOSITY_VEC);
+}
+
+//======================= Endpoint Search Routines =============================
+// Identify the endpoints of a detected edge and compute a sampling offset to
+// correct for aliasing. The computed offset accounts for distance from edge
+// to create a gradient of antialiased values.
+//
+// Input parameters:
+// - posC: The texture coordinate position of the current pixel.
+// - lumC: The luminosity of the current pixel.
+// - lumHC: The luminosity of the highest contrast pixel to HC that is
+// perpendicular to the detected edge.
+// - lengthSign: Single component magnitude and direction (in texture
+// coordinates) from the center of C pointing to HC.
+// - tcPixel: (Width, Height) of a single pixel in texture coordinate units.
+// - horzSpan: True if the detected edge is horizontal.
+// - posEdgeAA: Output parameter with the position to resample the input texture
+// to get an edge anti-aliased rgb value for the current pixel.
+//
+// Implementations:
+// - nvidiaEndpointSearch: The algorithm proposed by nVidia in their whitepaper
+// and sample implementations. Faster, but poorly handles single-pixel lines.
+// - vtkEndpointSearch: Modified endpoint search that does more texture lookups,
+// but does better detection of single pixel line endpoints.
+//
+// Return values for endpoint searches:
+const int FXAA_NO_EDGE_AA = 0; // Edge AA not required.
+const int FXAA_NEED_EDGE_AA = 1; // Edge AA required.
+const int FXAA_ABORT_EDGE_AA = 2; // Instruct to return. Used for debugging.
+
+//================ nVidia's Endpoint Search Implementation =====================
+
+int nvidiaEndpointSearch(vec2 posC, float lumC, float lumHC, float lengthSign,
+ vec2 tcPixel, bool horzSpan, out vec2 posEdgeAA)
+{
+ /*****************************************************************************
+ * End of Edge Search *
+ *===========================================================================*
+ * Search along the direction of the detected edge to find both endpoints. *
+ * *
+ * We define HC as the Highest Contrast neighbor perpendicular to the edge *
+ * direction (i.e. the pixel on the other side of the edge). *
+ * *
+ * The luminosity of HC is lumHC, the contrast between C and HC is *
+ * contrastCHC, and the average luminosity of HC and C is lumAveCHC. *
+ * *
+ * We'll walk along the edge boundary in both direction, sampling the average*
+ * luminosity of the pixels on both sides of the edge: lumAveN for the *
+ * negative direction, lumAveP for the positive direction. We determine the *
+ * end of the edge to be where: *
+ * *
+ * abs(lumAve[NP] - lumCHC) >= contrastHC / 4. *
+ * *
+ * which indicates that the average luminosities have diverged enough to no *
+ * longer be considered part of the edge. *
+ ****************************************************************************/
+
+ float contrastCHC = abs(lumC - lumHC);
+
+ // Point on the boundary of C and HC:
+ vec2 boundaryCHC = posC; // Will be shifted later.
+
+ // Direction of the edge
+ vec2 edgeDir = vec2(0.f); // Component is set below:
+
+ if (horzSpan)
+ {
+ boundaryCHC.y += lengthSign * 0.5f;
+ edgeDir.x = tcPixel.x;
+ }
+ else
+ {
+ boundaryCHC.x += lengthSign * 0.5f;
+ edgeDir.y = tcPixel.y;
+ }
+
+ // Prepare for the search loop:
+ float contrastThreshold = contrastCHC / 4.f;
+ float lumAveCHC = 0.5f * (lumC + lumHC);
+ float lumAveN;
+ float lumAveP;
+ bool doneN = false;
+ bool doneP = false;
+ vec2 posN = boundaryCHC - edgeDir;
+ vec2 posP = boundaryCHC + edgeDir;
+
+#ifdef FXAA_DEBUG_EDGE_NUM_STEPS
+ int stepsN = 0;
+ int stepsP = 0;
+#endif // FXAA_DEBUG_EDGE_NUM_STEPS
+
+ for (int i = 0; i < EndpointSearchIterations; ++i)
+ {
+#ifdef FXAA_DEBUG_EDGE_NUM_STEPS
+ if (!doneN) stepsN += 1;
+ if (!doneP) stepsP += 1;
+#endif // FXAA_DEBUG_EDGE_NUM_STEPS
+
+ // Sample on the edge boundary in both directions:
+ if (!doneN) lumAveN = luminosity(texture2D(Input, posN).rgb);
+ if (!doneP) lumAveP = luminosity(texture2D(Input, posP).rgb);
+
+ // Edge endpoint is where the contrast changes significantly:
+ doneN = doneN || (abs(lumAveN - lumAveCHC) >= contrastThreshold);
+ doneP = doneP || (abs(lumAveP - lumAveCHC) >= contrastThreshold);
+ if (doneN && doneP) break;
+
+ // Step to next pixel:
+ if (!doneN) posN -= edgeDir;
+ if (!doneP) posP += edgeDir;
+ }
+
+#ifdef FXAA_DEBUG_EDGE_NUM_STEPS
+ fragOutput0 = vec4(float(stepsN) / float(EndpointSearchIterations), 0.f,
+ float(stepsP) / float(EndpointSearchIterations), 1.f);
+ return FXAA_ABORT_EDGE_AA;
+#endif // FXAA_DEBUG_EDGE_NUM_STEPS
+
+ /*****************************************************************************
+ * Edge Search Analysis *
+ *===========================================================================*
+ * We've located the ends of the edge at this point. Next we figure out how *
+ * to interpolate the edge. *
+ * *
+ * First we need to find out which end of the edge (N or P) is changing *
+ * contrast relative to boundaryCHC. This is best explained visually: *
+ * *
+ * +------------+ *
+ * |XX E | *
+ * |NXXXHXXP | *
+ * |N C PXXXX| *
+ * | X| *
+ * +------------+ *
+ * *
+ * In the above, an X represents a dark pixel, and a blank space is a light *
+ * pixel. C is the current pixel, and H is pixel HC. The negative endpoint N*
+ * of the edge is the midpoint between the first set of blank pixels to the *
+ * left of C and H, while the positive endpoint P is the first set of dark *
+ * pixels to the right. The pixels under the "N" are light, while the pixels*
+ * under "P" are dark. The "P" side of the edge is changing contrast *
+ * relative to C. We compute this condition as: *
+ * *
+ * bool lumCLessThanAve = lumC < lumAveCHC; *
+ * bool lumNLessThanAve = lumAveN < lumAveCHC; *
+ * bool lumPLessThanAve = lumAveP < lumAveCHC; *
+ * bool shadeIfNearN = lumCLessThanAve != lumNLessThanAve; *
+ * bool shadeIfNearP = lumCLessThanAve != lumPLessThanAve; *
+ * *
+ * If shadeIfNearN is true, N is changing contrast relative to C. The same *
+ * is true for P. Thus, the change in the average contrast of the the *
+ * endpoint relative to lumAveHC must be opposite to the change in contrast *
+ * from C to lumAveHC. *
+ * *
+ * In addition to checking the change in contrast, we also identify which *
+ * endpoint is nearest to C. As the variable names suggest, we will only *
+ * apply edge anti-aliasing if we're nearest an endpoint that has the *
+ * desired contrast change. This prevents shading edge neighbors that do not*
+ * follow the direction of the line, such as point E in the diagram. *
+ * *
+ * bool CisNearN = (norm(posN - boundaryCHC) < norm(posP - boundaryCHC)); *
+ * *
+ * If both of the above conditions are met (the nearest endpoint has the *
+ * proper contrast change), then we compute the ratio of C's distance from *
+ * the desired endpoint to the total length of the edge. This ratio is the *
+ * fraction of a pixel that we shift C towards HC to resample C for *
+ * anti-aliasing. *
+ ****************************************************************************/
+
+ // Check both endpoints for the contrast change condition:
+ bool lumCLessThanAve = lumC < lumAveCHC;
+ bool lumNLessThanAve = lumAveN < lumAveCHC;
+ bool lumPLessThanAve = lumAveP < lumAveCHC;
+ bool shadeIfNearN = lumCLessThanAve != lumNLessThanAve;
+ bool shadeIfNearP = lumCLessThanAve != lumPLessThanAve;
+
+ // Identify the closest point:
+ float dstN;
+ float dstP;
+ if (horzSpan)
+ {
+ dstN = boundaryCHC.x - posN.x;
+ dstP = posP.x - boundaryCHC.x;
+ }
+ else
+ {
+ dstN = boundaryCHC.y - posN.y;
+ dstP = posP.y - boundaryCHC.y;
+ }
+ bool nearestEndpointIsN = dstN < dstP;
+ float dst = min(dstN, dstP);
+
+ // Finally determine if we need shading:
+ bool needEdgeAA = nearestEndpointIsN ? shadeIfNearN : shadeIfNearP;
+
+#ifdef FXAA_DEBUG_EDGE_DISTANCE
+ if (needEdgeAA)
+ {
+ float maxDistance = EndpointSearchIterations;
+ if (nearestEndpointIsN)
+ {
+ fragOutput0 = vec4(1.f - dstN / maxDistance, 0.f, 0.f, 1.f);
+ }
+ else
+ {
+ fragOutput0 = vec4(0.f, 0.f, 1.f - dstP / maxDistance, 1.f);
+ }
+ }
+ else
+ {
+ fragOutput0 = vec4(1.f, 1.f, 0.f, 1.f);
+ }
+ return FXAA_ABORT_EDGE_AA;
+#endif // FXAA_DEBUG_EDGE_DISTANCE
+
+ // Compute the pixel offset:
+ float invNegSpanLength = -1.f / (dstN + dstP);
+ float pixelOffset = dst * invNegSpanLength + 0.5;
+
+#ifdef FXAA_DEBUG_EDGE_SAMPLE_OFFSET
+ if (needEdgeAA)
+ { // x2, since the max value is 0.5:
+ fragOutput0 = vec4(-2.f * dst * invNegSpanLength, 0.f, 0.f, 1.f);
+ return FXAA_ABORT_EDGE_AA;
+ }
+#endif // FXAA_DEBUG_EDGE_SAMPLE_OFFSET
+
+ // Resample the edge anti-aliased value:
+ posEdgeAA = posC;
+ if (horzSpan)
+ {
+ posEdgeAA.y += pixelOffset * lengthSign;
+ }
+ else
+ {
+ posEdgeAA.x += pixelOffset * lengthSign;
+ }
+
+ return needEdgeAA ? 1 : 0;
+}
+
+//================== VTK's Endpoint Search Implementation ======================
+
+int vtkEndpointSearch(vec2 posC, float lumC, float lumHC, float lengthSign,
+ vec2 tcPixel, bool horzSpan, out vec2 posEdgeAA)
+{
+ /*****************************************************************************
+ * End of Edge Search *
+ *===========================================================================*
+ * Search along the direction of the detected edge to find both endpoints. *
+ * +------------+ *
+ * |X | nVidia's endpoint detector handles this case poorly. If C *
+ * | XXXXXX C | is the current pixel, it will detect N as the leftmost *
+ * | XXHXX| column of pixels, since it samples the average luminosity *
+ * | X| at the border of the rows containing C and HC. The actual *
+ * +------------+ endpoint is 3 pixels to the left from C, but the average *
+ * luminosity does not change at this point. *
+ * *
+ * We adapt the algorithm to sample both rows/columns containing C and HC on *
+ * the texel centers, rather than the interpolated border. We then detect *
+ * the edge endpoints when: *
+ * *
+ * abs(lumHCN - lumHC) > abs(lumHCN - lumC) || *
+ * abs(lumCN - lumC) > abs(lumCN - lumHC) *
+ * *
+ * where lumHCN is the luminosity of the sample in HC's row in the negative *
+ * direction, lumCN is the luminosity of the sample in C's row in the *
+ * negative direction, lumHC is the luminosity of HC, and lumC is the *
+ * luminosity of C. Thus, the endpoint is where a sampled luminosity in C's *
+ * row is closer to HC, or vice-versa. The positive endpoint is determined *
+ * similarly. *
+ * *
+ * After the endpoints has been determined, we decide whether or not the *
+ * current pixel needs resampling. This is similar to nVidia's algorithm. *
+ * We determine if the luminosity of the nearest endpoint's C sample is *
+ * closer to C or HC. If it's closer to HC, it gets shaded. The resampling *
+ * offset is computed identically to nVidia's algorithm. *
+ ****************************************************************************/
+
+ // Point on the boundary of C and HC:
+ vec2 posHC = posC; // Will be shifted later.
+
+ // Direction of the edge
+ vec2 edgeDir = vec2(0.f); // Component is set below:
+
+ if (horzSpan)
+ {
+ posHC.y += lengthSign;
+ edgeDir.x = tcPixel.x;
+ }
+ else
+ {
+ posHC.x += lengthSign;
+ edgeDir.y = tcPixel.y;
+ }
+
+ // Prepare for the search loop:
+ float lumHCN;
+ float lumHCP;
+ float lumCN;
+ float lumCP;
+ bool doneN = false;
+ bool doneP = false;
+ vec2 posHCN = posHC - edgeDir;
+ vec2 posHCP = posHC + edgeDir;
+ vec2 posCN = posC - edgeDir;
+ vec2 posCP = posC + edgeDir;
+
+#ifdef FXAA_DEBUG_EDGE_NUM_STEPS
+ int stepsN = 0;
+ int stepsP = 0;
+#endif // FXAA_DEBUG_EDGE_NUM_STEPS
+
+ for (int i = 0; i < EndpointSearchIterations; ++i)
+ {
+#ifdef FXAA_DEBUG_EDGE_NUM_STEPS
+ if (!doneN) stepsN += 1;
+ if (!doneP) stepsP += 1;
+#endif // FXAA_DEBUG_EDGE_NUM_STEPS
+
+ // Sample the luminosities along the edge:
+ if (!doneN)
+ {
+ lumHCN = luminosity(texture2D(Input, posHCN).rgb);
+ lumCN = luminosity(texture2D(Input, posCN).rgb);
+ }
+ if (!doneP)
+ {
+ lumHCP = luminosity(texture2D(Input, posHCP).rgb);
+ lumCP = luminosity(texture2D(Input, posCP).rgb);
+ }
+
+ // Check contrast to detect endpoint:
+ doneN = doneN || abs(lumHCN - lumHC) > abs(lumHCN - lumC)
+ || abs(lumCN - lumC) > abs(lumCN - lumHC);
+ doneP = doneP || abs(lumHCP - lumHC) > abs(lumHCP - lumC)
+ || abs(lumCP - lumC) > abs(lumCP - lumHC);
+
+ if (doneN && doneP)
+ {
+ break;
+ }
+
+ // Take next step.
+ if (!doneN)
+ {
+ posHCN -= edgeDir;
+ posCN -= edgeDir;
+ }
+ if (!doneP)
+ {
+ posHCP += edgeDir;
+ posCP += edgeDir;
+ }
+ }
+
+#ifdef FXAA_DEBUG_EDGE_NUM_STEPS
+ fragOutput0 = vec4(float(stepsN) / float(EndpointSearchIterations), 0.f,
+ float(stepsP) / float(EndpointSearchIterations), 1.f);
+ return FXAA_ABORT_EDGE_AA;
+#endif // FXAA_DEBUG_EDGE_NUM_STEPS
+
+ // Identify the closest point:
+ float dstN;
+ float dstP;
+
+ if (horzSpan)
+ {
+ dstN = posC.x - posCN.x;
+ dstP = posCP.x - posC.x;
+ }
+ else
+ {
+ dstN = posC.y - posCN.y;
+ dstP = posCP.y - posC.y;
+ }
+
+ bool nearestEndpointIsN = dstN < dstP;
+ float dst = min(dstN, dstP);
+ float lumCNear = nearestEndpointIsN ? lumCN : lumCP;
+
+ // Resample if the nearest endpoint sample in C's row is closer in luminosity
+ // to HC than C.
+ bool needEdgeAA = abs(lumCNear - lumHC) < abs(lumCNear - lumC);
+
+#ifdef FXAA_DEBUG_EDGE_DISTANCE
+ if (needEdgeAA)
+ {
+ float maxDistance = EndpointSearchIterations;
+ if (nearestEndpointIsN)
+ {
+ fragOutput0 = vec4(1.f - dstN / maxDistance, 0.f, 0.f, 1.f);
+ }
+ else
+ {
+ fragOutput0 = vec4(0.f, 0.f, 1.f - dstP / maxDistance, 1.f);
+ }
+ }
+ else
+ {
+ fragOutput0 = vec4(1.f, 1.f, 0.f, 1.f);
+ }
+ return FXAA_ABORT_EDGE_AA;
+#endif // FXAA_DEBUG_EDGE_DISTANCE
+
+ // Compute the pixel offset:
+ float invNegSpanLength = -1.f / (dstN + dstP);
+ float pixelOffset = dst * invNegSpanLength + 0.5f;
+
+#ifdef FXAA_DEBUG_EDGE_SAMPLE_OFFSET
+ if (needEdgeAA)
+ { // x2, since the max value is 0.5:
+ fragOutput0 = vec4(-2.f * dst * invNegSpanLength, 0.f, 0.f, 1.f);
+ return FXAA_ABORT_EDGE_AA;
+ }
+#endif // FXAA_DEBUG_EDGE_SAMPLE_OFFSET
+
+ // Resample the edge anti-aliased value:
+ posEdgeAA = posC;
+ if (horzSpan)
+ {
+ posEdgeAA.y += pixelOffset * lengthSign;
+ }
+ else
+ {
+ posEdgeAA.x += pixelOffset * lengthSign;
+ }
+
+ return needEdgeAA ? 1 : 0;
+}
+
+//=============================== FXAA Body ====================================
+
+void main()
+{
+ // Pixel step size in texture coordinate units:
+ vec2 tcPixel = InvTexSize;
+
+ /****************************************************************************
+ * Compute Local Contrast Range And Early Abort *
+ *==========================================================================*
+ * Determine the contrast range for the current pixel and its neightbors *
+ * to the North, South, West, and East. If the range is less than both of: *
+ * *
+ * a) RelativeContrastThreshold * lumMax *
+ * *
+ * and *
+ * *
+ * b) HardContrastThreshold *
+ * *
+ * then skip anti-aliasing for this pixel. *
+ ****************************************************************************/
+
+ // First compute the texture coordinates:
+ vec2 tcC = texCoord;
+ vec2 tcN = texCoord + vec2( 0.f, -tcPixel.y);
+ vec2 tcS = texCoord + vec2( 0.f, tcPixel.y);
+ vec2 tcW = texCoord + vec2(-tcPixel.x, 0.f);
+ vec2 tcE = texCoord + vec2( tcPixel.x, 0.f);
+
+ // Extract the rgb values of these pixels:
+ vec3 rgbC = texture2D(Input, tcC).rgb;
+ vec3 rgbN = texture2D(Input, tcN).rgb;
+ vec3 rgbS = texture2D(Input, tcS).rgb;
+ vec3 rgbW = texture2D(Input, tcW).rgb;
+ vec3 rgbE = texture2D(Input, tcE).rgb;
+
+ // Convert to luminosity:
+ float lumC = luminosity(rgbC);
+ float lumN = luminosity(rgbN);
+ float lumS = luminosity(rgbS);
+ float lumW = luminosity(rgbW);
+ float lumE = luminosity(rgbE);
+
+ // The min, max, and range of luminosity for CNSWE:
+ float lumMin = min(lumC, min(min(lumN, lumS), min(lumW, lumE)));
+ float lumMax = max(lumC, max(max(lumN, lumS), max(lumW, lumE)));
+ float lumRange = lumMax - lumMin;
+ float lumThresh = max(HardContrastThreshold,
+ RelativeContrastThreshold * lumMax);
+
+ // Don't apply FXAA unless there's a significant change in luminosity around
+ // the current pixel:
+ if (lumRange < lumThresh)
+ {
+ fragOutput0 = vec4(rgbC, 1.f); // original color
+ return;
+ }
+
+ /****************************************************************************
+ * Fetch texels for complete 3x3 neighborhood. *
+ ****************************************************************************/
+
+ // Fetch additional texels for edge detection / subpixel antialiasing:
+ vec2 tcNE = texCoord + vec2( tcPixel.x, -tcPixel.y);
+ vec2 tcSE = texCoord + vec2( tcPixel.x, tcPixel.y);
+ vec2 tcNW = texCoord + vec2(-tcPixel.x, -tcPixel.y);
+ vec2 tcSW = texCoord + vec2(-tcPixel.x, tcPixel.y);
+ vec3 rgbNE = texture2D(Input, tcNE).rgb;
+ vec3 rgbSE = texture2D(Input, tcSE).rgb;
+ vec3 rgbNW = texture2D(Input, tcNW).rgb;
+ vec3 rgbSW = texture2D(Input, tcSW).rgb;
+ float lumNE = luminosity(rgbNE);
+ float lumSE = luminosity(rgbSE);
+ float lumNW = luminosity(rgbNW);
+ float lumSW = luminosity(rgbSW);
+
+ // Precompute some combined luminosities. These are reused later.
+ float lumNS = lumN + lumS;
+ float lumWE = lumW + lumE;
+ float lumNSWE = lumNS + lumWE;
+ float lumNWNE = lumNW + lumNE;
+ float lumSWSE = lumSW + lumSE;
+ float lumNWSW = lumNW + lumSW;
+ float lumNESE = lumNE + lumSE;
+
+ /****************************************************************************
+ * Subpixel Anti-aliasing *
+ *==========================================================================*
+ * Check if the current pixel is very high contrast to it's neighbors (e.g. *
+ * specular aliasing, noisy shadow textures, etc). If it is, compute the *
+ * average color over the 3x3 neighborhood and a blending factor. *
+ * *
+ * The blending factor is computed as the minimum of: *
+ * *
+ * 1) max(0.f, abs([average NSWE lum] - lumC) - SubpixelContrastThreshold) *
+ * FXAA_SUBPIX_TRIM_SCALE *
+ * *
+ * or *
+ * *
+ * 2) SubpixelBlendLimit *
+ ****************************************************************************/
+
+ // Check for sub-pixel aliasing (e.g. current pixel has high contrast from
+ // neighbors):
+ float lumAveNSWE = 0.25f * (lumNSWE);
+ float lumSubRange = abs(lumAveNSWE - lumC);
+
+ // Compute the subpixel blend amount:
+ float blendSub = max(0.f, (lumSubRange / lumRange) -
+ SubpixelContrastThreshold);
+ blendSub = min(SubpixelBlendLimit,
+ blendSub * (1.f / (1.f - SubpixelContrastThreshold)));
+
+#ifdef FXAA_DEBUG_SUBPIXEL_ALIASING
+ if (blendSub > 0.f)
+ {
+ fragOutput0 = vec4(vec3(blendSub / SubpixelBlendLimit), 1.f);
+ }
+ else
+ {
+ fragOutput0 = vec4(rgbC, 1.f);
+ }
+ return;
+#endif // FXAA_DEBUG_SUBPIXEL_ALIASING
+
+ // Compute the subpixel blend color. Average the 3x3 neighborhood:
+ vec3 rgbSub = (1.f/9.f) *
+ (rgbNW + rgbN + rgbNE +
+ rgbW + rgbC + rgbE +
+ rgbSW + rgbS + rgbSE);
+
+ /****************************************************************************
+ * Edge Testing *
+ *==========================================================================*
+ * Apply vertical and horizontal edge detection techniques to determine the *
+ * direction of any edges in the 3x3 neighborhood. *
+ ****************************************************************************/
+
+ // Check for vertical edge. Pixel coeffecients are:
+ // 1 -2 1
+ // 2 -4 2
+ // 1 -2 1
+ // The absolute value of each row is taken, summed, and divided by 12.
+ // Operations are decomposed here to take advantage of FMA ops.
+ float edgeVertRow1 = abs(-2.f * lumN + lumNWNE);
+ float edgeVertRow2 = abs(-2.f * lumC + lumWE);
+ float edgeVertRow3 = abs(-2.f * lumS + lumSWSE);
+ float edgeVert = ((2.f * edgeVertRow2 + edgeVertRow1) + edgeVertRow3) / 12.f;
+
+ // Check for horizontal edge. Pixel coeffecients are:
+ // 1 2 1
+ // -2 -4 -2
+ // 1 2 1
+ // The absolute value of each column is taken, summed, and divided by 12.
+ // Operations are decomposed here to take advantage of FMA ops.
+ float edgeHorzCol1 = abs(-2.f * lumW + lumNWSW);
+ float edgeHorzCol2 = abs(-2.f * lumC + lumNS);
+ float edgeHorzCol3 = abs(-2.f * lumE + lumNESE);
+ float edgeHorz = ((2.f * edgeHorzCol2 + edgeHorzCol1) + edgeHorzCol3) / 12.f;
+
+ // Indicates that the edge span is horizontal:
+ bool horzSpan = edgeHorz >= edgeVert;
+
+#ifdef FXAA_DEBUG_EDGE_DIRECTION
+ fragOutput0 = horzSpan ? vec4(0.f, 0.f, 1.f, 1.f)
+ : vec4(1.f, 0.f, 0.f, 1.f);
+ return;
+#endif // FXAA_DEBUG_EDGE_DIRECTION
+
+ /****************************************************************************
+ * Endpoint Search Preparation *
+ *==========================================================================*
+ * Compute inputs for an endpoint detection algorithm. Mainly concerned *
+ * locating HC -- the Highest Contrast pixel (relative to C) that's on the *
+ * opposite side of the detected edge from C. *
+ ****************************************************************************/
+
+ // The two neighbor pixels perpendicular to the edge:
+ float lumHC1;
+ float lumHC2;
+
+ // Single-pixel texture coordinate offset that points from C to HC.
+ float lengthSign;
+
+ if (horzSpan)
+ {
+ lumHC1 = lumN;
+ lumHC2 = lumS;
+ lengthSign = -tcPixel.y; // Assume N for now.
+ }
+ else
+ {
+ lumHC1 = lumW;
+ lumHC2 = lumE;
+ lengthSign = -tcPixel.x; // Assume W for now.
+ }
+
+ // Luminosity of the NSWE pixel perpendicular to the edge with the highest
+ // contrast to C:
+ float lumHC;
+ if (abs(lumC - lumHC1) >= abs(lumC - lumHC2))
+ {
+ lumHC = lumHC1;
+ }
+ else
+ {
+ lumHC = lumHC2;
+ // Also reverse the offset direction in this case:
+ lengthSign = -lengthSign;
+ }
+
+ vec2 posEdgeAA; // Position to resample C at to get edge-antialiasing.
+
+#ifdef FXAA_USE_HIGH_QUALITY_ENDPOINTS
+ int endpointResult = vtkEndpointSearch(tcC, lumC, lumHC, lengthSign,
+ tcPixel, horzSpan, posEdgeAA);
+#else // FXAA_USE_HIGH_QUALITY_ENDPOINTS
+ int endpointResult = nvidiaEndpointSearch(tcC, lumC, lumHC, lengthSign,
+ tcPixel, horzSpan, posEdgeAA);
+#endif // FXAA_USE_HIGH_QUALITY_ENDPOINTS
+
+ // Only sample texture if needed. Reuse rgbC otherwise.
+ vec3 rgbEdgeAA = rgbC;
+
+ switch (endpointResult)
+ {
+ case FXAA_ABORT_EDGE_AA: // Used for debugging (endpoint search set colors)
+ return;
+
+ case FXAA_NEED_EDGE_AA: // Resample the texture at the requested position.
+ rgbEdgeAA = texture2D(Input, posEdgeAA).rgb;
+ break;
+
+ case FXAA_NO_EDGE_AA: // Current pixel does not need edge anti-aliasing.
+ default:
+ break;
+ }
+
+#ifdef FXAA_DEBUG_ONLY_SUBPIX_AA
+ rgbEdgeAA = rgbC;
+#endif // FXAA_DEBUG_ONLY_SUBPIX_AA
+#ifdef FXAA_DEBUG_ONLY_EDGE_AA
+ blendSub = 0.f;
+#endif // FXAA_DEBUG_ONLY_EDGE_AA
+
+ // Blend the edgeAA and subpixelAA results together:
+ fragOutput0 = vec4(mix(rgbEdgeAA, rgbSub, blendSub), 1.f);
+}
+
+
diff --git a/shaders/pts/paraview-1.0.3/wavelet-volume/6.shader_test b/shaders/pts/paraview-1.0.3/wavelet-volume/6.shader_test
new file mode 100644
index 0000000..55c232f
--- /dev/null
+++ b/shaders/pts/paraview-1.0.3/wavelet-volume/6.shader_test
@@ -0,0 +1,627 @@
+[require]
+GLSL >= 1.50
+
+[vertex shader]
+#version 150
+#ifdef GL_ES
+#if __VERSION__ == 300
+#define attribute in
+#define varying out
+#endif // 300
+#else // GL_ES
+#define highp
+#define mediump
+#define lowp
+#if __VERSION__ == 150
+#define attribute in
+#define varying out
+#endif
+#endif // GL_ES
+
+
+/*=========================================================================
+
+ Program: Visualization Toolkit
+ Module: raycastervs.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.
+
+=========================================================================*/
+
+/// Needed to enable inverse function
+#extension GL_ARB_gpu_shader5 : enable
+
+//////////////////////////////////////////////////////////////////////////////
+///
+/// Uniforms, attributes, and globals
+///
+//////////////////////////////////////////////////////////////////////////////
+
+ uniform bool in_cellFlag;
+ uniform vec3 in_cellSpacing;
+ uniform mat4 in_modelViewMatrix;
+ uniform mat4 in_projectionMatrix;
+ uniform mat4 in_volumeMatrix;
+
+ uniform vec3 in_volumeExtentsMin;
+ uniform vec3 in_volumeExtentsMax;
+
+ uniform mat4 in_inverseTextureDatasetMatrix;
+ uniform mat4 in_cellToPoint;
+ uniform vec3 in_textureExtentsMax;
+ uniform vec3 in_textureExtentsMin;
+
+ //This variable could be 'invariant varying' but it is declared
+ //as 'varying' to avoid compiler compatibility issues.
+ varying mat4 ip_inverseTextureDataAdjusted;
+
+//VTK::Termination::Dec
+
+//VTK::Cropping::Dec
+
+//VTK::Shading::Dec
+
+//////////////////////////////////////////////////////////////////////////////
+///
+/// Inputs
+///
+//////////////////////////////////////////////////////////////////////////////
+attribute vec3 in_vertexPos;
+
+//////////////////////////////////////////////////////////////////////////////
+///
+/// Outputs
+///
+//////////////////////////////////////////////////////////////////////////////
+/// 3D texture coordinates for texture lookup in the fragment shader
+varying vec3 ip_textureCoords;
+varying vec3 ip_vertexPos;
+
+void main()
+{
+ /// Get clipspace position
+
+ vec4 pos = in_projectionMatrix * in_modelViewMatrix *
+ in_volumeMatrix * vec4(in_vertexPos.xyz, 1.0);
+ gl_Position = pos;
+
+ /// Compute texture coordinates
+
+ // For point dataset, we offset the texture coordinate
+ // to account for OpenGL treating voxel at the center of the cell.
+ vec3 uvx = sign(in_cellSpacing) * (in_vertexPos - in_volumeExtentsMin) /
+ (in_volumeExtentsMax - in_volumeExtentsMin);
+
+ if (in_cellFlag)
+ {
+ ip_textureCoords = uvx;
+ ip_inverseTextureDataAdjusted = in_inverseTextureDatasetMatrix;
+ }
+ else
+ {
+ // Transform cell tex-coordinates to point tex-coordinates
+ ip_textureCoords = (in_cellToPoint * vec4(uvx, 1.0)).xyz;
+ ip_inverseTextureDataAdjusted = in_cellToPoint * in_inverseTextureDatasetMatrix;
+ }
+
+ /// Copy incoming vertex position for the fragment shader
+ ip_vertexPos = in_vertexPos;
+}
+
+
+[fragment shader]
+#version 150
+#ifdef GL_ES
+#if __VERSION__ == 300
+#define varying in
+#ifdef GL_FRAGMENT_PRECISION_HIGH
+precision highp float;
+precision highp sampler2D;
+precision highp sampler3D;
+#else
+precision mediump float;
+precision mediump sampler2D;
+precision mediump sampler3D;
+#endif
+#define texelFetchBuffer texelFetch
+#define texture1D texture
+#define texture2D texture
+#define texture3D texture
+#endif // 300
+#if __VERSION__ == 100
+#extension GL_OES_standard_derivatives : enable
+#ifdef GL_FRAGMENT_PRECISION_HIGH
+precision highp float;
+#else
+precision mediump float;
+#endif
+#endif // 100
+#else // GL_ES
+#define highp
+#define mediump
+#define lowp
+#if __VERSION__ == 150
+#define varying in
+#define texelFetchBuffer texelFetch
+#define texture1D texture
+#define texture2D texture
+#define texture3D texture
+#endif
+#if __VERSION__ == 120
+#extension GL_EXT_gpu_shader4 : require
+#endif
+#endif // GL_ES
+
+
+/*=========================================================================
+
+ Program: Visualization Toolkit
+ Module: raycasterfs.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.
+
+=========================================================================*/
+
+//////////////////////////////////////////////////////////////////////////////
+///
+/// Inputs
+///
+//////////////////////////////////////////////////////////////////////////////
+
+/// 3D texture coordinates form vertex shader
+varying vec3 ip_textureCoords;
+varying vec3 ip_vertexPos;
+
+//////////////////////////////////////////////////////////////////////////////
+///
+/// Outputs
+///
+//////////////////////////////////////////////////////////////////////////////
+
+vec4 g_fragColor = vec4(0.0);
+
+//////////////////////////////////////////////////////////////////////////////
+///
+/// Uniforms, attributes, and globals
+///
+//////////////////////////////////////////////////////////////////////////////
+vec3 g_dataPos;
+vec3 g_dirStep;
+vec4 g_srcColor;
+vec4 g_eyePosObj;
+bool g_exit;
+bool g_skip;
+float g_currentT;
+float g_terminatePointMax;
+
+uniform vec4 in_volume_scale;
+uniform vec4 in_volume_bias;
+
+out vec4 fragOutput0;
+
+
+
+// Volume dataset
+uniform sampler3D in_volume;
+uniform int in_noOfComponents;
+uniform int in_independentComponents;
+
+uniform sampler2D in_noiseSampler;
+#ifndef GL_ES
+uniform sampler2D in_depthSampler;
+#endif
+
+// Camera position
+uniform vec3 in_cameraPos;
+
+// view and model matrices
+uniform mat4 in_volumeMatrix;
+uniform mat4 in_inverseVolumeMatrix;
+uniform mat4 in_projectionMatrix;
+uniform mat4 in_inverseProjectionMatrix;
+uniform mat4 in_modelViewMatrix;
+uniform mat4 in_inverseModelViewMatrix;
+uniform mat4 in_textureDatasetMatrix;
+uniform mat4 in_inverseTextureDatasetMatrix;
+varying mat4 ip_inverseTextureDataAdjusted;
+uniform vec3 in_texMin;
+uniform vec3 in_texMax;
+uniform mat4 in_textureToEye;
+
+// Ray step size
+uniform vec3 in_cellStep;
+uniform vec2 in_scalarsRange[4];
+uniform vec3 in_cellSpacing;
+
+// Sample distance
+uniform float in_sampleDistance;
+
+// Scales
+uniform vec3 in_cellScale;
+uniform vec2 in_windowLowerLeftCorner;
+uniform vec2 in_inverseOriginalWindowSize;
+uniform vec2 in_inverseWindowSize;
+uniform vec3 in_textureExtentsMax;
+uniform vec3 in_textureExtentsMin;
+
+// Material and lighting
+uniform vec3 in_diffuse[4];
+uniform vec3 in_ambient[4];
+uniform vec3 in_specular[4];
+uniform float in_shininess[4];
+
+// Others
+uniform bool in_cellFlag;
+uniform bool in_useJittering;
+vec3 g_rayJitter = vec3(0.0);
+uniform bool in_clampDepthToBackface;
+
+uniform vec2 in_averageIPRange;
+uniform vec3 in_lightAmbientColor[1];
+uniform vec3 in_lightDiffuseColor[1];
+uniform vec3 in_lightSpecularColor[1];
+vec4 g_lightPosObj;
+vec3 g_ldir;
+vec3 g_vdir;
+vec3 g_h;
+
+
+ const float g_opacityThreshold = 1.0 - 1.0 / 255.0;
+
+//VTK::Cropping::Dec
+
+
+ int clippingPlanesSize;
+ vec3 objRayDir;
+ mat4 textureToObjMat;
+
+//VTK::Shading::Dec
+
+//VTK::BinaryMask::Dec
+
+//VTK::CompositeMask::Dec
+
+
+uniform sampler2D in_opacityTransferFunc;
+float computeOpacity(vec4 scalar)
+ {
+ return texture2D(in_opacityTransferFunc, vec2(scalar.w, 0)).r;
+ }
+
+
+vec4 computeGradient(int component)
+ {
+ return vec4(0.0);
+ }
+
+
+vec4 computeLighting(vec4 color, int component)
+ {
+ vec4 finalColor = vec4(0.0);
+ finalColor = vec4(color.rgb, 0.0);
+ finalColor.a = color.a;
+ return finalColor;
+ }
+
+
+uniform sampler2D in_colorTransferFunc;
+vec4 computeColor(vec4 scalar, float opacity)
+ {
+ return computeLighting(vec4(texture2D(in_colorTransferFunc,
+ vec2(scalar.w, 0.0)).xyz, opacity), 0);
+ }
+
+
+vec3 computeRayDirection()
+ {
+ return normalize(ip_vertexPos.xyz - g_eyePosObj.xyz);
+ }
+
+//VTK::Picking::Dec
+
+//VTK::RenderToImage::Dec
+
+//VTK::DepthPeeling::Dec
+
+/// We support only 8 clipping planes for now
+/// The first value is the size of the data array for clipping
+/// planes (origin, normal)
+uniform float in_clippingPlanes[49];
+uniform float in_scale;
+uniform float in_bias;
+
+//////////////////////////////////////////////////////////////////////////////
+///
+/// Helper functions
+///
+//////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Transform window coordinate to NDC.
+ */
+vec4 WindowToNDC(const float xCoord, const float yCoord, const float zCoord)
+{
+ vec4 NDCCoord = vec4(0.0, 0.0, 0.0, 1.0);
+
+ NDCCoord.x = (xCoord - in_windowLowerLeftCorner.x) * 2.0 *
+ in_inverseWindowSize.x - 1.0;
+ NDCCoord.y = (yCoord - in_windowLowerLeftCorner.y) * 2.0 *
+ in_inverseWindowSize.y - 1.0;
+ NDCCoord.z = (2.0 * zCoord - (gl_DepthRange.near + gl_DepthRange.far)) /
+ gl_DepthRange.diff;
+
+ return NDCCoord;
+}
+
+/**
+ * Transform NDC coordinate to window coordinates.
+ */
+vec4 NDCToWindow(const float xNDC, const float yNDC, const float zNDC)
+{
+ vec4 WinCoord = vec4(0.0, 0.0, 0.0, 1.0);
+
+ WinCoord.x = (xNDC + 1.f) / (2.f * in_inverseWindowSize.x) +
+ in_windowLowerLeftCorner.x;
+ WinCoord.y = (yNDC + 1.f) / (2.f * in_inverseWindowSize.y) +
+ in_windowLowerLeftCorner.y;
+ WinCoord.z = (zNDC * gl_DepthRange.diff +
+ (gl_DepthRange.near + gl_DepthRange.far)) / 2.f;
+
+ return WinCoord;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+///
+/// Ray-casting
+///
+//////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Global initialization. This method should only be called once per shader
+ * invocation regardless of whether castRay() is called several times (e.g.
+ * vtkDualDepthPeelingPass). Any castRay() specific initialization should be
+ * placed within that function.
+ */
+void initializeRayCast()
+{
+ /// Initialize g_fragColor (output) to 0
+ g_fragColor = vec4(0.0);
+ g_dirStep = vec3(0.0);
+ g_srcColor = vec4(0.0);
+ g_exit = false;
+
+
+ bool l_adjustTextureExtents = !in_cellFlag;
+ // Get the 3D texture coordinates for lookup into the in_volume dataset
+ g_dataPos = ip_textureCoords.xyz;
+
+ // Eye position in dataset space
+ g_eyePosObj = (in_inverseVolumeMatrix * vec4(in_cameraPos, 1.0));
+ if (g_eyePosObj.w != 0.0)
+ {
+ g_eyePosObj.x /= g_eyePosObj.w;
+ g_eyePosObj.y /= g_eyePosObj.w;
+ g_eyePosObj.z /= g_eyePosObj.w;
+ g_eyePosObj.w = 1.0;
+ }
+
+ // Getting the ray marching direction (in dataset space);
+ vec3 rayDir = computeRayDirection();
+
+ // Multiply the raymarching direction with the step size to get the
+ // sub-step size we need to take at each raymarching step
+ g_dirStep = (ip_inverseTextureDataAdjusted *
+ vec4(rayDir, 0.0)).xyz * in_sampleDistance;
+
+ // 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 coordinate is less than 1 if
+ // the reduction factor is less than 1.
+ // Device coordinates are between -1 and 1. We need texture
+ // coordinates between 0 and 1. The in_noiseSampler and in_depthSampler
+ // buffers have the original size buffer.
+ vec2 fragTexCoord = (gl_FragCoord.xy - in_windowLowerLeftCorner) *
+ in_inverseWindowSize;
+
+ if (in_useJittering)
+ {
+ float jitterValue = texture2D(in_noiseSampler, fragTexCoord).x;
+ g_rayJitter = g_dirStep * jitterValue;
+ g_dataPos += g_rayJitter;
+ }
+ else
+ {
+ g_dataPos += g_dirStep;
+ }
+
+ // Flag to deternmine if voxel should be considered for the rendering
+ g_skip = false;
+
+
+ // Flag to indicate if the raymarch loop should terminate
+ bool stop = false;
+
+ g_terminatePointMax = 0.0;
+
+#ifdef GL_ES
+ vec4 l_depthValue = vec4(1.0,1.0,1.0,1.0);
+#else
+ vec4 l_depthValue = texture2D(in_depthSampler, fragTexCoord);
+#endif
+ // Depth test
+ if(gl_FragCoord.z >= l_depthValue.x)
+ {
+ discard;
+ }
+
+ // color buffer or max scalar buffer have a reduced size.
+ fragTexCoord = (gl_FragCoord.xy - in_windowLowerLeftCorner) *
+ in_inverseOriginalWindowSize;
+
+ // Compute max number of iterations it will take before we hit
+ // the termination point
+
+ // Abscissa of the point on the depth buffer along the ray.
+ // point in texture coordinates
+ vec4 terminatePoint = WindowToNDC(gl_FragCoord.x, gl_FragCoord.y, l_depthValue.x);
+
+ // From normalized device coordinates to eye coordinates.
+ // in_projectionMatrix is inversed because of way VT
+ // From eye coordinates to texture coordinates
+ terminatePoint = ip_inverseTextureDataAdjusted *
+ in_inverseVolumeMatrix *
+ in_inverseModelViewMatrix *
+ in_inverseProjectionMatrix *
+ terminatePoint;
+ terminatePoint /= terminatePoint.w;
+
+ g_terminatePointMax = length(terminatePoint.xyz - g_dataPos.xyz) /
+ length(g_dirStep);
+ g_currentT = 0.0;
+
+ //VTK::Cropping::Init
+
+ //VTK::Clipping::Init
+
+ //VTK::RenderToImage::Init
+
+ //VTK::DepthPass::Init
+}
+
+/**
+ * March along the ray direction sampling the volume texture. This function
+ * takes a start and end point as arguments but it is up to the specific render
+ * pass implementation to use these values (e.g. vtkDualDepthPeelingPass). The
+ * mapper does not use these values by default, instead it uses the number of
+ * steps defined by g_terminatePointMax.
+ */
+vec4 castRay(const float zStart, const float zEnd)
+{
+ //VTK::DepthPeeling::Ray::Init
+
+ //VTK::DepthPeeling::Ray::PathCheck
+
+ //VTK::Shading::Init
+
+ /// For all samples along the ray
+ while (!g_exit)
+ {
+
+ g_skip = false;
+
+ //VTK::Cropping::Impl
+
+ //VTK::Clipping::Impl
+
+ //VTK::BinaryMask::Impl
+
+ //VTK::CompositeMask::Impl
+
+
+ if (!g_skip)
+ {
+ vec4 scalar = texture3D(in_volume, g_dataPos);
+ scalar.r = scalar.r*in_volume_scale.r + in_volume_bias.r;
+ scalar = vec4(scalar.r,scalar.r,scalar.r,scalar.r);
+ g_srcColor = vec4(0.0);
+ g_srcColor.a = computeOpacity(scalar);
+ if (g_srcColor.a > 0.0)
+ {
+ g_srcColor = computeColor(scalar, g_srcColor.a);
+ // Opacity calculation using compositing:
+ // Here we use front to back compositing scheme whereby
+ // the current sample value is multiplied to the
+ // currently accumulated alpha and then this product
+ // is subtracted from the sample value to get the
+ // alpha from the previous steps. Next, this alpha is
+ // multiplied with the current sample colour
+ // and accumulated to the composited colour. The alpha
+ // value from the previous steps is then accumulated
+ // to the composited colour alpha.
+ g_srcColor.rgb *= g_srcColor.a;
+ g_fragColor = (1.0f - g_fragColor.a) * g_srcColor + g_fragColor;
+ }
+ }
+
+ //VTK::RenderToImage::Impl
+
+ //VTK::DepthPass::Impl
+
+ /// Advance ray
+ g_dataPos += g_dirStep;
+
+
+ if(any(greaterThan(g_dataPos, in_texMax)) ||
+ any(lessThan(g_dataPos, in_texMin)))
+ {
+ break;
+ }
+
+ // Early ray termination
+ // if the currently composited colour alpha is already fully saturated
+ // we terminated the loop or if we have hit an obstacle in the
+ // direction of they ray (using depth buffer) we terminate as well.
+ if((g_fragColor.a > g_opacityThreshold) ||
+ g_currentT >= g_terminatePointMax)
+ {
+ break;
+ }
+ ++g_currentT;
+ }
+
+ //VTK::Shading::Exit
+
+ return g_fragColor;
+}
+
+/**
+ * Finalize specific modes and set output data.
+ */
+void finalizeRayCast()
+{
+ //VTK::Base::Exit
+
+ //VTK::Terminate::Exit
+
+ //VTK::Cropping::Exit
+
+ //VTK::Clipping::Exit
+
+ //VTK::Picking::Exit
+
+ g_fragColor.r = g_fragColor.r * in_scale + in_bias * g_fragColor.a;
+ g_fragColor.g = g_fragColor.g * in_scale + in_bias * g_fragColor.a;
+ g_fragColor.b = g_fragColor.b * in_scale + in_bias * g_fragColor.a;
+ fragOutput0 = g_fragColor;
+
+ //VTK::RenderToImage::Exit
+
+ //VTK::DepthPass::Exit
+}
+
+//////////////////////////////////////////////////////////////////////////////
+///
+/// Main
+///
+//////////////////////////////////////////////////////////////////////////////
+void main()
+{
+
+ initializeRayCast();
+ castRay(-1.0, -1.0);
+ finalizeRayCast();
+}
+
+
diff --git a/shaders/pts/paraview-1.0.3/wavelet-volume/9.shader_test b/shaders/pts/paraview-1.0.3/wavelet-volume/9.shader_test
new file mode 100644
index 0000000..d328dc9
--- /dev/null
+++ b/shaders/pts/paraview-1.0.3/wavelet-volume/9.shader_test
@@ -0,0 +1,240 @@
+[require]
+GLSL >= 1.50
+
+[vertex shader]
+#version 150
+#ifdef GL_ES
+#if __VERSION__ == 300
+#define attribute in
+#define varying out
+#endif // 300
+#else // GL_ES
+#define highp
+#define mediump
+#define lowp
+#if __VERSION__ == 150
+#define attribute in
+#define varying out
+#endif
+#endif // GL_ES
+
+
+/*=========================================================================
+
+ Program: Visualization Toolkit
+ Module: vtkPolyDataVS.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.
+
+=========================================================================*/
+
+attribute vec4 vertexMC;
+
+// frag position in VC
+//VTK::PositionVC::Dec
+
+// optional normal declaration
+//VTK::Normal::Dec
+
+// extra lighting parameters
+//VTK::Light::Dec
+
+// Texture coordinates
+//VTK::TCoord::Dec
+
+// material property values
+//VTK::Color::Dec
+
+// clipping plane vars
+//VTK::Clip::Dec
+
+// camera and actor matrix values
+uniform mat4 MCDCMatrix;
+
+// Apple Bug
+//VTK::PrimID::Dec
+
+// Value raster
+//VTK::ValuePass::Dec
+
+void main()
+{
+ //VTK::Color::Impl
+
+ //VTK::Normal::Impl
+
+ //VTK::TCoord::Impl
+
+ //VTK::Clip::Impl
+
+ //VTK::PrimID::Impl
+
+ gl_Position = MCDCMatrix * vertexMC;
+
+
+ //VTK::ValuePass::Impl
+
+ //VTK::Light::Impl
+}
+
+
+[fragment shader]
+#version 150
+#ifdef GL_ES
+#if __VERSION__ == 300
+#define varying in
+#ifdef GL_FRAGMENT_PRECISION_HIGH
+precision highp float;
+precision highp sampler2D;
+precision highp sampler3D;
+#else
+precision mediump float;
+precision mediump sampler2D;
+precision mediump sampler3D;
+#endif
+#define texelFetchBuffer texelFetch
+#define texture1D texture
+#define texture2D texture
+#define texture3D texture
+#endif // 300
+#if __VERSION__ == 100
+#extension GL_OES_standard_derivatives : enable
+#ifdef GL_FRAGMENT_PRECISION_HIGH
+precision highp float;
+#else
+precision mediump float;
+#endif
+#endif // 100
+#else // GL_ES
+#define highp
+#define mediump
+#define lowp
+#if __VERSION__ == 150
+#define varying in
+#define texelFetchBuffer texelFetch
+#define texture1D texture
+#define texture2D texture
+#define texture3D texture
+#endif
+#if __VERSION__ == 120
+#extension GL_EXT_gpu_shader4 : require
+#endif
+#endif // GL_ES
+
+
+/*=========================================================================
+
+ Program: Visualization Toolkit
+ Module: vtkPolyDataFS.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.
+
+=========================================================================*/
+// Template for the polydata mappers fragment shader
+
+uniform int PrimitiveIDOffset;
+
+// VC position of this fragment
+//VTK::PositionVC::Dec
+
+// optional color passed in from the vertex shader, vertexColor
+uniform float opacityUniform; // the fragment opacity
+uniform vec3 ambientColorUniform; // intensity weighted color
+uniform vec3 diffuseColorUniform; // intensity weighted color
+
+
+// optional surface normal declaration
+//VTK::Normal::Dec
+
+// extra lighting parameters
+//VTK::Light::Dec
+
+// Texture coordinates
+//VTK::TCoord::Dec
+
+// picking support
+//VTK::Picking::Dec
+
+// Depth Peeling Support
+//VTK::DepthPeeling::Dec
+
+// clipping plane vars
+//VTK::Clip::Dec
+
+// the output of this shader
+out vec4 fragOutput0;
+
+
+// Apple Bug
+//VTK::PrimID::Dec
+
+// handle coincident offsets
+//VTK::Coincident::Dec
+
+// Value raster
+//VTK::ValuePass::Dec
+
+void main()
+{
+ // VC position of this fragment. This should not branch/return/discard.
+ //VTK::PositionVC::Impl
+
+ // Place any calls that require uniform flow (e.g. dFdx) here.
+ //VTK::UniformFlow::Impl
+
+ // Set gl_FragDepth here (gl_FragCoord.z by default)
+ //VTK::Depth::Impl
+
+ // Early depth peeling abort:
+ //VTK::DepthPeeling::PreColor
+
+ // Apple Bug
+ //VTK::PrimID::Impl
+
+ //VTK::Clip::Impl
+
+ //VTK::ValuePass::Impl
+
+ vec3 ambientColor;
+ vec3 diffuseColor;
+ float opacity;
+ ambientColor = ambientColorUniform;
+ diffuseColor = diffuseColorUniform;
+ opacity = opacityUniform;
+
+
+ // Generate the normal if we are not passed in one
+ //VTK::Normal::Impl
+
+ fragOutput0 = vec4(ambientColor + diffuseColor, opacity);
+ //VTK::Light::Impl
+
+
+ //VTK::TCoord::Impl
+
+ if (fragOutput0.a <= 0.0)
+ {
+ discard;
+ }
+
+ //VTK::DepthPeeling::Impl
+
+ //VTK::Picking::Impl
+
+ // handle coincident offsets
+ //VTK::Coincident::Impl
+}
+
+