1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkFXAAOptions.h 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 16 /** 17 * @class vtkFXAAOptions 18 * @brief Configuration for FXAA implementations. 19 * 20 * 21 * This class encapsulates the settings for vtkOpenGLFXAAFilter. 22 */ 23 24 #ifndef vtkFXAAOptions_h 25 #define vtkFXAAOptions_h 26 27 #include "vtkObject.h" 28 #include "vtkRenderingCoreModule.h" // For export macro 29 30 class VTKRENDERINGCORE_EXPORT vtkFXAAOptions : public vtkObject 31 { 32 public: 33 /** 34 * Debugging options that affect the output color buffer. See 35 * vtkFXAAFilterFS.glsl for details. 36 */ 37 enum DebugOption 38 { 39 FXAA_NO_DEBUG = 0, 40 FXAA_DEBUG_SUBPIXEL_ALIASING, 41 FXAA_DEBUG_EDGE_DIRECTION, 42 FXAA_DEBUG_EDGE_NUM_STEPS, 43 FXAA_DEBUG_EDGE_DISTANCE, 44 FXAA_DEBUG_EDGE_SAMPLE_OFFSET, 45 FXAA_DEBUG_ONLY_SUBPIX_AA, 46 FXAA_DEBUG_ONLY_EDGE_AA 47 }; 48 49 static vtkFXAAOptions* New(); 50 vtkTypeMacro(vtkFXAAOptions, vtkObject); 51 void PrintSelf(ostream& os, vtkIndent indent) override; 52 53 ///@{ 54 /** 55 * Threshold for applying FXAA to a pixel, relative to the maximum luminosity 56 * of its 4 immediate neighbors. 57 58 * The luminosity of the current pixel and it's NSWE neighbors is computed. 59 * The maximum luminosity and luminosity range (contrast) of all 5 pixels is 60 * found. If the contrast is less than RelativeContrastThreshold * maxLum, 61 * the pixel is not considered aliased and will not be affected by FXAA. 62 63 * Suggested settings: 64 * - 1/3: Too little 65 * - 1/4: Low quality 66 * - 1/8: High quality (default) 67 * - 1/16: Overkill 68 */ 69 vtkSetClampMacro(RelativeContrastThreshold, float, 0.f, 1.f); 70 vtkGetMacro(RelativeContrastThreshold, float); 71 ///@} 72 73 ///@{ 74 /** 75 * Similar to RelativeContrastThreshold, but not scaled by the maximum 76 * luminosity. 77 78 * If the contrast of the current pixel and it's 4 immediate NSWE neighbors is 79 * less than HardContrastThreshold, the pixel is not considered aliased and 80 * will not be affected by FXAA. 81 82 * Suggested settings: 83 * - 1/32: Visible limit 84 * - 1/16: High quality (default) 85 * - 1/12: Upper limit (start of visible unfiltered edges) 86 */ 87 vtkSetClampMacro(HardContrastThreshold, float, 0.f, 1.f); 88 vtkGetMacro(HardContrastThreshold, float); 89 ///@} 90 91 ///@{ 92 /** 93 * Subpixel aliasing is corrected by applying a lowpass filter to the current 94 * pixel. This is implemented by blending an average of the 3x3 neighborhood 95 * around the pixel into the final result. The amount of blending is 96 * determined by comparing the detected amount of subpixel aliasing to the 97 * total contrasting of the CNSWE pixels: 98 99 * SubpixelBlending = abs(lumC - lumAveNSWE) / (lumMaxCNSWE - lumMinCNSWE) 100 101 * This parameter sets an upper limit to the amount of subpixel blending to 102 * prevent the image from simply getting blurred. 103 104 * Suggested settings: 105 * - 1/2: Low amount of blending. 106 * - 3/4: Medium amount of blending (default) 107 * - 7/8: High amount of blending. 108 * - 1: Maximum amount of blending. 109 */ 110 vtkSetClampMacro(SubpixelBlendLimit, float, 0.f, 1.f); 111 vtkGetMacro(SubpixelBlendLimit, float); 112 ///@} 113 114 ///@{ 115 /** 116 * Minimum amount of subpixel aliasing required for subpixel antialiasing to 117 * be applied. 118 119 * Subpixel aliasing is corrected by applying a lowpass filter to the current 120 * pixel. This is implemented by blending an average of the 3x3 neighborhood 121 * around the pixel into the final result. The amount of blending is 122 * determined by comparing the detected amount of subpixel aliasing to the 123 * total contrasting of the CNSWE pixels: 124 125 * SubpixelBlending = abs(lumC - lumAveNSWE) / (lumMaxCNSWE - lumMinCNSWE) 126 127 * If SubpixelBlending is less than this threshold, no lowpass blending will 128 * occur. 129 130 * Suggested settings: 131 * - 1/2: Low subpixel aliasing removal 132 * - 1/3: Medium subpixel aliasing removal 133 * - 1/4: Default subpixel aliasing removal 134 * - 1/8: High subpixel aliasing removal 135 * - 0: Complete subpixel aliasing removal 136 */ 137 vtkSetClampMacro(SubpixelContrastThreshold, float, 0.f, 1.f); 138 vtkGetMacro(SubpixelContrastThreshold, float); 139 ///@} 140 141 ///@{ 142 /** 143 * Use an improved edge endpoint detection algorithm. 144 145 * If true, a modified edge endpoint detection algorithm is used that requires 146 * more texture lookups, but will properly detect aliased single-pixel lines. 147 148 * If false, the edge endpoint algorithm proposed by NVIDIA will by used. This 149 * algorithm is faster (fewer lookups), but will fail to detect endpoints of 150 * single pixel edge steps. 151 152 * Default setting is true. 153 */ 154 vtkSetMacro(UseHighQualityEndpoints, bool); 155 vtkGetMacro(UseHighQualityEndpoints, bool); 156 vtkBooleanMacro(UseHighQualityEndpoints, bool); 157 ///@} 158 159 ///@{ 160 /** 161 * Set the number of iterations for the endpoint search algorithm. Increasing 162 * this value will increase runtime, but also properly detect longer edges. 163 * The current implementation steps one pixel in both the positive and 164 * negative directions per iteration. The default value is 12, which will 165 * resolve endpoints of edges < 25 pixels long (2 * 12 + 1). 166 */ 167 vtkSetClampMacro(EndpointSearchIterations, int, 0, VTK_INT_MAX); 168 vtkGetMacro(EndpointSearchIterations, int); 169 ///@} 170 171 ///@{ 172 /** 173 * Debugging options that affect the output color buffer. See 174 * vtkFXAAFilterFS.glsl for details. Only one may be active at a time. 175 */ 176 vtkSetMacro(DebugOptionValue, DebugOption); 177 vtkGetMacro(DebugOptionValue, DebugOption); 178 ///@} 179 180 protected: 181 vtkFXAAOptions(); 182 ~vtkFXAAOptions() override; 183 184 float RelativeContrastThreshold; 185 float HardContrastThreshold; 186 float SubpixelBlendLimit; 187 float SubpixelContrastThreshold; 188 int EndpointSearchIterations; 189 bool UseHighQualityEndpoints; 190 DebugOption DebugOptionValue; 191 192 private: 193 vtkFXAAOptions(const vtkFXAAOptions&) = delete; 194 void operator=(const vtkFXAAOptions&) = delete; 195 }; 196 197 #endif // vtkFXAAOptions_h 198