├── .gitignore
├── License.txt
├── Package.swift
├── README.md
├── examples
├── Linux-OpenGL
│ ├── ImageFilterNotebook.ipynb
│ ├── SimpleImageFilter
│ │ ├── .gitignore
│ │ ├── Package.swift
│ │ └── Sources
│ │ │ └── main.swift
│ └── SimpleVideoFilter
│ │ ├── .gitignore
│ │ ├── Package.swift
│ │ └── Sources
│ │ └── main.swift
├── Linux-RPi
│ └── SimpleVideoFilter
│ │ ├── Source
│ │ └── main.swift
│ │ └── compile.sh
├── Mac
│ ├── FilterShowcase
│ │ ├── FilterShowcase.xcodeproj
│ │ │ └── project.pbxproj
│ │ └── FilterShowcase
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Base.lproj
│ │ │ └── MainMenu.xib
│ │ │ ├── FilterOperationTypes.swift
│ │ │ ├── FilterOperations.swift
│ │ │ ├── FilterShowcaseWindowController.swift
│ │ │ ├── FilterShowcaseWindowController.xib
│ │ │ └── Info.plist
│ ├── SimpleImageFilter
│ │ ├── SimpleImageFilter.xcodeproj
│ │ │ └── project.pbxproj
│ │ └── SimpleImageFilter
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Base.lproj
│ │ │ └── MainMenu.xib
│ │ │ └── Info.plist
│ ├── SimpleMovieFilter
│ │ ├── SimpleMovieFilter.xcodeproj
│ │ │ └── project.pbxproj
│ │ └── SimpleMovieFilter
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Base.lproj
│ │ │ └── MainMenu.xib
│ │ │ └── Info.plist
│ ├── SimpleVideoFilter
│ │ ├── SimpleVideoFilter.xcodeproj
│ │ │ └── project.pbxproj
│ │ └── SimpleVideoFilter
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Base.lproj
│ │ │ └── MainMenu.xib
│ │ │ └── Info.plist
│ └── SimpleVideoRecorder
│ │ ├── SimpleVideoRecorder.xcodeproj
│ │ └── project.pbxproj
│ │ └── SimpleVideoRecorder
│ │ ├── AppDelegate.swift
│ │ ├── Base.lproj
│ │ └── MainMenu.xib
│ │ └── Info.plist
├── SharedAssets
│ ├── Assets-iOS.xcassets
│ │ └── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── Icon-120.png
│ │ │ ├── Icon-121.png
│ │ │ ├── Icon-152.png
│ │ │ ├── Icon-167.png
│ │ │ ├── Icon-180.png
│ │ │ ├── Icon-40.png
│ │ │ ├── Icon-58.png
│ │ │ ├── Icon-76.png
│ │ │ ├── Icon-80.png
│ │ │ ├── Icon-81.png
│ │ │ ├── Icon-87.png
│ │ │ ├── Icon-Small-1.png
│ │ │ └── Icon-Small@2x-1.png
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── GPUImageLogo-128.png
│ │ │ ├── GPUImageLogo-16.png
│ │ │ ├── GPUImageLogo-256.png
│ │ │ ├── GPUImageLogo-257.png
│ │ │ ├── GPUImageLogo-32.png
│ │ │ ├── GPUImageLogo-33.png
│ │ │ ├── GPUImageLogo-64.png
│ │ │ ├── iTunesArtwork-1.png
│ │ │ └── iTunesArtwork.png
│ ├── Lambeau.jpg
│ ├── Mask.png
│ ├── WID-small.jpg
│ └── sample_iPod.m4v
└── iOS
│ ├── FilterShowcase
│ ├── FilterShowcase.xcodeproj
│ │ └── project.pbxproj
│ └── FilterShowcaseSwift
│ │ ├── AppDelegate.swift
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── FilterDisplayViewController.swift
│ │ ├── FilterListViewController.swift
│ │ └── Info.plist
│ ├── SimpleImageFilter
│ ├── SimpleImageFilter.xcodeproj
│ │ └── project.pbxproj
│ └── SimpleImageFilter
│ │ ├── AppDelegate.swift
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── ViewController.swift
│ ├── SimpleMovieFilter
│ ├── SimpleMovieFilter.xcodeproj
│ │ └── project.pbxproj
│ └── SimpleMovieFilter
│ │ ├── AppDelegate.swift
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── ViewController.swift
│ ├── SimpleVideoFilter
│ ├── SimpleVideoFilter.xcodeproj
│ │ └── project.pbxproj
│ └── SimpleVideoFilter
│ │ ├── AppDelegate.swift
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── ViewController.swift
│ └── SimpleVideoRecorder
│ ├── SimpleVideoRecorder.xcodeproj
│ └── project.pbxproj
│ └── SimpleVideoRecorder
│ ├── AppDelegate.swift
│ ├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
│ ├── Info.plist
│ └── ViewController.swift
└── framework
├── GPUImage.xcodeproj
├── GPUImageTestSuite_Info.plist
├── GPUImage_Info.plist
└── project.pbxproj
├── Packages
├── CFreeGLUT
│ ├── Package.swift
│ ├── README.md
│ └── module.modulemap
├── COpenGL
│ ├── Package.swift
│ ├── module.modulemap
│ └── proto.h
├── COpenGLES
│ ├── Package.swift
│ └── module.modulemap
├── CVideo4Linux
│ ├── Package.swift
│ ├── module.modulemap
│ └── stubs.h
├── CVideoCore
│ ├── Package.swift
│ └── module.modulemap
└── lodepng
│ ├── include
│ └── lodepng.h
│ └── lodepng.cpp
├── Source
├── Apple
│ ├── Camera.swift
│ ├── MovieInput.swift
│ ├── MovieOutput.swift
│ ├── OpenGLContext-OpenGL.swift
│ ├── OpenGLContext-OpenGLES.swift
│ ├── PictureInput.swift
│ ├── PictureOutput.swift
│ ├── RenderView-Cocoa.swift
│ └── RenderView-UIKit.swift
├── BasicOperation.swift
├── CameraConversion.swift
├── Color.swift
├── FillMode.swift
├── Framebuffer.swift
├── FramebufferCache.swift
├── ImageGenerator.swift
├── ImageOrientation.swift
├── Linux
│ ├── GLUTRenderWindow.swift
│ ├── OpenGLContext-RPi.swift
│ ├── OpenGLContext.swift
│ ├── PictureInput.swift
│ ├── PictureOutput.swift
│ ├── RPiRenderWindow.swift
│ ├── V4LCamera
│ │ └── V4LCamera.swift
│ └── V4LSupplement
│ │ ├── include
│ │ └── v4lfuncs.h
│ │ └── v4lfuncs.c
├── Matrix.swift
├── OpenGLContext_Shared.swift
├── OpenGLRendering.swift
├── OperationGroup.swift
├── Operations
│ ├── AdaptiveThreshold.swift
│ ├── AddBlend.swift
│ ├── AlphaBlend.swift
│ ├── AmatorkaFilter.swift
│ ├── AverageColorExtractor.swift
│ ├── AverageLuminanceExtractor.swift
│ ├── AverageLuminanceThreshold.swift
│ ├── BilateralBlur.swift
│ ├── BoxBlur.swift
│ ├── BrightnessAdjustment.swift
│ ├── BulgeDistortion.swift
│ ├── CGAColorspaceFilter.swift
│ ├── CannyEdgeDetection.swift
│ ├── ChromaKeyBlend.swift
│ ├── ChromaKeying.swift
│ ├── CircleGenerator.swift
│ ├── ClosingFilter.swift
│ ├── ColorBlend.swift
│ ├── ColorBurnBlend.swift
│ ├── ColorDodgeBlend.swift
│ ├── ColorInversion.swift
│ ├── ColorLocalBinaryPattern.swift
│ ├── ColorMatrixFilter.swift
│ ├── ColourFASTFeatureDetection.swift
│ ├── ContrastAdjustment.swift
│ ├── ConvertedShaders_GL.swift
│ ├── ConvertedShaders_GLES.swift
│ ├── Convolution3x3.swift
│ ├── Crop.swift
│ ├── CrosshairGenerator.swift
│ ├── Crosshatch.swift
│ ├── DarkenBlend.swift
│ ├── DifferenceBlend.swift
│ ├── Dilation.swift
│ ├── DissolveBlend.swift
│ ├── DivideBlend.swift
│ ├── EmbossFilter.swift
│ ├── Erosion.swift
│ ├── ExclusionBlend.swift
│ ├── ExposureAdjustment.swift
│ ├── FalseColor.swift
│ ├── GammaAdjustment.swift
│ ├── GaussianBlur.swift
│ ├── GlassSphereRefraction.swift
│ ├── Halftone.swift
│ ├── HardLightBlend.swift
│ ├── HarrisCornerDetector.swift
│ ├── Haze.swift
│ ├── HighPassFilter.swift
│ ├── HighlightAndShadowTint.swift
│ ├── HighlightsAndShadows.swift
│ ├── Histogram.swift
│ ├── HistogramDisplay.swift
│ ├── HistogramEqualization.swift
│ ├── HueAdjustment.swift
│ ├── HueBlend.swift
│ ├── ImageBuffer.swift
│ ├── KuwaharaFilter.swift
│ ├── KuwaharaRadius3Filter.swift
│ ├── LanczosResampling.swift
│ ├── Laplacian.swift
│ ├── LevelsAdjustment.swift
│ ├── LightenBlend.swift
│ ├── LineGenerator.swift
│ ├── LinearBurnBlend.swift
│ ├── LocalBinaryPattern.swift
│ ├── LookupFilter.swift
│ ├── LookupImages
│ │ ├── lookup.png
│ │ ├── lookup_amatorka.png
│ │ ├── lookup_miss_etikate.png
│ │ ├── lookup_soft_elegance_1.png
│ │ └── lookup_soft_elegance_2.png
│ ├── LowPassFilter.swift
│ ├── Luminance.swift
│ ├── LuminanceRangeReduction.swift
│ ├── LuminanceThreshold.swift
│ ├── LuminosityBlend.swift
│ ├── MedianFilter.swift
│ ├── MissEtikateFilter.swift
│ ├── MonochromeFilter.swift
│ ├── MotionBlur.swift
│ ├── MotionDetector.swift
│ ├── MultiplyBlend.swift
│ ├── NobleCornerDetector.swift
│ ├── NormalBlend.swift
│ ├── OpacityAdjustment.swift
│ ├── OpeningFilter.swift
│ ├── OverlayBlend.swift
│ ├── PinchDistortion.swift
│ ├── Pixellate.swift
│ ├── PolarPixellate.swift
│ ├── PolkaDot.swift
│ ├── Posterize.swift
│ ├── PrewittEdgeDetection.swift
│ ├── RGBAdjustmentFilter.swift
│ ├── SaturationAdjustment.swift
│ ├── SaturationBlend.swift
│ ├── ScreenBlend.swift
│ ├── SepiaToneFilter.swift
│ ├── Shaders
│ │ ├── AdaptiveThreshold_GL.fsh
│ │ ├── AdaptiveThreshold_GLES.fsh
│ │ ├── AddBlend_GL.fsh
│ │ ├── AddBlend_GLES.fsh
│ │ ├── AlphaBlend_GL.fsh
│ │ ├── AlphaBlend_GLES.fsh
│ │ ├── AlphaTest_GL.fsh
│ │ ├── AlphaTest_GLES.fsh
│ │ ├── AverageColor.vsh
│ │ ├── AverageColor_GL.fsh
│ │ ├── AverageColor_GLES.fsh
│ │ ├── AverageLuminance_GL.fsh
│ │ ├── AverageLuminance_GLES.fsh
│ │ ├── BilateralBlur.vsh
│ │ ├── BilateralBlur_GL.fsh
│ │ ├── BilateralBlur_GLES.fsh
│ │ ├── Brightness_GL.fsh
│ │ ├── Brightness_GLES.fsh
│ │ ├── BulgeDistortion_GL.fsh
│ │ ├── BulgeDistortion_GLES.fsh
│ │ ├── CGAColorspace_GL.fsh
│ │ ├── CGAColorspace_GLES.fsh
│ │ ├── ChromaKeyBlend_GL.fsh
│ │ ├── ChromaKeyBlend_GLES.fsh
│ │ ├── ChromaKey_GL.fsh
│ │ ├── ChromaKey_GLES.fsh
│ │ ├── Circle.vsh
│ │ ├── Circle_GL.fsh
│ │ ├── Circle_GLES.fsh
│ │ ├── ColorBlend_GL.fsh
│ │ ├── ColorBlend_GLES.fsh
│ │ ├── ColorBurnBlend_GL.fsh
│ │ ├── ColorBurnBlend_GLES.fsh
│ │ ├── ColorDodgeBlend_GL.fsh
│ │ ├── ColorDodgeBlend_GLES.fsh
│ │ ├── ColorInvert_GL.fsh
│ │ ├── ColorInvert_GLES.fsh
│ │ ├── ColorLocalBinaryPattern_GL.fsh
│ │ ├── ColorLocalBinaryPattern_GLES.fsh
│ │ ├── ColorMatrix_GL.fsh
│ │ ├── ColorMatrix_GLES.fsh
│ │ ├── ColorSwizzling_GL.fsh
│ │ ├── ColorSwizzling_GLES.fsh
│ │ ├── ColourFASTDecriptor.vsh
│ │ ├── ColourFASTDecriptor_GL.fsh
│ │ ├── ColourFASTDecriptor_GLES.fsh
│ │ ├── Contrast_GL.fsh
│ │ ├── Contrast_GLES.fsh
│ │ ├── Convolution3x3_GL.fsh
│ │ ├── Convolution3x3_GLES.fsh
│ │ ├── Crosshair.vsh
│ │ ├── Crosshair_GL.fsh
│ │ ├── Crosshair_GLES.fsh
│ │ ├── Crosshatch_GL.fsh
│ │ ├── Crosshatch_GLES.fsh
│ │ ├── DarkenBlend_GL.fsh
│ │ ├── DarkenBlend_GLES.fsh
│ │ ├── DifferenceBlend_GL.fsh
│ │ ├── DifferenceBlend_GLES.fsh
│ │ ├── Dilation1_GL.fsh
│ │ ├── Dilation1_GLES.fsh
│ │ ├── Dilation2_GL.fsh
│ │ ├── Dilation2_GLES.fsh
│ │ ├── Dilation3_GL.fsh
│ │ ├── Dilation3_GLES.fsh
│ │ ├── Dilation4_GL.fsh
│ │ ├── Dilation4_GLES.fsh
│ │ ├── DirectionalNonMaximumSuppression_GL.fsh
│ │ ├── DirectionalNonMaximumSuppression_GLES.fsh
│ │ ├── DirectionalSobelEdgeDetection_GL.fsh
│ │ ├── DirectionalSobelEdgeDetection_GLES.fsh
│ │ ├── DissolveBlend_GL.fsh
│ │ ├── DissolveBlend_GLES.fsh
│ │ ├── DivideBlend_GL.fsh
│ │ ├── DivideBlend_GLES.fsh
│ │ ├── Erosion1_GL.fsh
│ │ ├── Erosion1_GLES.fsh
│ │ ├── Erosion2_GL.fsh
│ │ ├── Erosion2_GLES.fsh
│ │ ├── Erosion3_GL.fsh
│ │ ├── Erosion3_GLES.fsh
│ │ ├── Erosion4_GL.fsh
│ │ ├── Erosion4_GLES.fsh
│ │ ├── ErosionDilation1.vsh
│ │ ├── ErosionDilation2.vsh
│ │ ├── ErosionDilation3.vsh
│ │ ├── ErosionDilation4.vsh
│ │ ├── ExclusionBlend_GL.fsh
│ │ ├── ExclusionBlend_GLES.fsh
│ │ ├── Exposure_GL.fsh
│ │ ├── Exposure_GLES.fsh
│ │ ├── FalseColor_GL.fsh
│ │ ├── FalseColor_GLES.fsh
│ │ ├── FiveInput.vsh
│ │ ├── FourInput.vsh
│ │ ├── Gamma_GL.fsh
│ │ ├── Gamma_GLES.fsh
│ │ ├── GlassSphere_GL.fsh
│ │ ├── GlassSphere_GLES.fsh
│ │ ├── Halftone_GL.fsh
│ │ ├── Halftone_GLES.fsh
│ │ ├── HardLightBlend_GL.fsh
│ │ ├── HardLightBlend_GLES.fsh
│ │ ├── HarrisCornerDetector_GL.fsh
│ │ ├── HarrisCornerDetector_GLES.fsh
│ │ ├── Haze_GL.fsh
│ │ ├── Haze_GLES.fsh
│ │ ├── HighlightShadowTint_GL.fsh
│ │ ├── HighlightShadowTint_GLES.fsh
│ │ ├── HighlightShadow_GL.fsh
│ │ ├── HighlightShadow_GLES.fsh
│ │ ├── HistogramAccumulation_GL.fsh
│ │ ├── HistogramAccumulation_GLES.fsh
│ │ ├── HistogramBlueSampling.vsh
│ │ ├── HistogramDisplay.vsh
│ │ ├── HistogramDisplay_GL.fsh
│ │ ├── HistogramDisplay_GLES.fsh
│ │ ├── HistogramEqualizationBlue_GL.fsh
│ │ ├── HistogramEqualizationBlue_GLES.fsh
│ │ ├── HistogramEqualizationGreen_GL.fsh
│ │ ├── HistogramEqualizationGreen_GLES.fsh
│ │ ├── HistogramEqualizationLuminance_GL.fsh
│ │ ├── HistogramEqualizationLuminance_GLES.fsh
│ │ ├── HistogramEqualizationRGB_GL.fsh
│ │ ├── HistogramEqualizationRGB_GLES.fsh
│ │ ├── HistogramEqualizationRed_GL.fsh
│ │ ├── HistogramEqualizationRed_GLES.fsh
│ │ ├── HistogramGreenSampling.vsh
│ │ ├── HistogramLuminanceSampling.vsh
│ │ ├── HistogramRedSampling.vsh
│ │ ├── HueBlend_GL.fsh
│ │ ├── HueBlend_GLES.fsh
│ │ ├── Hue_GL.fsh
│ │ ├── Hue_GLES.fsh
│ │ ├── KuwaharaRadius3_GL.fsh
│ │ ├── KuwaharaRadius3_GLES.fsh
│ │ ├── Kuwahara_GL.fsh
│ │ ├── Kuwahara_GLES.fsh
│ │ ├── LanczosResampling.vsh
│ │ ├── LanczosResampling_GL.fsh
│ │ ├── LanczosResampling_GLES.fsh
│ │ ├── Laplacian_GL.fsh
│ │ ├── Laplacian_GLES.fsh
│ │ ├── Levels_GL.fsh
│ │ ├── Levels_GLES.fsh
│ │ ├── LightenBlend_GL.fsh
│ │ ├── LightenBlend_GLES.fsh
│ │ ├── Line.vsh
│ │ ├── Line_GL.fsh
│ │ ├── Line_GLES.fsh
│ │ ├── LinearBurnBlend_GL.fsh
│ │ ├── LinearBurnBlend_GLES.fsh
│ │ ├── LocalBinaryPattern_GL.fsh
│ │ ├── LocalBinaryPattern_GLES.fsh
│ │ ├── Lookup_GL.fsh
│ │ ├── Lookup_GLES.fsh
│ │ ├── LuminanceRange_GL.fsh
│ │ ├── LuminanceRange_GLES.fsh
│ │ ├── LuminanceThreshold_GL.fsh
│ │ ├── LuminanceThreshold_GLES.fsh
│ │ ├── Luminance_GL.fsh
│ │ ├── Luminance_GLES.fsh
│ │ ├── LuminosityBlend_GL.fsh
│ │ ├── LuminosityBlend_GLES.fsh
│ │ ├── Median_GL.fsh
│ │ ├── Median_GLES.fsh
│ │ ├── Monochrome_GL.fsh
│ │ ├── Monochrome_GLES.fsh
│ │ ├── MotionBlur.vsh
│ │ ├── MotionBlur_GL.fsh
│ │ ├── MotionBlur_GLES.fsh
│ │ ├── MotionComparison_GL.fsh
│ │ ├── MotionComparison_GLES.fsh
│ │ ├── MultiplyBlend_GL.fsh
│ │ ├── MultiplyBlend_GLES.fsh
│ │ ├── NearbyTexelSampling.vsh
│ │ ├── NobleCornerDetector_GL.fsh
│ │ ├── NobleCornerDetector_GLES.fsh
│ │ ├── NormalBlend_GL.fsh
│ │ ├── NormalBlend_GLES.fsh
│ │ ├── OneInput.vsh
│ │ ├── Opacity_GL.fsh
│ │ ├── Opacity_GLES.fsh
│ │ ├── OverlayBlend_GL.fsh
│ │ ├── OverlayBlend_GLES.fsh
│ │ ├── Passthrough_GL.fsh
│ │ ├── Passthrough_GLES.fsh
│ │ ├── PinchDistortion_GL.fsh
│ │ ├── PinchDistortion_GLES.fsh
│ │ ├── Pixellate_GL.fsh
│ │ ├── Pixellate_GLES.fsh
│ │ ├── PolarPixellate_GL.fsh
│ │ ├── PolarPixellate_GLES.fsh
│ │ ├── PolkaDot_GL.fsh
│ │ ├── PolkaDot_GLES.fsh
│ │ ├── Posterize_GL.fsh
│ │ ├── Posterize_GLES.fsh
│ │ ├── PrewittEdgeDetection_GL.fsh
│ │ ├── PrewittEdgeDetection_GLES.fsh
│ │ ├── RGBAdjustment_GL.fsh
│ │ ├── RGBAdjustment_GLES.fsh
│ │ ├── SaturationBlend_GL.fsh
│ │ ├── SaturationBlend_GLES.fsh
│ │ ├── Saturation_GL.fsh
│ │ ├── Saturation_GLES.fsh
│ │ ├── ScreenBlend_GL.fsh
│ │ ├── ScreenBlend_GLES.fsh
│ │ ├── ShaderConverter.sh
│ │ ├── Sharpen.vsh
│ │ ├── Sharpen_GL.fsh
│ │ ├── Sharpen_GLES.fsh
│ │ ├── ShiTomasiFeatureDetector_GL.fsh
│ │ ├── ShiTomasiFeatureDetector_GLES.fsh
│ │ ├── Sketch_GL.fsh
│ │ ├── Sketch_GLES.fsh
│ │ ├── SobelEdgeDetection_GL.fsh
│ │ ├── SobelEdgeDetection_GLES.fsh
│ │ ├── SoftLightBlend_GL.fsh
│ │ ├── SoftLightBlend_GLES.fsh
│ │ ├── Solarize_GL.fsh
│ │ ├── Solarize_GLES.fsh
│ │ ├── SourceOverBlend_GL.fsh
│ │ ├── SourceOverBlend_GLES.fsh
│ │ ├── SphereRefraction_GL.fsh
│ │ ├── SphereRefraction_GLES.fsh
│ │ ├── StretchDistortion_GL.fsh
│ │ ├── StretchDistortion_GLES.fsh
│ │ ├── SubtractBlend_GL.fsh
│ │ ├── SubtractBlend_GLES.fsh
│ │ ├── Swirl_GL.fsh
│ │ ├── Swirl_GLES.fsh
│ │ ├── ThreeInput.vsh
│ │ ├── ThresholdEdgeDetection_GL.fsh
│ │ ├── ThresholdEdgeDetection_GLES.fsh
│ │ ├── ThresholdSketch_GL.fsh
│ │ ├── ThresholdSketch_GLES.fsh
│ │ ├── ThresholdedNonMaximumSuppression_GL.fsh
│ │ ├── ThresholdedNonMaximumSuppression_GLES.fsh
│ │ ├── TiltShift_GL.fsh
│ │ ├── TiltShift_GLES.fsh
│ │ ├── Toon_GL.fsh
│ │ ├── Toon_GLES.fsh
│ │ ├── Transform.vsh
│ │ ├── TwoInput.vsh
│ │ ├── UnsharpMask_GL.fsh
│ │ ├── UnsharpMask_GLES.fsh
│ │ ├── Vibrance_GL.fsh
│ │ ├── Vibrance_GLES.fsh
│ │ ├── Vignette_GL.fsh
│ │ ├── Vignette_GLES.fsh
│ │ ├── WeakPixelInclusion_GL.fsh
│ │ ├── WeakPixelInclusion_GLES.fsh
│ │ ├── WhiteBalance_GL.fsh
│ │ ├── WhiteBalance_GLES.fsh
│ │ ├── XYDerivative_GL.fsh
│ │ ├── XYDerivative_GLES.fsh
│ │ ├── YUVConversionFullRangeUVPlanar_GL.fsh
│ │ ├── YUVConversionFullRangeUVPlanar_GLES.fsh
│ │ ├── YUVConversionFullRange_GL.fsh
│ │ ├── YUVConversionFullRange_GLES.fsh
│ │ ├── YUVConversionVideoRange_GL.fsh
│ │ ├── YUVConversionVideoRange_GLES.fsh
│ │ ├── ZoomBlur_GL.fsh
│ │ └── ZoomBlur_GLES.fsh
│ ├── Sharpen.swift
│ ├── ShiTomasiFeatureDetector.swift
│ ├── SingleComponentGaussianBlur.swift
│ ├── SketchFilter.swift
│ ├── SmoothToonFilter.swift
│ ├── SobelEdgeDetection.swift
│ ├── SoftElegance.swift
│ ├── SoftLightBlend.swift
│ ├── Solarize.swift
│ ├── SolidColorGenerator.swift
│ ├── SourceOverBlend.swift
│ ├── SphereRefraction.swift
│ ├── StretchDistortion.swift
│ ├── SubtractBlend.swift
│ ├── SwirlDistortion.swift
│ ├── ThresholdSketch.swift
│ ├── ThresholdSobelEdgeDetection.swift
│ ├── TiltShift.swift
│ ├── ToonFilter.swift
│ ├── TransformOperation.swift
│ ├── UnsharpMask.swift
│ ├── Vibrance.swift
│ ├── Vignette.swift
│ ├── WhiteBalance.swift
│ ├── ZoomBlur.swift
│ └── iOSBlur.swift
├── Pipeline.swift
├── Position.swift
├── RawDataInput.swift
├── RawDataOutput.swift
├── SerialDispatch.swift
├── ShaderProgram.swift
├── ShaderUniformSettings.swift
├── Size.swift
├── TextureInput.swift
├── TextureOutput.swift
├── TextureSamplingOperation.swift
├── Timestamp.swift
└── TwoStageOperation.swift
└── Tests
├── Pipeline_Tests.swift
└── ShaderProgram_Tests.swift
/.gitignore:
--------------------------------------------------------------------------------
1 | # Exclude the build directory
2 | build/*
3 | examples/FilterShowcase/build*
4 | examples/Linux-OpenGL/SimpleVideoFilter/.build
5 | examples/Linux-OpenGL/swift-install
6 | examples/Linux-OpenGL/.ipynb_checkpoints
7 | examples/Linux-OpenGL/test.png
8 | .build
9 | .swiftpm
10 | Package.resolved
11 |
12 | # Exclude temp nibs and swap files
13 | *~.nib
14 | *.swp
15 |
16 | # Exclude OS X folder attributes
17 | .DS_Store
18 | .svn
19 |
20 | # Exclude user-specific XCode 3 and 4 files
21 | *.mode1
22 | *.mode1v3
23 | *.mode2v3
24 | *.perspective
25 | *.perspectivev3
26 | *.pbxuser
27 | *.xcworkspace
28 | xcuserdata
29 | .vscode
30 |
31 | # Documentation
32 | documentation/*
33 |
34 | # Carthage
35 | Carthage/Build
36 |
--------------------------------------------------------------------------------
/examples/Linux-OpenGL/SimpleImageFilter/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /.build
3 | /Packages
4 | /*.xcodeproj
5 | Package.resolved
6 | test.png
--------------------------------------------------------------------------------
/examples/Linux-OpenGL/SimpleImageFilter/Package.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:4.2
2 |
3 | import PackageDescription
4 |
5 | let package = Package(
6 | name: "SimpleImageFilter",
7 | dependencies: [
8 | .package(path: "../../../../GPUImage2")
9 | ],
10 | targets: [
11 | .target(
12 | name: "SimpleImageFilter",
13 | dependencies: ["GPUImage"],
14 | path: "Sources")
15 | ]
16 | )
17 |
--------------------------------------------------------------------------------
/examples/Linux-OpenGL/SimpleImageFilter/Sources/main.swift:
--------------------------------------------------------------------------------
1 | import GPUImage
2 | import Foundation
3 |
4 | // For now, GLUT initialization is done in the render window, so that must come first in sequence
5 | let renderWindow = GLUTRenderWindow(width:1280, height:720, title:"Simple Video Filter", offscreen:false)
6 | guard let pictureInput = PictureInput(path:"../../SharedAssets/Lambeau.jpg") else {
7 | fatalError("Could not load sample image")
8 | }
9 | let edgeDetection = SobelEdgeDetection()
10 | let pictureOutput = PictureOutput()
11 |
12 | pictureInput --> edgeDetection --> renderWindow
13 | pictureInput --> pictureOutput
14 |
15 | pictureOutput.saveNextFrameToPath("./test.png", format:.png)
16 |
17 | pictureInput.processImage(synchronously: true)
18 |
19 | renderWindow.loopWithFunction {Thread.sleep(forTimeInterval: 1.0)}
20 |
--------------------------------------------------------------------------------
/examples/Linux-OpenGL/SimpleVideoFilter/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /.build
3 | /Packages
4 | /*.xcodeproj
5 | Package.resolved
--------------------------------------------------------------------------------
/examples/Linux-OpenGL/SimpleVideoFilter/Package.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:4.2
2 |
3 | import PackageDescription
4 |
5 | let package = Package(
6 | name: "SimpleVideoFilter",
7 | dependencies: [
8 | .package(path: "../../../../GPUImage2")
9 | ],
10 | targets: [
11 | .target(
12 | name: "SimpleVideoFilter",
13 | dependencies: ["GPUImage", "GPUImageV4LCamera"],
14 | path: "Sources")
15 | ]
16 | )
17 |
--------------------------------------------------------------------------------
/examples/Linux-OpenGL/SimpleVideoFilter/Sources/main.swift:
--------------------------------------------------------------------------------
1 | import GPUImage
2 | import GPUImageV4LCamera
3 |
4 | // For now, GLUT initialization is done in the render window, so that must come first in sequence
5 | let renderWindow = GLUTRenderWindow(width:1280, height:720, title:"Simple Video Filter", offscreen:false)
6 | let camera = V4LCamera(size:Size(width:1280.0, height:720.0))
7 | let edgeDetection = SobelEdgeDetection()
8 |
9 | camera --> edgeDetection --> renderWindow
10 |
11 | camera.startCapture()
12 | renderWindow.loopWithFunction(camera.grabFrame)
13 |
--------------------------------------------------------------------------------
/examples/Linux-RPi/SimpleVideoFilter/Source/main.swift:
--------------------------------------------------------------------------------
1 | import GPUImage
2 |
3 | // For now, rendering requires the window to be created first
4 | let renderWindow = RPiRenderWindow(width:1280, height:720)
5 | let camera = V4LCamera(size:Size(width:1280.0, height:720.0))
6 | let edgeDetection = SobelEdgeDetection()
7 |
8 | camera --> edgeDetection --> renderWindow
9 |
10 | var terminate:Int = 0
11 |
12 | camera.startCapture()
13 | while (terminate == 0) {
14 | camera.grabFrame()
15 | }
--------------------------------------------------------------------------------
/examples/Linux-RPi/SimpleVideoFilter/compile.sh:
--------------------------------------------------------------------------------
1 | swiftc Source/main.swift -o SimpleVideoFilter -I ../../../framework -L ../../../framework -lGPUImage
2 |
--------------------------------------------------------------------------------
/examples/Mac/FilterShowcase/FilterShowcase/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 |
3 | @NSApplicationMain
4 | class AppDelegate: NSObject, NSApplicationDelegate {
5 |
6 | @IBOutlet weak var window: NSWindow!
7 |
8 | var windowController:FilterShowcaseWindowController?
9 |
10 | func applicationDidFinishLaunching(_ aNotification: Notification) {
11 | self.windowController = FilterShowcaseWindowController(windowNibName:NSNib.Name(rawValue: "FilterShowcaseWindowController"))
12 | self.windowController?.showWindow(self)
13 | }
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/examples/Mac/SimpleImageFilter/SimpleImageFilter/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import GPUImage
3 |
4 | @NSApplicationMain
5 | class AppDelegate: NSObject, NSApplicationDelegate {
6 |
7 | @IBOutlet weak var window: NSWindow!
8 | @IBOutlet weak var renderView: RenderView!
9 |
10 | var image:PictureInput!
11 | var filter:SaturationAdjustment!
12 |
13 | @objc dynamic var filterValue = 1.0 {
14 | didSet {
15 | filter.saturation = GLfloat(filterValue)
16 | image.processImage()
17 | }
18 | }
19 |
20 | func applicationDidFinishLaunching(_ aNotification: Notification) {
21 | let inputImage = NSImage(named:NSImage.Name(rawValue: "Lambeau.jpg"))!
22 | image = PictureInput(image:inputImage)
23 |
24 | filter = SaturationAdjustment()
25 |
26 | image --> filter --> renderView
27 | image.processImage()
28 | }
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/examples/Mac/SimpleMovieFilter/SimpleMovieFilter/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import GPUImage
3 |
4 | @NSApplicationMain
5 | class AppDelegate: NSObject, NSApplicationDelegate {
6 |
7 | @IBOutlet weak var window: NSWindow!
8 | @IBOutlet weak var renderView: RenderView!
9 |
10 | var movie:MovieInput!
11 | var filter:Pixellate!
12 |
13 | @objc dynamic var filterValue = 0.05 {
14 | didSet {
15 | filter.fractionalWidthOfAPixel = GLfloat(filterValue)
16 | }
17 | }
18 |
19 | func applicationDidFinishLaunching(_ aNotification: Notification) {
20 | let bundleURL = Bundle.main.resourceURL!
21 | let movieURL = URL(string:"sample_iPod.m4v", relativeTo:bundleURL)!
22 |
23 | do {
24 | movie = try MovieInput(url:movieURL, playAtActualSpeed:true)
25 | filter = Pixellate()
26 | movie --> filter --> renderView
27 | movie.runBenchmark = true
28 | movie.start()
29 | } catch {
30 | print("Couldn't process movie with error: \(error)")
31 | }
32 | }
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-120.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-121.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-121.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-152.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-167.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-167.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-180.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-40.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-58.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-76.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-80.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-80.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-81.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-81.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-87.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-87.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-Small-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-Small-1.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-Small@2x-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets-iOS.xcassets/AppIcon.appiconset/Icon-Small@2x-1.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/GPUImageLogo-128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/GPUImageLogo-128.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/GPUImageLogo-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/GPUImageLogo-16.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/GPUImageLogo-256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/GPUImageLogo-256.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/GPUImageLogo-257.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/GPUImageLogo-257.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/GPUImageLogo-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/GPUImageLogo-32.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/GPUImageLogo-33.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/GPUImageLogo-33.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/GPUImageLogo-64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/GPUImageLogo-64.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/iTunesArtwork-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/iTunesArtwork-1.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/iTunesArtwork.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Assets.xcassets/AppIcon.appiconset/iTunesArtwork.png
--------------------------------------------------------------------------------
/examples/SharedAssets/Lambeau.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Lambeau.jpg
--------------------------------------------------------------------------------
/examples/SharedAssets/Mask.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/Mask.png
--------------------------------------------------------------------------------
/examples/SharedAssets/WID-small.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/WID-small.jpg
--------------------------------------------------------------------------------
/examples/SharedAssets/sample_iPod.m4v:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/examples/SharedAssets/sample_iPod.m4v
--------------------------------------------------------------------------------
/examples/iOS/FilterShowcase/FilterShowcaseSwift/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 |
3 | @UIApplicationMain
4 | class AppDelegate: UIResponder, UIApplicationDelegate {
5 |
6 | var window: UIWindow?
7 |
8 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey:Any]?) -> Bool {
9 | return true
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/examples/iOS/SimpleImageFilter/SimpleImageFilter/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 |
3 | @UIApplicationMain
4 | class AppDelegate: UIResponder, UIApplicationDelegate {
5 |
6 | var window: UIWindow?
7 |
8 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey:Any]?) -> Bool {
9 | return true
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/examples/iOS/SimpleMovieFilter/SimpleMovieFilter/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 |
3 | @UIApplicationMain
4 | class AppDelegate: UIResponder, UIApplicationDelegate {
5 |
6 | var window: UIWindow?
7 |
8 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey:Any]?) -> Bool {
9 | return true
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/examples/iOS/SimpleMovieFilter/SimpleMovieFilter/ViewController.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import GPUImage
3 |
4 | class ViewController: UIViewController {
5 |
6 | @IBOutlet weak var renderView: RenderView!
7 |
8 | var movie:MovieInput!
9 | var filter:Pixellate!
10 |
11 | override func viewDidLayoutSubviews() {
12 | super.viewDidLayoutSubviews()
13 |
14 | let bundleURL = Bundle.main.resourceURL!
15 | let movieURL = URL(string:"sample_iPod.m4v", relativeTo:bundleURL)!
16 |
17 | do {
18 | movie = try MovieInput(url:movieURL, playAtActualSpeed:true)
19 | filter = Pixellate()
20 | movie --> filter --> renderView
21 | movie.runBenchmark = true
22 | movie.start()
23 | } catch {
24 | print("Couldn't process movie with error: \(error)")
25 | }
26 |
27 | // let documentsDir = try NSFileManager.defaultManager().URLForDirectory(.DocumentDirectory, inDomain:.UserDomainMask, appropriateForURL:nil, create:true)
28 | // let fileURL = NSURL(string:"test.png", relativeToURL:documentsDir)!
29 | // try pngImage.writeToURL(fileURL, options:.DataWritingAtomic)
30 | }
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/examples/iOS/SimpleVideoFilter/SimpleVideoFilter/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 |
3 | @UIApplicationMain
4 | class AppDelegate: UIResponder, UIApplicationDelegate {
5 |
6 | var window: UIWindow?
7 |
8 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey:Any]?) -> Bool {
9 | return true
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/examples/iOS/SimpleVideoRecorder/SimpleVideoRecorder/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 |
3 | @UIApplicationMain
4 | class AppDelegate: UIResponder, UIApplicationDelegate {
5 |
6 | var window: UIWindow?
7 |
8 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey:Any]?) -> Bool { return true
9 | }
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/framework/GPUImage.xcodeproj/GPUImageTestSuite_Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/framework/GPUImage.xcodeproj/GPUImage_Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSHumanReadableCopyright
24 | Copyright © 2016 Sunset Lake Software LLC. All rights reserved.
25 | NSPrincipalClass
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/framework/Packages/CFreeGLUT/Package.swift:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/framework/Packages/CFreeGLUT/Package.swift
--------------------------------------------------------------------------------
/framework/Packages/CFreeGLUT/README.md:
--------------------------------------------------------------------------------
1 | # CFreeGLUT
2 |
3 | This is a simple module map for the freeglut library, most likely to be used for Linux. I've used this in a couple of projects in Ubuntu 14.04.
4 |
5 | To use, have something like the following in your application's Package.swift:
6 |
7 | ```
8 | import PackageDescription
9 |
10 | let package = Package(
11 | dependencies: [
12 | .Package(url: "https://github.com/BradLarson/CFreeGLUT.git", majorVersion: 1)
13 | ]
14 | )
15 | ```
16 |
17 | or clone this locally and use
18 |
19 | ```
20 | swiftc -I ./CFreeGLUT myfile.swift
21 | ```
22 |
23 | or the like to pull it in.
24 |
25 | Then you just need an
26 |
27 | ```
28 | import CFreeGLUT
29 | ```
30 |
31 | in your Swift code to import the freeglut functions.
--------------------------------------------------------------------------------
/framework/Packages/CFreeGLUT/module.modulemap:
--------------------------------------------------------------------------------
1 | module CFreeGLUT [system] {
2 | header "/usr/include/GL/freeglut.h"
3 | link "glut"
4 | export *
5 | }
--------------------------------------------------------------------------------
/framework/Packages/COpenGL/Package.swift:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/framework/Packages/COpenGL/Package.swift
--------------------------------------------------------------------------------
/framework/Packages/COpenGL/module.modulemap:
--------------------------------------------------------------------------------
1 | module COpenGL [system] {
2 | header "proto.h"
3 | header "/usr/include/GL/gl.h"
4 | header "/usr/include/GL/glext.h"
5 | link "GL"
6 | export *
7 | }
--------------------------------------------------------------------------------
/framework/Packages/COpenGL/proto.h:
--------------------------------------------------------------------------------
1 | #define GL_GLEXT_PROTOTYPES 1
--------------------------------------------------------------------------------
/framework/Packages/COpenGLES/Package.swift:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/framework/Packages/COpenGLES/Package.swift
--------------------------------------------------------------------------------
/framework/Packages/COpenGLES/module.modulemap:
--------------------------------------------------------------------------------
1 | module COpenGLES [system] {
2 | module gles1 {
3 | header "/opt/vc/include/GLES/gl.h"
4 | header "/opt/vc/include/GLES/glext.h"
5 | }
6 |
7 | module gles2 {
8 | header "/opt/vc/include/GLES2/gl2.h"
9 | header "/opt/vc/include/GLES2/gl2ext.h"
10 | }
11 | link "GLESv2"
12 | export *
13 | }
14 |
--------------------------------------------------------------------------------
/framework/Packages/CVideo4Linux/Package.swift:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/framework/Packages/CVideo4Linux/Package.swift
--------------------------------------------------------------------------------
/framework/Packages/CVideo4Linux/module.modulemap:
--------------------------------------------------------------------------------
1 | module CVideo4Linux [system] {
2 | header "/usr/include/libv4l2.h"
3 | header "/usr/include/linux/videodev2.h"
4 | link "v4l2"
5 | link "v4lconvert"
6 | export *
7 | }
--------------------------------------------------------------------------------
/framework/Packages/CVideo4Linux/stubs.h:
--------------------------------------------------------------------------------
1 | // Need to create non-variadic versions of the V4L functions for them to bridge to Swift
2 |
3 | int v4l2_open_swift(const char *file, int oflag, int arg2)
4 | {
5 | v4l2_open(file, oflag, arg2);
6 | }
7 |
8 | int v4l2_ioctl_swift(int fd, unsigned long int request, void *arg2)
9 | {
10 | v4l2_ioctl(fd, request, arg2);
11 | }
12 |
13 | int v4l2_ioctl_S_FMT(int fd, void *arg2)
14 | {
15 | v4l2_ioctl(fd, VIDIOC_S_FMT, arg2);
16 | }
17 |
18 | int v4l2_ioctl_QUERYCAP(int fd, void *arg2)
19 | {
20 | v4l2_ioctl(fd, VIDIOC_QUERYCAP, arg2);
21 | }
--------------------------------------------------------------------------------
/framework/Packages/CVideoCore/Package.swift:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/framework/Packages/CVideoCore/Package.swift
--------------------------------------------------------------------------------
/framework/Packages/CVideoCore/module.modulemap:
--------------------------------------------------------------------------------
1 | module CVideoCore [system] {
2 | header "/opt/vc/include/bcm_host.h"
3 | header "/opt/vc/include/EGL/egl.h"
4 | link "bcm_host"
5 | link "EGL"
6 | export *
7 | }
8 |
--------------------------------------------------------------------------------
/framework/Source/Color.swift:
--------------------------------------------------------------------------------
1 | public struct Color {
2 | public let redComponent:Float
3 | public let greenComponent:Float
4 | public let blueComponent:Float
5 | public let alphaComponent:Float
6 |
7 | public init(red:Float, green:Float, blue:Float, alpha:Float = 1.0) {
8 | self.redComponent = red
9 | self.greenComponent = green
10 | self.blueComponent = blue
11 | self.alphaComponent = alpha
12 | }
13 |
14 | public static let black = Color(red:0.0, green:0.0, blue:0.0, alpha:1.0)
15 | public static let white = Color(red:1.0, green:1.0, blue:1.0, alpha:1.0)
16 | public static let red = Color(red:1.0, green:0.0, blue:0.0, alpha:1.0)
17 | public static let green = Color(red:0.0, green:1.0, blue:0.0, alpha:1.0)
18 | public static let blue = Color(red:0.0, green:0.0, blue:1.0, alpha:1.0)
19 | public static let transparent = Color(red:0.0, green:0.0, blue:0.0, alpha:0.0)
20 | }
21 |
--------------------------------------------------------------------------------
/framework/Source/ImageGenerator.swift:
--------------------------------------------------------------------------------
1 | public class ImageGenerator: ImageSource {
2 | public var size:Size
3 |
4 | public let targets = TargetContainer()
5 | var imageFramebuffer:Framebuffer!
6 |
7 | public init(size:Size) {
8 | self.size = size
9 | do {
10 | imageFramebuffer = try Framebuffer(context:sharedImageProcessingContext, orientation:.portrait, size:GLSize(size))
11 | } catch {
12 | fatalError("Could not construct framebuffer of size: \(size), error:\(error)")
13 | }
14 | }
15 |
16 | public func transmitPreviousImage(to target:ImageConsumer, atIndex:UInt) {
17 | imageFramebuffer.lock()
18 | target.newFramebufferAvailable(imageFramebuffer, fromSourceIndex:atIndex)
19 | }
20 |
21 | func notifyTargets() {
22 | updateTargetsWithFramebuffer(imageFramebuffer)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/framework/Source/Linux/V4LSupplement/include/v4lfuncs.h:
--------------------------------------------------------------------------------
1 | // Need to create non-variadic versions of the V4L functions for them to bridge to Swift
2 | #include
3 |
4 | struct buffer {
5 | void *start;
6 | size_t length;
7 | };
8 |
9 | int v4l2_open_swift(const char *file, int oflag, int arg2);
10 | int v4l2_ioctl_swift(int fd, unsigned long int request, void *arg2);
11 | int v4l2_ioctl_S_FMT(int fd, void *arg2);
12 | int v4l2_ioctl_QUERYCAP(int fd, void *arg2);
13 | int v4l2_ioctl_QBUF(int fd, void *arg2);
14 | int v4l2_ioctl_DQBUF(int fd, void *arg2);
15 | int v4l2_streamon(int fd);
16 | int v4l2_streamoff(int fd);
17 | struct v4l2_format v4l2_generate_RGB24_format(int width, int height);
18 | struct v4l2_format v4l2_generate_YUV420_format(int width, int height);
19 | struct v4l2_format v4l2_generate_YUV422_format(int width, int height);
20 | struct buffer v4l2_generate_buffer(int fd, int index);
21 | struct v4l2_requestbuffers v4l2_request_buffer_size(int fd, int buffers);
22 | // void v4l2_enqueue_initial_buffers(int fd, int buffers);
23 | struct v4l2_buffer v4l2_dequeue_buffer(int fd, int index);
24 | void v4l2_enqueue_buffer(int fd, int index);
25 |
--------------------------------------------------------------------------------
/framework/Source/OperationGroup.swift:
--------------------------------------------------------------------------------
1 | open class OperationGroup: ImageProcessingOperation {
2 | let inputImageRelay = ImageRelay()
3 | let outputImageRelay = ImageRelay()
4 |
5 | public var sources:SourceContainer { get { return inputImageRelay.sources } }
6 | public var targets:TargetContainer { get { return outputImageRelay.targets } }
7 | public let maximumInputs:UInt = 1
8 |
9 | public init() {
10 | }
11 |
12 | public func newFramebufferAvailable(_ framebuffer:Framebuffer, fromSourceIndex:UInt) {
13 | inputImageRelay.newFramebufferAvailable(framebuffer, fromSourceIndex:fromSourceIndex)
14 | }
15 |
16 | public func configureGroup(_ configurationOperation:(_ input:ImageRelay, _ output:ImageRelay) -> ()) {
17 | configurationOperation(inputImageRelay, outputImageRelay)
18 | }
19 |
20 | public func transmitPreviousImage(to target:ImageConsumer, atIndex:UInt) {
21 | outputImageRelay.transmitPreviousImage(to:target, atIndex:atIndex)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/framework/Source/Operations/AdaptiveThreshold.swift:
--------------------------------------------------------------------------------
1 | public class AdaptiveThreshold: OperationGroup {
2 | public var blurRadiusInPixels: Float { didSet { boxBlur.blurRadiusInPixels = blurRadiusInPixels } }
3 |
4 | let luminance = Luminance()
5 | let boxBlur = BoxBlur()
6 | let adaptiveThreshold = BasicOperation(fragmentShader:AdaptiveThresholdFragmentShader, numberOfInputs:2)
7 |
8 | public override init() {
9 | blurRadiusInPixels = 4.0
10 | super.init()
11 |
12 | self.configureGroup{input, output in
13 | input --> self.luminance --> self.boxBlur --> self.adaptiveThreshold --> output
14 | self.luminance --> self.adaptiveThreshold
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/AddBlend.swift:
--------------------------------------------------------------------------------
1 | public class AddBlend: BasicOperation {
2 |
3 | public init() {
4 | super.init(fragmentShader:AddBlendFragmentShader, numberOfInputs:2)
5 | }
6 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/AlphaBlend.swift:
--------------------------------------------------------------------------------
1 | public class AlphaBlend: BasicOperation {
2 | public var mix:Float = 0.5 { didSet { uniformSettings["mixturePercent"] = mix } }
3 |
4 | public init() {
5 | super.init(fragmentShader:AlphaBlendFragmentShader, numberOfInputs:2)
6 |
7 | ({mix = 0.5})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/AmatorkaFilter.swift:
--------------------------------------------------------------------------------
1 | /** A photo filter based on Photoshop action by Amatorka
2 | http://amatorka.deviantart.com/art/Amatorka-Action-2-121069631
3 | */
4 |
5 | // Note: If you want to use this effect you have to add lookup_amatorka.png
6 | // from Resources folder to your application bundle.
7 |
8 | #if !os(Linux)
9 |
10 | public class AmatorkaFilter: LookupFilter {
11 | public override init() {
12 | super.init()
13 |
14 | ({lookupImage = PictureInput(imageName:"lookup_amatorka.png")})()
15 | ({intensity = 1.0})()
16 | }
17 | }
18 | #endif
19 |
--------------------------------------------------------------------------------
/framework/Source/Operations/AverageLuminanceThreshold.swift:
--------------------------------------------------------------------------------
1 | public class AverageLuminanceThreshold: OperationGroup {
2 | public var thresholdMultiplier:Float = 1.0
3 |
4 | let averageLuminance = AverageLuminanceExtractor()
5 | let luminanceThreshold = LuminanceThreshold()
6 |
7 | public override init() {
8 | super.init()
9 |
10 | averageLuminance.extractedLuminanceCallback = {[weak self] luminance in
11 | self?.luminanceThreshold.threshold = (self?.thresholdMultiplier ?? 1.0) * luminance
12 | }
13 |
14 | self.configureGroup{input, output in
15 | input --> self.averageLuminance
16 | input --> self.luminanceThreshold --> output
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/BilateralBlur.swift:
--------------------------------------------------------------------------------
1 | // TODO: auto-generate shaders for this, per the Gaussian blur method
2 |
3 | public class BilateralBlur: TwoStageOperation {
4 | public var distanceNormalizationFactor:Float = 8.0 { didSet { uniformSettings["distanceNormalizationFactor"] = distanceNormalizationFactor } }
5 |
6 | public init() {
7 | super.init(vertexShader:BilateralBlurVertexShader, fragmentShader:BilateralBlurFragmentShader)
8 |
9 | ({distanceNormalizationFactor = 1.0})()
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/framework/Source/Operations/BrightnessAdjustment.swift:
--------------------------------------------------------------------------------
1 | public class BrightnessAdjustment: BasicOperation {
2 | public var brightness:Float = 0.0 { didSet { uniformSettings["brightness"] = brightness } }
3 |
4 | public init() {
5 | super.init(fragmentShader:BrightnessFragmentShader, numberOfInputs:1)
6 |
7 | ({brightness = 1.0})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/BulgeDistortion.swift:
--------------------------------------------------------------------------------
1 | public class BulgeDistortion: BasicOperation {
2 | public var radius:Float = 0.25 { didSet { uniformSettings["radius"] = radius } }
3 | public var scale:Float = 0.5 { didSet { uniformSettings["scale"] = scale } }
4 | public var center:Position = Position.center { didSet { uniformSettings["center"] = center } }
5 |
6 | public init() {
7 | super.init(fragmentShader:BulgeDistortionFragmentShader, numberOfInputs:1)
8 |
9 | ({radius = 0.25})()
10 | ({scale = 0.5})()
11 | ({center = Position.center})()
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/framework/Source/Operations/CGAColorspaceFilter.swift:
--------------------------------------------------------------------------------
1 | public class CGAColorspaceFilter: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:CGAColorspaceFragmentShader, numberOfInputs:1)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/ChromaKeyBlend.swift:
--------------------------------------------------------------------------------
1 | public class ChromaKeyBlend: BasicOperation {
2 | public var thresholdSensitivity:Float = 0.4 { didSet { uniformSettings["thresholdSensitivity"] = thresholdSensitivity } }
3 | public var smoothing:Float = 0.1 { didSet { uniformSettings["smoothing"] = smoothing } }
4 | public var colorToReplace:Color = Color.green { didSet { uniformSettings["colorToReplace"] = colorToReplace } }
5 |
6 | public init() {
7 | super.init(fragmentShader:ChromaKeyBlendFragmentShader, numberOfInputs:2)
8 |
9 | ({thresholdSensitivity = 0.4})()
10 | ({smoothing = 0.1})()
11 | ({colorToReplace = Color.green})()
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/framework/Source/Operations/ChromaKeying.swift:
--------------------------------------------------------------------------------
1 | public class ChromaKeying: BasicOperation {
2 | public var thresholdSensitivity:Float = 0.4 { didSet { uniformSettings["thresholdSensitivity"] = thresholdSensitivity } }
3 | public var smoothing:Float = 0.1 { didSet { uniformSettings["smoothing"] = smoothing } }
4 | public var colorToReplace:Color = Color.green { didSet { uniformSettings["colorToReplace"] = colorToReplace } }
5 |
6 | public init() {
7 | super.init(fragmentShader:ChromaKeyFragmentShader, numberOfInputs:1)
8 |
9 | ({thresholdSensitivity = 0.4})()
10 | ({smoothing = 0.1})()
11 | ({colorToReplace = Color.green})()
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/framework/Source/Operations/ClosingFilter.swift:
--------------------------------------------------------------------------------
1 | public class ClosingFilter: OperationGroup {
2 | public var radius:UInt {
3 | didSet {
4 | erosion.radius = radius
5 | dilation.radius = radius
6 | }
7 | }
8 | let erosion = Erosion()
9 | let dilation = Dilation()
10 |
11 | public override init() {
12 | radius = 1
13 | super.init()
14 |
15 | self.configureGroup{input, output in
16 | input --> self.dilation --> self.erosion --> output
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/ColorBlend.swift:
--------------------------------------------------------------------------------
1 | public class ColorBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:ColorBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/ColorBurnBlend.swift:
--------------------------------------------------------------------------------
1 | public class ColorBurnBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:ColorBurnBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/ColorDodgeBlend.swift:
--------------------------------------------------------------------------------
1 | public class ColorDodgeBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:ColorDodgeBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/ColorInversion.swift:
--------------------------------------------------------------------------------
1 | public class ColorInversion: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:ColorInvertFragmentShader, numberOfInputs:1)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/ColorLocalBinaryPattern.swift:
--------------------------------------------------------------------------------
1 | /** This is based on "Accelerating image recognition on mobile devices using GPGPU" by Miguel Bordallo Lopez, Henri Nykanen, Jari Hannuksela, Olli Silven and Markku Vehvilainen
2 | http://www.ee.oulu.fi/~jhannuks/publications/SPIE2011a.pdf
3 |
4 | Right pixel is the most significant bit, traveling clockwise to get to the upper right, which is the least significant
5 | If the external pixel is greater than or equal to the center, set to 1, otherwise 0
6 |
7 | 2 1 0
8 | 3 7
9 | 4 5 6
10 |
11 | 01101101
12 | 76543210
13 | */
14 |
15 | public class ColorLocalBinaryPattern: TextureSamplingOperation {
16 | public init() {
17 | super.init(fragmentShader:ColorLocalBinaryPatternFragmentShader)
18 | }
19 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/ColorMatrixFilter.swift:
--------------------------------------------------------------------------------
1 | public class ColorMatrixFilter: BasicOperation {
2 | public var intensity:Float = 1.0 { didSet { uniformSettings["intensity"] = intensity } }
3 | public var colorMatrix:Matrix4x4 = Matrix4x4.identity { didSet { uniformSettings["colorMatrix"] = colorMatrix } }
4 |
5 | public init() {
6 |
7 | super.init(fragmentShader:ColorMatrixFragmentShader, numberOfInputs:1)
8 |
9 | ({intensity = 1.0})()
10 | ({colorMatrix = Matrix4x4.identity})()
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/framework/Source/Operations/ContrastAdjustment.swift:
--------------------------------------------------------------------------------
1 | public class ContrastAdjustment: BasicOperation {
2 | public var contrast:Float = 1.0 { didSet { uniformSettings["contrast"] = contrast } }
3 |
4 | public init() {
5 | super.init(fragmentShader:ContrastFragmentShader, numberOfInputs:1)
6 |
7 | ({contrast = 1.0})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Convolution3x3.swift:
--------------------------------------------------------------------------------
1 | public class Convolution3x3: TextureSamplingOperation {
2 | public var convolutionKernel:Matrix3x3 = Matrix3x3.centerOnly { didSet { uniformSettings["convolutionMatrix"] = convolutionKernel } }
3 |
4 | public init() {
5 | super.init(fragmentShader:Convolution3x3FragmentShader)
6 |
7 | ({convolutionKernel = Matrix3x3.centerOnly})()
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/framework/Source/Operations/Crosshatch.swift:
--------------------------------------------------------------------------------
1 | public class Crosshatch: BasicOperation {
2 | public var crossHatchSpacing:Float = 0.03 { didSet { uniformSettings["crossHatchSpacing"] = crossHatchSpacing } }
3 | public var lineWidth:Float = 0.003 { didSet { uniformSettings["lineWidth"] = lineWidth } }
4 |
5 | public init() {
6 | super.init(fragmentShader:CrosshatchFragmentShader, numberOfInputs:1)
7 |
8 | ({crossHatchSpacing = 0.03})()
9 | ({lineWidth = 0.003})()
10 | }
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/DarkenBlend.swift:
--------------------------------------------------------------------------------
1 | public class DarkenBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:DarkenBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/DifferenceBlend.swift:
--------------------------------------------------------------------------------
1 | public class DifferenceBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:DifferenceBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/DissolveBlend.swift:
--------------------------------------------------------------------------------
1 | public class DissolveBlend: BasicOperation {
2 | public var mix:Float = 0.5 { didSet { uniformSettings["mixturePercent"] = mix } }
3 |
4 | public init() {
5 | super.init(fragmentShader:DissolveBlendFragmentShader, numberOfInputs:2)
6 |
7 | ({mix = 0.5})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/DivideBlend.swift:
--------------------------------------------------------------------------------
1 | public class DivideBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:DivideBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/EmbossFilter.swift:
--------------------------------------------------------------------------------
1 | public class EmbossFilter : Convolution3x3 {
2 | public var intensity:Float = 1.0 {
3 | didSet {
4 | self.convolutionKernel = Matrix3x3(rowMajorValues:[
5 | intensity * (-2.0), -intensity, 0.0,
6 | -intensity, 1.0, intensity,
7 | 0.0, intensity, intensity * 2.0])
8 | }
9 | }
10 |
11 | public override init() {
12 | super.init()
13 |
14 | ({intensity = 1.0})()
15 | }
16 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/ExclusionBlend.swift:
--------------------------------------------------------------------------------
1 | public class ExclusionBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:ExclusionBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/ExposureAdjustment.swift:
--------------------------------------------------------------------------------
1 | public class ExposureAdjustment: BasicOperation {
2 | public var exposure:Float = 0.0 { didSet { uniformSettings["exposure"] = exposure } }
3 |
4 | public init() {
5 | super.init(fragmentShader:ExposureFragmentShader, numberOfInputs:1)
6 |
7 | ({exposure = 0.0})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/FalseColor.swift:
--------------------------------------------------------------------------------
1 | public class FalseColor: BasicOperation {
2 | public var firstColor:Color = Color(red:0.0, green:0.0, blue:0.5, alpha:1.0) { didSet { uniformSettings["firstColor"] = firstColor } }
3 | public var secondColor:Color = Color.red { didSet { uniformSettings["secondColor"] = secondColor } }
4 |
5 | public init() {
6 | super.init(fragmentShader:FalseColorFragmentShader, numberOfInputs:1)
7 |
8 | ({firstColor = Color(red:0.0, green:0.0, blue:0.5, alpha:1.0)})()
9 | ({secondColor = Color.red})()
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/framework/Source/Operations/GammaAdjustment.swift:
--------------------------------------------------------------------------------
1 | public class GammaAdjustment: BasicOperation {
2 | public var gamma:Float = 1.0 { didSet { uniformSettings["gamma"] = gamma } }
3 |
4 | public init() {
5 | super.init(fragmentShader:GammaFragmentShader, numberOfInputs:1)
6 |
7 | ({gamma = 1.0})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/GlassSphereRefraction.swift:
--------------------------------------------------------------------------------
1 | public class GlassSphereRefraction: BasicOperation {
2 | public var radius:Float = 0.25 { didSet { uniformSettings["radius"] = radius } }
3 | public var refractiveIndex:Float = 0.71 { didSet { uniformSettings["refractiveIndex"] = refractiveIndex } }
4 | public var center:Position = Position.center { didSet { uniformSettings["center"] = center } }
5 |
6 | public init() {
7 | super.init(fragmentShader:GlassSphereFragmentShader, numberOfInputs:1)
8 |
9 | ({radius = 0.25})()
10 | ({refractiveIndex = 0.71})()
11 | ({center = Position.center})()
12 |
13 | self.backgroundColor = Color(red:0.0, green:0.0, blue:0.0, alpha:0.0)
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/framework/Source/Operations/Halftone.swift:
--------------------------------------------------------------------------------
1 | public class Halftone: BasicOperation {
2 | public var fractionalWidthOfAPixel:Float = 0.01 {
3 | didSet {
4 | sharedImageProcessingContext.runOperationAsynchronously{
5 | let imageWidth = 1.0 / Float(self.renderFramebuffer?.size.width ?? 2048)
6 | self.uniformSettings["fractionalWidthOfPixel"] = max(self.fractionalWidthOfAPixel, imageWidth)
7 | }
8 | }
9 | }
10 |
11 | public init() {
12 | super.init(fragmentShader:HalftoneFragmentShader, numberOfInputs:1)
13 |
14 | ({fractionalWidthOfAPixel = 0.01})()
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/framework/Source/Operations/HardLightBlend.swift:
--------------------------------------------------------------------------------
1 | public class HardLightBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:HardLightBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Haze.swift:
--------------------------------------------------------------------------------
1 | public class Haze: BasicOperation {
2 | public var distance:Float = 0.2 { didSet { uniformSettings["hazeDistance"] = distance } }
3 | public var slope:Float = 0.0 { didSet { uniformSettings["slope"] = slope } }
4 |
5 | public init() {
6 | super.init(fragmentShader:HazeFragmentShader, numberOfInputs:1)
7 |
8 | ({distance = 0.2})()
9 | ({slope = 0.0})()
10 | }
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/HighPassFilter.swift:
--------------------------------------------------------------------------------
1 | public class HighPassFilter: OperationGroup {
2 | public var strength: Float = 0.5 { didSet { lowPass.strength = strength } }
3 |
4 | let lowPass = LowPassFilter()
5 | let differenceBlend = DifferenceBlend()
6 |
7 | public override init() {
8 | super.init()
9 |
10 | ({strength = 0.5})()
11 |
12 | self.configureGroup{input, output in
13 | input --> self.differenceBlend
14 | input --> self.lowPass --> self.differenceBlend --> output
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/HighlightAndShadowTint.swift:
--------------------------------------------------------------------------------
1 | public class HighlightAndShadowTint: BasicOperation {
2 | public var shadowTintIntensity:Float = 0.0 { didSet { uniformSettings["shadowTintIntensity"] = shadowTintIntensity } }
3 | public var highlightTintIntensity:Float = 0.0 { didSet { uniformSettings["highlightTintIntensity"] = highlightTintIntensity } }
4 | public var shadowTintColor:Color = Color.red { didSet { uniformSettings["shadowTintColor"] = shadowTintColor } }
5 | public var highlightTintColor:Color = Color.blue { didSet { uniformSettings["highlightTintColor"] = highlightTintColor } }
6 |
7 | public init() {
8 | super.init(fragmentShader:HighlightShadowTintFragmentShader, numberOfInputs:1)
9 |
10 | ({shadowTintIntensity = 0.0})()
11 | ({highlightTintIntensity = 0.0})()
12 | ({shadowTintColor = Color.red})()
13 | ({highlightTintColor = Color.blue})()
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/framework/Source/Operations/HighlightsAndShadows.swift:
--------------------------------------------------------------------------------
1 | public class HighlightsAndShadows: BasicOperation {
2 | public var shadows:Float = 0.0 { didSet { uniformSettings["shadows"] = shadows } }
3 | public var highlights:Float = 1.0 { didSet { uniformSettings["highlights"] = highlights } }
4 |
5 | public init() {
6 | super.init(fragmentShader:HighlightShadowFragmentShader, numberOfInputs:1)
7 |
8 | ({shadows = 0.0})()
9 | ({highlights = 1.0})()
10 | }
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/HistogramDisplay.swift:
--------------------------------------------------------------------------------
1 | public class HistogramDisplay: BasicOperation {
2 | public init() {
3 | super.init(vertexShader:HistogramDisplayVertexShader, fragmentShader:HistogramDisplayFragmentShader, numberOfInputs:1)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/HueAdjustment.swift:
--------------------------------------------------------------------------------
1 | public class HueAdjustment: BasicOperation {
2 | public var hue:Float = 90.0 { didSet { uniformSettings["hueAdjust"] = hue } }
3 |
4 | public init() {
5 | super.init(fragmentShader:HueFragmentShader, numberOfInputs:1)
6 |
7 | ({hue = 90.0})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/HueBlend.swift:
--------------------------------------------------------------------------------
1 | public class HueBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:HueBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/KuwaharaFilter.swift:
--------------------------------------------------------------------------------
1 | public class KuwaharaFilter: BasicOperation {
2 | public var radius:Int = 3 { didSet { uniformSettings["radius"] = radius } }
3 |
4 | public init() {
5 | super.init(fragmentShader:KuwaharaFragmentShader, numberOfInputs:1)
6 |
7 | ({radius = 3})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/KuwaharaRadius3Filter.swift:
--------------------------------------------------------------------------------
1 | public class KuwaharaRadius3Filter: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:KuwaharaRadius3FragmentShader, numberOfInputs:1)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Laplacian.swift:
--------------------------------------------------------------------------------
1 | public class Laplacian: TextureSamplingOperation {
2 | public init() {
3 | super.init(fragmentShader:LaplacianFragmentShader)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/LightenBlend.swift:
--------------------------------------------------------------------------------
1 | public class LightenBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:LightenBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/LinearBurnBlend.swift:
--------------------------------------------------------------------------------
1 | public class LinearBurnBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:LinearBurnBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/LocalBinaryPattern.swift:
--------------------------------------------------------------------------------
1 | /* This is based on "Accelerating image recognition on mobile devices using GPGPU" by Miguel Bordallo Lopez, Henri Nykanen, Jari Hannuksela, Olli Silven and Markku Vehvilainen
2 | http://www.ee.oulu.fi/~jhannuks/publications/SPIE2011a.pdf
3 |
4 | Right pixel is the most significant bit, traveling clockwise to get to the upper right, which is the least significant
5 | If the external pixel is greater than or equal to the center, set to 1, otherwise 0
6 |
7 | 2 1 0
8 | 3 7
9 | 4 5 6
10 |
11 | 01101101
12 | 76543210
13 | */
14 |
15 | public class LocalBinaryPattern: TextureSamplingOperation {
16 | public init() {
17 | super.init(fragmentShader:LocalBinaryPatternFragmentShader)
18 | }
19 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/LookupFilter.swift:
--------------------------------------------------------------------------------
1 | // PictureInput isn't defined yet on Linux, so this operation is inoperable there
2 | #if !os(Linux)
3 | public class LookupFilter: BasicOperation {
4 | public var intensity:Float = 1.0 { didSet { uniformSettings["intensity"] = intensity } }
5 | public var lookupImage:PictureInput? { // TODO: Check for retain cycles in all cases here
6 | didSet {
7 | lookupImage?.addTarget(self, atTargetIndex:1)
8 | lookupImage?.processImage()
9 | }
10 | }
11 |
12 | public init() {
13 | super.init(fragmentShader:LookupFragmentShader, numberOfInputs:2)
14 |
15 | ({intensity = 1.0})()
16 | }
17 | }
18 | #endif
19 |
--------------------------------------------------------------------------------
/framework/Source/Operations/LookupImages/lookup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/framework/Source/Operations/LookupImages/lookup.png
--------------------------------------------------------------------------------
/framework/Source/Operations/LookupImages/lookup_amatorka.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/framework/Source/Operations/LookupImages/lookup_amatorka.png
--------------------------------------------------------------------------------
/framework/Source/Operations/LookupImages/lookup_miss_etikate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/framework/Source/Operations/LookupImages/lookup_miss_etikate.png
--------------------------------------------------------------------------------
/framework/Source/Operations/LookupImages/lookup_soft_elegance_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/framework/Source/Operations/LookupImages/lookup_soft_elegance_1.png
--------------------------------------------------------------------------------
/framework/Source/Operations/LookupImages/lookup_soft_elegance_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BradLarson/GPUImage2/3a2275e48716a6ebdab0d4098bd7d90321ef4143/framework/Source/Operations/LookupImages/lookup_soft_elegance_2.png
--------------------------------------------------------------------------------
/framework/Source/Operations/LowPassFilter.swift:
--------------------------------------------------------------------------------
1 | public class LowPassFilter: OperationGroup {
2 | public var strength: Float = 0.5 { didSet { dissolveBlend.mix = strength } }
3 |
4 | let dissolveBlend = DissolveBlend()
5 | let buffer = ImageBuffer()
6 |
7 | public override init() {
8 | super.init()
9 |
10 | buffer.bufferSize = 1
11 | ({strength = 0.5})()
12 |
13 | self.configureGroup{input, output in
14 | // This is needed to break the cycle on the very first pass through the blend loop
15 | self.dissolveBlend.activatePassthroughOnNextFrame = true
16 | // TODO: this may be a retain cycle
17 | input --> self.dissolveBlend --> self.buffer --> self.dissolveBlend --> output
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Luminance.swift:
--------------------------------------------------------------------------------
1 | public class Luminance: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:LuminanceFragmentShader, numberOfInputs:1)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/LuminanceRangeReduction.swift:
--------------------------------------------------------------------------------
1 | public class LuminanceRangeReduction: BasicOperation {
2 | public var rangeReductionFactor:Float = 0.6 { didSet { uniformSettings["rangeReduction"] = rangeReductionFactor } }
3 |
4 | public init() {
5 | super.init(fragmentShader:LuminanceRangeFragmentShader, numberOfInputs:1)
6 |
7 | ({rangeReductionFactor = 0.6})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/LuminanceThreshold.swift:
--------------------------------------------------------------------------------
1 | public class LuminanceThreshold: BasicOperation {
2 | public var threshold:Float = 0.5 { didSet { uniformSettings["threshold"] = threshold } }
3 |
4 | public init() {
5 | super.init(fragmentShader:LuminanceThresholdFragmentShader, numberOfInputs:1)
6 |
7 | ({threshold = 0.5})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/LuminosityBlend.swift:
--------------------------------------------------------------------------------
1 | public class LuminosityBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:LuminosityBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/MedianFilter.swift:
--------------------------------------------------------------------------------
1 | public class MedianFilter: TextureSamplingOperation {
2 | public init() {
3 | super.init(fragmentShader:MedianFragmentShader)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/MissEtikateFilter.swift:
--------------------------------------------------------------------------------
1 | /** A photo filter based on Photoshop action by Miss Etikate:
2 | http://miss-etikate.deviantart.com/art/Photoshop-Action-15-120151961
3 | */
4 |
5 | // Note: If you want to use this effect you have to add lookup_miss_etikate.png
6 | // from Resources folder to your application bundle.
7 |
8 | #if !os(Linux)
9 | public class MissEtikateFilter: LookupFilter {
10 | public override init() {
11 | super.init()
12 |
13 | ({lookupImage = PictureInput(imageName:"lookup_miss_etikate.png")})()
14 | }
15 | }
16 | #endif
17 |
--------------------------------------------------------------------------------
/framework/Source/Operations/MonochromeFilter.swift:
--------------------------------------------------------------------------------
1 | public class MonochromeFilter: BasicOperation {
2 | public var intensity:Float = 1.0 { didSet { uniformSettings["intensity"] = intensity } }
3 | public var color:Color = Color(red:0.6, green:0.45, blue:0.3, alpha:1.0) { didSet { uniformSettings["filterColor"] = color } }
4 |
5 | public init() {
6 | super.init(fragmentShader:MonochromeFragmentShader, numberOfInputs:1)
7 |
8 | ({intensity = 1.0})()
9 | ({color = Color(red:0.6, green:0.45, blue:0.3, alpha:1.0)})()
10 | }
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/MotionDetector.swift:
--------------------------------------------------------------------------------
1 | public class MotionDetector: OperationGroup {
2 | public var lowPassStrength:Float = 1.0 { didSet {lowPassFilter.strength = lowPassStrength}}
3 | public var motionDetectedCallback:((Position, Float) -> ())?
4 |
5 | let lowPassFilter = LowPassFilter()
6 | let motionComparison = BasicOperation(fragmentShader:MotionComparisonFragmentShader, numberOfInputs:2)
7 | let averageColorExtractor = AverageColorExtractor()
8 |
9 | public override init() {
10 | super.init()
11 |
12 | averageColorExtractor.extractedColorCallback = {[weak self] color in
13 | self?.motionDetectedCallback?(Position(color.redComponent / color.alphaComponent, color.greenComponent / color.alphaComponent), color.alphaComponent)
14 | }
15 |
16 | self.configureGroup{input, output in
17 | input --> self.motionComparison --> self.averageColorExtractor --> output
18 | input --> self.lowPassFilter --> self.motionComparison
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/framework/Source/Operations/MultiplyBlend.swift:
--------------------------------------------------------------------------------
1 | public class MultiplyBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:MultiplyBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/NobleCornerDetector.swift:
--------------------------------------------------------------------------------
1 | /* Noble corner detector
2 |
3 | This is the Noble variant on the Harris detector, from
4 | Alison Noble, "Descriptions of Image Surfaces", PhD thesis, Department of Engineering Science, Oxford University 1989, p45.
5 | */
6 |
7 | public class NobleCornerDetector: HarrisCornerDetector {
8 | public init() {
9 | super.init(fragmentShader:NobleCornerDetectorFragmentShader)
10 | }
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/NormalBlend.swift:
--------------------------------------------------------------------------------
1 | public class NormalBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:NormalBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/OpacityAdjustment.swift:
--------------------------------------------------------------------------------
1 | public class OpacityAdjustment: BasicOperation {
2 | public var opacity:Float = 0.0 { didSet { uniformSettings["opacity"] = opacity } }
3 |
4 | public init() {
5 | super.init(fragmentShader:OpacityFragmentShader, numberOfInputs:1)
6 |
7 | ({opacity = 0.0})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/OpeningFilter.swift:
--------------------------------------------------------------------------------
1 | public class OpeningFilter: OperationGroup {
2 | public var radius:UInt {
3 | didSet {
4 | erosion.radius = radius
5 | dilation.radius = radius
6 | }
7 | }
8 | let erosion = Erosion()
9 | let dilation = Dilation()
10 |
11 | public override init() {
12 | radius = 1
13 | super.init()
14 |
15 | self.configureGroup{input, output in
16 | input --> self.erosion --> self.dilation --> output
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/OverlayBlend.swift:
--------------------------------------------------------------------------------
1 | public class OverlayBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:OverlayBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/PinchDistortion.swift:
--------------------------------------------------------------------------------
1 | public class PinchDistortion: BasicOperation {
2 | public var radius:Float = 1.0 { didSet { uniformSettings["radius"] = radius } }
3 | public var scale:Float = 0.5 { didSet { uniformSettings["scale"] = scale } }
4 | public var center:Position = Position.center { didSet { uniformSettings["center"] = center } }
5 |
6 | public init() {
7 | super.init(fragmentShader:PinchDistortionFragmentShader, numberOfInputs:1)
8 |
9 | ({radius = 1.0})()
10 | ({scale = 0.5})()
11 | ({center = Position.center})()
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/framework/Source/Operations/Pixellate.swift:
--------------------------------------------------------------------------------
1 | public class Pixellate: BasicOperation {
2 | public var fractionalWidthOfAPixel:Float = 0.01 {
3 | didSet {
4 | let imageWidth = 1.0 / Float(self.renderFramebuffer?.size.width ?? 2048)
5 | uniformSettings["fractionalWidthOfPixel"] = max(fractionalWidthOfAPixel, imageWidth)
6 | }
7 | }
8 |
9 | public init() {
10 | super.init(fragmentShader:PixellateFragmentShader, numberOfInputs:1)
11 |
12 | ({fractionalWidthOfAPixel = 0.01})()
13 | }
14 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/PolarPixellate.swift:
--------------------------------------------------------------------------------
1 | public class PolarPixellate: BasicOperation {
2 | public var pixelSize:Size = Size(width:0.05, height:0.05) { didSet { uniformSettings["pixelSize"] = pixelSize } }
3 | public var center:Position = Position.center { didSet { uniformSettings["center"] = center } }
4 |
5 | public init() {
6 | super.init(fragmentShader:PolarPixellateFragmentShader, numberOfInputs:1)
7 |
8 | ({pixelSize = Size(width:0.05, height:0.05)})()
9 | ({center = Position.center})()
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/framework/Source/Operations/PolkaDot.swift:
--------------------------------------------------------------------------------
1 | public class PolkaDot: BasicOperation {
2 | public var dotScaling:Float = 0.90 { didSet { uniformSettings["dotScaling"] = dotScaling } }
3 | public var fractionalWidthOfAPixel:Float = 0.01 {
4 | didSet {
5 | let imageWidth = 1.0 / Float(self.renderFramebuffer?.size.width ?? 2048)
6 | uniformSettings["fractionalWidthOfPixel"] = max(fractionalWidthOfAPixel, imageWidth)
7 | }
8 | }
9 |
10 | public init() {
11 | super.init(fragmentShader:PolkaDotFragmentShader, numberOfInputs:1)
12 |
13 | ({fractionalWidthOfAPixel = 0.01})()
14 | ({dotScaling = 0.90})()
15 | }
16 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Posterize.swift:
--------------------------------------------------------------------------------
1 | public class Posterize: BasicOperation {
2 | public var colorLevels:Float = 10.0 { didSet { uniformSettings["colorLevels"] = colorLevels } }
3 |
4 | public init() {
5 | super.init(fragmentShader:PosterizeFragmentShader, numberOfInputs:1)
6 |
7 | ({colorLevels = 10.0})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/PrewittEdgeDetection.swift:
--------------------------------------------------------------------------------
1 | public class PrewittEdgeDetection: TextureSamplingOperation {
2 | public var edgeStrength:Float = 1.0 { didSet { uniformSettings["edgeStrength"] = edgeStrength } }
3 |
4 | public init() {
5 | super.init(fragmentShader:PrewittEdgeDetectionFragmentShader)
6 |
7 | ({edgeStrength = 1.0})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/RGBAdjustmentFilter.swift:
--------------------------------------------------------------------------------
1 | public class RGBAdjustment: BasicOperation {
2 | public var red:Float = 1.0 { didSet { uniformSettings["redAdjustment"] = red } }
3 | public var blue:Float = 1.0 { didSet { uniformSettings["blueAdjustment"] = blue } }
4 | public var green:Float = 1.0 { didSet { uniformSettings["greenAdjustment"] = green } }
5 |
6 | public init() {
7 | super.init(fragmentShader:RGBAdjustmentFragmentShader, numberOfInputs:1)
8 |
9 | ({red = 1.0})()
10 | ({blue = 1.0})()
11 | ({green = 1.0})()
12 | }
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/SaturationAdjustment.swift:
--------------------------------------------------------------------------------
1 | public class SaturationAdjustment: BasicOperation {
2 | public var saturation:Float = 1.0 { didSet { uniformSettings["saturation"] = saturation } }
3 |
4 | public init() {
5 | super.init(fragmentShader:SaturationFragmentShader, numberOfInputs:1)
6 |
7 | ({saturation = 1.0})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/SaturationBlend.swift:
--------------------------------------------------------------------------------
1 | public class SaturationBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:SaturationBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/ScreenBlend.swift:
--------------------------------------------------------------------------------
1 | public class ScreenBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:ScreenBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/SepiaToneFilter.swift:
--------------------------------------------------------------------------------
1 | public class SepiaToneFilter: ColorMatrixFilter {
2 | override public init() {
3 | super.init()
4 |
5 | ({colorMatrix = Matrix4x4(rowMajorValues:[0.3588, 0.7044, 0.1368, 0.0,
6 | 0.2990, 0.5870, 0.1140, 0.0,
7 | 0.2392, 0.4696, 0.0912 ,0.0,
8 | 0.0, 0.0, 0.0, 1.0])})()
9 | }
10 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/AdaptiveThreshold_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | float blurredInput = texture2D(inputImageTexture, textureCoordinate).r;
10 | float localLuminance = texture2D(inputImageTexture2, textureCoordinate2).r;
11 | float thresholdResult = step(blurredInput - 0.05, localLuminance);
12 |
13 | gl_FragColor = vec4(vec3(thresholdResult), 1.0);
14 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/AdaptiveThreshold_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | highp float blurredInput = texture2D(inputImageTexture, textureCoordinate).r;
10 | highp float localLuminance = texture2D(inputImageTexture2, textureCoordinate2).r;
11 | highp float thresholdResult = step(blurredInput - 0.05, localLuminance);
12 |
13 | gl_FragColor = vec4(vec3(thresholdResult), 1.0);
14 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/AlphaBlend_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | uniform float mixturePercent;
8 |
9 | void main()
10 | {
11 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
12 | vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
13 |
14 | gl_FragColor = vec4(mix(textureColor.rgb, textureColor2.rgb, textureColor2.a * mixturePercent), textureColor.a);
15 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/AlphaBlend_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | uniform lowp float mixturePercent;
8 |
9 | void main()
10 | {
11 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
12 | lowp vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
13 |
14 | gl_FragColor = vec4(mix(textureColor.rgb, textureColor2.rgb, textureColor2.a * mixturePercent), textureColor.a);
15 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/AlphaTest_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | void main()
6 | {
7 | vec4 color = texture2D(inputImageTexture, textureCoordinate);
8 | if (color.a < 0.5)
9 | {
10 | discard;
11 | }
12 | else
13 | {
14 | gl_FragColor = color;
15 | }
16 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/AlphaTest_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | void main()
6 | {
7 | lowp vec4 color = texture2D(inputImageTexture, textureCoordinate);
8 | if (color.a < 0.5)
9 | {
10 | discard;
11 | }
12 | else
13 | {
14 | gl_FragColor = color;
15 | }
16 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/AverageColor.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 | attribute vec4 inputTextureCoordinate;
3 |
4 | uniform float texelWidth;
5 | uniform float texelHeight;
6 |
7 | varying vec2 upperLeftInputTextureCoordinate;
8 | varying vec2 upperRightInputTextureCoordinate;
9 | varying vec2 lowerLeftInputTextureCoordinate;
10 | varying vec2 lowerRightInputTextureCoordinate;
11 |
12 | void main()
13 | {
14 | gl_Position = position;
15 |
16 | upperLeftInputTextureCoordinate = inputTextureCoordinate.xy + vec2(-texelWidth, -texelHeight);
17 | upperRightInputTextureCoordinate = inputTextureCoordinate.xy + vec2(texelWidth, -texelHeight);
18 | lowerLeftInputTextureCoordinate = inputTextureCoordinate.xy + vec2(-texelWidth, texelHeight);
19 | lowerRightInputTextureCoordinate = inputTextureCoordinate.xy + vec2(texelWidth, texelHeight);
20 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/AverageColor_GL.fsh:
--------------------------------------------------------------------------------
1 | uniform sampler2D inputImageTexture;
2 |
3 | varying vec2 outputTextureCoordinate;
4 |
5 | varying vec2 upperLeftInputTextureCoordinate;
6 | varying vec2 upperRightInputTextureCoordinate;
7 | varying vec2 lowerLeftInputTextureCoordinate;
8 | varying vec2 lowerRightInputTextureCoordinate;
9 |
10 | void main()
11 | {
12 | vec4 upperLeftColor = texture2D(inputImageTexture, upperLeftInputTextureCoordinate);
13 | vec4 upperRightColor = texture2D(inputImageTexture, upperRightInputTextureCoordinate);
14 | vec4 lowerLeftColor = texture2D(inputImageTexture, lowerLeftInputTextureCoordinate);
15 | vec4 lowerRightColor = texture2D(inputImageTexture, lowerRightInputTextureCoordinate);
16 |
17 | gl_FragColor = 0.25 * (upperLeftColor + upperRightColor + lowerLeftColor + lowerRightColor);
18 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/AverageColor_GLES.fsh:
--------------------------------------------------------------------------------
1 | precision highp float;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | varying highp vec2 outputTextureCoordinate;
6 |
7 | varying highp vec2 upperLeftInputTextureCoordinate;
8 | varying highp vec2 upperRightInputTextureCoordinate;
9 | varying highp vec2 lowerLeftInputTextureCoordinate;
10 | varying highp vec2 lowerRightInputTextureCoordinate;
11 |
12 | void main()
13 | {
14 | highp vec4 upperLeftColor = texture2D(inputImageTexture, upperLeftInputTextureCoordinate);
15 | highp vec4 upperRightColor = texture2D(inputImageTexture, upperRightInputTextureCoordinate);
16 | highp vec4 lowerLeftColor = texture2D(inputImageTexture, lowerLeftInputTextureCoordinate);
17 | highp vec4 lowerRightColor = texture2D(inputImageTexture, lowerRightInputTextureCoordinate);
18 |
19 | gl_FragColor = 0.25 * (upperLeftColor + upperRightColor + lowerLeftColor + lowerRightColor);
20 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/AverageLuminance_GL.fsh:
--------------------------------------------------------------------------------
1 | uniform sampler2D inputImageTexture;
2 |
3 | varying vec2 outputTextureCoordinate;
4 |
5 | varying vec2 upperLeftInputTextureCoordinate;
6 | varying vec2 upperRightInputTextureCoordinate;
7 | varying vec2 lowerLeftInputTextureCoordinate;
8 | varying vec2 lowerRightInputTextureCoordinate;
9 |
10 | void main()
11 | {
12 | float upperLeftLuminance = texture2D(inputImageTexture, upperLeftInputTextureCoordinate).r;
13 | float upperRightLuminance = texture2D(inputImageTexture, upperRightInputTextureCoordinate).r;
14 | float lowerLeftLuminance = texture2D(inputImageTexture, lowerLeftInputTextureCoordinate).r;
15 | float lowerRightLuminance = texture2D(inputImageTexture, lowerRightInputTextureCoordinate).r;
16 |
17 | float luminosity = 0.25 * (upperLeftLuminance + upperRightLuminance + lowerLeftLuminance + lowerRightLuminance);
18 | gl_FragColor = vec4(luminosity, luminosity, luminosity, 1.0);
19 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/AverageLuminance_GLES.fsh:
--------------------------------------------------------------------------------
1 | precision highp float;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | varying highp vec2 outputTextureCoordinate;
6 |
7 | varying highp vec2 upperLeftInputTextureCoordinate;
8 | varying highp vec2 upperRightInputTextureCoordinate;
9 | varying highp vec2 lowerLeftInputTextureCoordinate;
10 | varying highp vec2 lowerRightInputTextureCoordinate;
11 |
12 | void main()
13 | {
14 | highp float upperLeftLuminance = texture2D(inputImageTexture, upperLeftInputTextureCoordinate).r;
15 | highp float upperRightLuminance = texture2D(inputImageTexture, upperRightInputTextureCoordinate).r;
16 | highp float lowerLeftLuminance = texture2D(inputImageTexture, lowerLeftInputTextureCoordinate).r;
17 | highp float lowerRightLuminance = texture2D(inputImageTexture, lowerRightInputTextureCoordinate).r;
18 |
19 | highp float luminosity = 0.25 * (upperLeftLuminance + upperRightLuminance + lowerLeftLuminance + lowerRightLuminance);
20 | gl_FragColor = vec4(luminosity, luminosity, luminosity, 1.0);
21 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/BilateralBlur.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 | attribute vec4 inputTextureCoordinate;
3 |
4 | const int GAUSSIAN_SAMPLES = 9;
5 |
6 | uniform float texelWidth;
7 | uniform float texelHeight;
8 |
9 | varying vec2 textureCoordinate;
10 | varying vec2 blurCoordinates[GAUSSIAN_SAMPLES];
11 |
12 | void main()
13 | {
14 | gl_Position = position;
15 | textureCoordinate = inputTextureCoordinate.xy;
16 |
17 | // Calculate the positions for the blur
18 | int multiplier = 0;
19 | vec2 blurStep;
20 | vec2 singleStepOffset = vec2(texelWidth, texelHeight);
21 |
22 | for (int i = 0; i < GAUSSIAN_SAMPLES; i++)
23 | {
24 | multiplier = (i - ((GAUSSIAN_SAMPLES - 1) / 2));
25 | // Blur in x (horizontal)
26 | blurStep = float(multiplier) * singleStepOffset;
27 | blurCoordinates[i] = inputTextureCoordinate.xy + blurStep;
28 | }
29 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Brightness_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float brightness;
5 |
6 | void main()
7 | {
8 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
9 |
10 | gl_FragColor = vec4((textureColor.rgb + vec3(brightness)), textureColor.w);
11 | }
12 |
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Brightness_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform lowp float brightness;
5 |
6 | void main()
7 | {
8 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
9 |
10 | gl_FragColor = vec4((textureColor.rgb + vec3(brightness)), textureColor.w);
11 | }
12 |
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/BulgeDistortion_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform float aspectRatio;
6 | uniform vec2 center;
7 | uniform float radius;
8 | uniform float scale;
9 |
10 | void main()
11 | {
12 | vec2 textureCoordinateToUse = vec2(textureCoordinate.x, ((textureCoordinate.y - center.y) * aspectRatio) + center.y);
13 | float dist = distance(center, textureCoordinateToUse);
14 | textureCoordinateToUse = textureCoordinate;
15 |
16 | if (dist < radius)
17 | {
18 | textureCoordinateToUse -= center;
19 | float percent = 1.0 - ((radius - dist) / radius) * scale;
20 | percent = percent * percent;
21 |
22 | textureCoordinateToUse = textureCoordinateToUse * percent;
23 | textureCoordinateToUse += center;
24 | }
25 |
26 | gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse );
27 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/BulgeDistortion_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform highp float aspectRatio;
6 | uniform highp vec2 center;
7 | uniform highp float radius;
8 | uniform highp float scale;
9 |
10 | void main()
11 | {
12 | highp vec2 textureCoordinateToUse = vec2(textureCoordinate.x, ((textureCoordinate.y - center.y) * aspectRatio) + center.y);
13 | highp float dist = distance(center, textureCoordinateToUse);
14 | textureCoordinateToUse = textureCoordinate;
15 |
16 | if (dist < radius)
17 | {
18 | textureCoordinateToUse -= center;
19 | highp float percent = 1.0 - ((radius - dist) / radius) * scale;
20 | percent = percent * percent;
21 |
22 | textureCoordinateToUse = textureCoordinateToUse * percent;
23 | textureCoordinateToUse += center;
24 | }
25 |
26 | gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse );
27 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Circle.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 | varying vec2 currentPosition;
3 | uniform float aspectRatio;
4 |
5 | void main()
6 | {
7 | currentPosition = vec2(position.x, position.y * aspectRatio);
8 | gl_Position = position;
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Circle_GL.fsh:
--------------------------------------------------------------------------------
1 | uniform vec4 circleColor;
2 | uniform vec4 backgroundColor;
3 | uniform vec2 center;
4 | uniform float radius;
5 |
6 | varying vec2 currentPosition;
7 |
8 | void main()
9 | {
10 | float distanceFromCenter = distance(center, currentPosition);
11 | float checkForPresenceWithinCircle = step(distanceFromCenter, radius);
12 |
13 | gl_FragColor = mix(backgroundColor, circleColor, checkForPresenceWithinCircle);
14 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Circle_GLES.fsh:
--------------------------------------------------------------------------------
1 | uniform lowp vec4 circleColor;
2 | uniform lowp vec4 backgroundColor;
3 | uniform highp vec2 center;
4 | uniform highp float radius;
5 |
6 | varying highp vec2 currentPosition;
7 |
8 | void main()
9 | {
10 | highp float distanceFromCenter = distance(center, currentPosition);
11 | highp float checkForPresenceWithinCircle = step(distanceFromCenter, radius);
12 |
13 | gl_FragColor = mix(backgroundColor, circleColor, checkForPresenceWithinCircle);
14 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ColorBurnBlend_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
10 | vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
11 | vec4 whiteColor = vec4(1.0);
12 | gl_FragColor = whiteColor - (whiteColor - textureColor) / textureColor2;
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ColorBurnBlend_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | mediump vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
10 | mediump vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
11 | mediump vec4 whiteColor = vec4(1.0);
12 | gl_FragColor = whiteColor - (whiteColor - textureColor) / textureColor2;
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ColorDodgeBlend_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | vec4 base = texture2D(inputImageTexture, textureCoordinate);
10 | vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);
11 |
12 | vec3 baseOverlayAlphaProduct = vec3(overlay.a * base.a);
13 | vec3 rightHandProduct = overlay.rgb * (1.0 - base.a) + base.rgb * (1.0 - overlay.a);
14 |
15 | vec3 firstBlendColor = baseOverlayAlphaProduct + rightHandProduct;
16 | vec3 overlayRGB = clamp((overlay.rgb / clamp(overlay.a, 0.01, 1.0)) * step(0.0, overlay.a), 0.0, 0.99);
17 |
18 | vec3 secondBlendColor = (base.rgb * overlay.a) / (1.0 - overlayRGB) + rightHandProduct;
19 |
20 | vec3 colorChoice = step((overlay.rgb * base.a + base.rgb * overlay.a), baseOverlayAlphaProduct);
21 |
22 | gl_FragColor = vec4(mix(firstBlendColor, secondBlendColor, colorChoice), 1.0);
23 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ColorDodgeBlend_GLES.fsh:
--------------------------------------------------------------------------------
1 | precision mediump float;
2 |
3 | varying highp vec2 textureCoordinate;
4 | varying highp vec2 textureCoordinate2;
5 |
6 | uniform sampler2D inputImageTexture;
7 | uniform sampler2D inputImageTexture2;
8 |
9 | void main()
10 | {
11 | vec4 base = texture2D(inputImageTexture, textureCoordinate);
12 | vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);
13 |
14 | vec3 baseOverlayAlphaProduct = vec3(overlay.a * base.a);
15 | vec3 rightHandProduct = overlay.rgb * (1.0 - base.a) + base.rgb * (1.0 - overlay.a);
16 |
17 | vec3 firstBlendColor = baseOverlayAlphaProduct + rightHandProduct;
18 | vec3 overlayRGB = clamp((overlay.rgb / clamp(overlay.a, 0.01, 1.0)) * step(0.0, overlay.a), 0.0, 0.99);
19 |
20 | vec3 secondBlendColor = (base.rgb * overlay.a) / (1.0 - overlayRGB) + rightHandProduct;
21 |
22 | vec3 colorChoice = step((overlay.rgb * base.a + base.rgb * overlay.a), baseOverlayAlphaProduct);
23 |
24 | gl_FragColor = vec4(mix(firstBlendColor, secondBlendColor, colorChoice), 1.0);
25 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ColorInvert_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | void main()
6 | {
7 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
8 |
9 | gl_FragColor = vec4((1.0 - textureColor.rgb), textureColor.w);
10 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ColorInvert_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | void main()
6 | {
7 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
8 |
9 | gl_FragColor = vec4((1.0 - textureColor.rgb), textureColor.w);
10 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ColorMatrix_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform mat4 colorMatrix;
6 | uniform float intensity;
7 |
8 | void main()
9 | {
10 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
11 | vec4 outputColor = textureColor * colorMatrix;
12 |
13 | gl_FragColor = (intensity * outputColor) + ((1.0 - intensity) * textureColor);
14 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ColorMatrix_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform lowp mat4 colorMatrix;
6 | uniform lowp float intensity;
7 |
8 | void main()
9 | {
10 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
11 | lowp vec4 outputColor = textureColor * colorMatrix;
12 |
13 | gl_FragColor = (intensity * outputColor) + ((1.0 - intensity) * textureColor);
14 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ColorSwizzling_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | void main()
6 | {
7 | gl_FragColor = texture2D(inputImageTexture, textureCoordinate).bgra;
8 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ColorSwizzling_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | void main()
6 | {
7 | gl_FragColor = texture2D(inputImageTexture, textureCoordinate).bgra;
8 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Contrast_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float contrast;
5 |
6 | void main()
7 | {
8 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
9 |
10 | gl_FragColor = vec4(((textureColor.rgb - vec3(0.5)) * contrast + vec3(0.5)), textureColor.w);
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Contrast_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform lowp float contrast;
5 |
6 | void main()
7 | {
8 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
9 |
10 | gl_FragColor = vec4(((textureColor.rgb - vec3(0.5)) * contrast + vec3(0.5)), textureColor.w);
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Crosshair.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 |
3 | uniform float crosshairWidth;
4 |
5 | varying vec2 centerLocation;
6 | varying float pointSpacing;
7 |
8 | void main()
9 | {
10 | gl_Position = vec4(((position.xy * 2.0) - 1.0), 0.0, 1.0);
11 | gl_PointSize = crosshairWidth + 1.0;
12 | pointSpacing = 1.0 / crosshairWidth;
13 | centerLocation = vec2(pointSpacing * ceil(crosshairWidth / 2.0), pointSpacing * ceil(crosshairWidth / 2.0));
14 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Crosshair_GL.fsh:
--------------------------------------------------------------------------------
1 | #version 120
2 |
3 | uniform vec3 crosshairColor;
4 |
5 | varying vec2 centerLocation;
6 | varying float pointSpacing;
7 |
8 | void main()
9 | {
10 | vec2 distanceFromCenter = abs(centerLocation - gl_PointCoord.xy);
11 | float axisTest = step(pointSpacing, gl_PointCoord.y) * step(distanceFromCenter.x, 0.09) + step(pointSpacing, gl_PointCoord.x) * step(distanceFromCenter.y, 0.09);
12 |
13 | gl_FragColor = vec4(crosshairColor * axisTest, axisTest);
14 | // gl_FragColor = vec4(distanceFromCenterInX, distanceFromCenterInY, 0.0, 1.0);
15 | }
16 |
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Crosshair_GLES.fsh:
--------------------------------------------------------------------------------
1 | uniform lowp vec3 crosshairColor;
2 |
3 | varying highp vec2 centerLocation;
4 | varying highp float pointSpacing;
5 |
6 | void main()
7 | {
8 | lowp vec2 distanceFromCenter = abs(centerLocation - gl_PointCoord.xy);
9 | lowp float axisTest = step(pointSpacing, gl_PointCoord.y) * step(distanceFromCenter.x, 0.09) + step(pointSpacing, gl_PointCoord.x) * step(distanceFromCenter.y, 0.09);
10 |
11 | gl_FragColor = vec4(crosshairColor * axisTest, axisTest);
12 | // gl_FragColor = vec4(distanceFromCenterInX, distanceFromCenterInY, 0.0, 1.0);
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/DarkenBlend_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | vec4 base = texture2D(inputImageTexture, textureCoordinate);
10 | vec4 overlayer = texture2D(inputImageTexture2, textureCoordinate2);
11 |
12 | gl_FragColor = vec4(min(overlayer.rgb * base.a, base.rgb * overlayer.a) + overlayer.rgb * (1.0 - base.a) + base.rgb * (1.0 - overlayer.a), 1.0);
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/DarkenBlend_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | lowp vec4 base = texture2D(inputImageTexture, textureCoordinate);
10 | lowp vec4 overlayer = texture2D(inputImageTexture2, textureCoordinate2);
11 |
12 | gl_FragColor = vec4(min(overlayer.rgb * base.a, base.rgb * overlayer.a) + overlayer.rgb * (1.0 - base.a) + base.rgb * (1.0 - overlayer.a), 1.0);
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/DifferenceBlend_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
10 | vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
11 | gl_FragColor = vec4(abs(textureColor2.rgb - textureColor.rgb), textureColor.a);
12 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/DifferenceBlend_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | mediump vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
10 | mediump vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
11 | gl_FragColor = vec4(abs(textureColor2.rgb - textureColor.rgb), textureColor.a);
12 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Dilation1_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 centerTextureCoordinate;
2 | varying vec2 oneStepPositiveTextureCoordinate;
3 | varying vec2 oneStepNegativeTextureCoordinate;
4 |
5 | uniform sampler2D inputImageTexture;
6 |
7 | void main()
8 | {
9 | vec4 centerIntensity = texture2D(inputImageTexture, centerTextureCoordinate);
10 | vec4 oneStepPositiveIntensity = texture2D(inputImageTexture, oneStepPositiveTextureCoordinate);
11 | vec4 oneStepNegativeIntensity = texture2D(inputImageTexture, oneStepNegativeTextureCoordinate);
12 |
13 | vec4 maxValue = max(centerIntensity, oneStepPositiveIntensity);
14 |
15 | gl_FragColor = max(maxValue, oneStepNegativeIntensity);
16 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Dilation1_GLES.fsh:
--------------------------------------------------------------------------------
1 | precision highp float;
2 |
3 | varying vec2 centerTextureCoordinate;
4 | varying vec2 oneStepPositiveTextureCoordinate;
5 | varying vec2 oneStepNegativeTextureCoordinate;
6 |
7 | uniform sampler2D inputImageTexture;
8 |
9 | void main()
10 | {
11 | lowp vec4 centerIntensity = texture2D(inputImageTexture, centerTextureCoordinate);
12 | lowp vec4 oneStepPositiveIntensity = texture2D(inputImageTexture, oneStepPositiveTextureCoordinate);
13 | lowp vec4 oneStepNegativeIntensity = texture2D(inputImageTexture, oneStepNegativeTextureCoordinate);
14 |
15 | lowp vec4 maxValue = max(centerIntensity, oneStepPositiveIntensity);
16 |
17 | gl_FragColor = max(maxValue, oneStepNegativeIntensity);
18 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Dilation2_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 centerTextureCoordinate;
2 | varying vec2 oneStepPositiveTextureCoordinate;
3 | varying vec2 oneStepNegativeTextureCoordinate;
4 | varying vec2 twoStepsPositiveTextureCoordinate;
5 | varying vec2 twoStepsNegativeTextureCoordinate;
6 |
7 | uniform sampler2D inputImageTexture;
8 |
9 | void main()
10 | {
11 | vec4 centerIntensity = texture2D(inputImageTexture, centerTextureCoordinate);
12 | vec4 oneStepPositiveIntensity = texture2D(inputImageTexture, oneStepPositiveTextureCoordinate);
13 | vec4 oneStepNegativeIntensity = texture2D(inputImageTexture, oneStepNegativeTextureCoordinate);
14 | vec4 twoStepsPositiveIntensity = texture2D(inputImageTexture, twoStepsPositiveTextureCoordinate);
15 | vec4 twoStepsNegativeIntensity = texture2D(inputImageTexture, twoStepsNegativeTextureCoordinate);
16 |
17 | vec4 maxValue = max(centerIntensity, oneStepPositiveIntensity);
18 | maxValue = max(maxValue, oneStepNegativeIntensity);
19 | maxValue = max(maxValue, twoStepsPositiveIntensity);
20 | maxValue = max(maxValue, twoStepsNegativeIntensity);
21 |
22 | gl_FragColor = max(maxValue, twoStepsNegativeIntensity);
23 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/DirectionalNonMaximumSuppression_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float texelWidth;
5 | uniform float texelHeight;
6 | uniform float upperThreshold;
7 | uniform float lowerThreshold;
8 |
9 | void main()
10 | {
11 | vec3 currentGradientAndDirection = texture2D(inputImageTexture, textureCoordinate).rgb;
12 | vec2 gradientDirection = ((currentGradientAndDirection.gb * 2.0) - 1.0) * vec2(texelWidth, texelHeight);
13 |
14 | float firstSampledGradientMagnitude = texture2D(inputImageTexture, textureCoordinate + gradientDirection).r;
15 | float secondSampledGradientMagnitude = texture2D(inputImageTexture, textureCoordinate - gradientDirection).r;
16 |
17 | float multiplier = step(firstSampledGradientMagnitude, currentGradientAndDirection.r);
18 | multiplier = multiplier * step(secondSampledGradientMagnitude, currentGradientAndDirection.r);
19 |
20 | float thresholdCompliance = smoothstep(lowerThreshold, upperThreshold, currentGradientAndDirection.r);
21 | multiplier = multiplier * thresholdCompliance;
22 |
23 | gl_FragColor = vec4(multiplier, multiplier, multiplier, 1.0);
24 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/DissolveBlend_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 | uniform float mixturePercent;
7 |
8 | void main()
9 | {
10 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
11 | vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
12 |
13 | gl_FragColor = mix(textureColor, textureColor2, mixturePercent);
14 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/DissolveBlend_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 | uniform lowp float mixturePercent;
7 |
8 | void main()
9 | {
10 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
11 | lowp vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
12 |
13 | gl_FragColor = mix(textureColor, textureColor2, mixturePercent);
14 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Erosion1_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 centerTextureCoordinate;
2 | varying vec2 oneStepPositiveTextureCoordinate;
3 | varying vec2 oneStepNegativeTextureCoordinate;
4 |
5 | uniform sampler2D inputImageTexture;
6 |
7 | void main()
8 | {
9 | vec4 centerIntensity = texture2D(inputImageTexture, centerTextureCoordinate);
10 | vec4 oneStepPositiveIntensity = texture2D(inputImageTexture, oneStepPositiveTextureCoordinate);
11 | vec4 oneStepNegativeIntensity = texture2D(inputImageTexture, oneStepNegativeTextureCoordinate);
12 |
13 | vec4 minValue = min(centerIntensity, oneStepPositiveIntensity);
14 |
15 | gl_FragColor = min(minValue, oneStepNegativeIntensity);
16 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Erosion1_GLES.fsh:
--------------------------------------------------------------------------------
1 | precision highp float;
2 |
3 | varying vec2 centerTextureCoordinate;
4 | varying vec2 oneStepPositiveTextureCoordinate;
5 | varying vec2 oneStepNegativeTextureCoordinate;
6 |
7 | uniform sampler2D inputImageTexture;
8 |
9 | void main()
10 | {
11 | lowp vec4 centerIntensity = texture2D(inputImageTexture, centerTextureCoordinate);
12 | lowp vec4 oneStepPositiveIntensity = texture2D(inputImageTexture, oneStepPositiveTextureCoordinate);
13 | lowp vec4 oneStepNegativeIntensity = texture2D(inputImageTexture, oneStepNegativeTextureCoordinate);
14 |
15 | lowp vec4 minValue = min(centerIntensity, oneStepPositiveIntensity);
16 |
17 | gl_FragColor = min(minValue, oneStepNegativeIntensity);
18 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Erosion2_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 centerTextureCoordinate;
2 | varying vec2 oneStepPositiveTextureCoordinate;
3 | varying vec2 oneStepNegativeTextureCoordinate;
4 | varying vec2 twoStepsPositiveTextureCoordinate;
5 | varying vec2 twoStepsNegativeTextureCoordinate;
6 |
7 | uniform sampler2D inputImageTexture;
8 |
9 | void main()
10 | {
11 | vec4 centerIntensity = texture2D(inputImageTexture, centerTextureCoordinate);
12 | vec4 oneStepPositiveIntensity = texture2D(inputImageTexture, oneStepPositiveTextureCoordinate);
13 | vec4 oneStepNegativeIntensity = texture2D(inputImageTexture, oneStepNegativeTextureCoordinate);
14 | vec4 twoStepsPositiveIntensity = texture2D(inputImageTexture, twoStepsPositiveTextureCoordinate);
15 | vec4 twoStepsNegativeIntensity = texture2D(inputImageTexture, twoStepsNegativeTextureCoordinate);
16 |
17 | vec4 minValue = min(centerIntensity, oneStepPositiveIntensity);
18 | minValue = min(minValue, oneStepNegativeIntensity);
19 | minValue = min(minValue, twoStepsPositiveIntensity);
20 |
21 | gl_FragColor = min(minValue, twoStepsNegativeIntensity);
22 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Erosion2_GLES.fsh:
--------------------------------------------------------------------------------
1 | precision highp float;
2 |
3 | varying vec2 centerTextureCoordinate;
4 | varying vec2 oneStepPositiveTextureCoordinate;
5 | varying vec2 oneStepNegativeTextureCoordinate;
6 | varying vec2 twoStepsPositiveTextureCoordinate;
7 | varying vec2 twoStepsNegativeTextureCoordinate;
8 |
9 | uniform sampler2D inputImageTexture;
10 |
11 | void main()
12 | {
13 | lowp vec4 centerIntensity = texture2D(inputImageTexture, centerTextureCoordinate);
14 | lowp vec4 oneStepPositiveIntensity = texture2D(inputImageTexture, oneStepPositiveTextureCoordinate);
15 | lowp vec4 oneStepNegativeIntensity = texture2D(inputImageTexture, oneStepNegativeTextureCoordinate);
16 | lowp vec4 twoStepsPositiveIntensity = texture2D(inputImageTexture, twoStepsPositiveTextureCoordinate);
17 | lowp vec4 twoStepsNegativeIntensity = texture2D(inputImageTexture, twoStepsNegativeTextureCoordinate);
18 |
19 | lowp vec4 minValue = min(centerIntensity, oneStepPositiveIntensity);
20 | minValue = min(minValue, oneStepNegativeIntensity);
21 | minValue = min(minValue, twoStepsPositiveIntensity);
22 |
23 | gl_FragColor = min(minValue, twoStepsNegativeIntensity);
24 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ErosionDilation1.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 | attribute vec2 inputTextureCoordinate;
3 |
4 | uniform float texelWidth;
5 | uniform float texelHeight;
6 |
7 | varying vec2 centerTextureCoordinate;
8 | varying vec2 oneStepPositiveTextureCoordinate;
9 | varying vec2 oneStepNegativeTextureCoordinate;
10 |
11 | void main()
12 | {
13 | gl_Position = position;
14 |
15 | vec2 offset = vec2(texelWidth, texelHeight);
16 |
17 | centerTextureCoordinate = inputTextureCoordinate;
18 | oneStepNegativeTextureCoordinate = inputTextureCoordinate - offset;
19 | oneStepPositiveTextureCoordinate = inputTextureCoordinate + offset;
20 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ErosionDilation2.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 | attribute vec2 inputTextureCoordinate;
3 |
4 | uniform float texelWidth;
5 | uniform float texelHeight;
6 |
7 | varying vec2 centerTextureCoordinate;
8 | varying vec2 oneStepPositiveTextureCoordinate;
9 | varying vec2 oneStepNegativeTextureCoordinate;
10 | varying vec2 twoStepsPositiveTextureCoordinate;
11 | varying vec2 twoStepsNegativeTextureCoordinate;
12 |
13 | void main()
14 | {
15 | gl_Position = position;
16 |
17 | vec2 offset = vec2(texelWidth, texelHeight);
18 |
19 | centerTextureCoordinate = inputTextureCoordinate;
20 | oneStepNegativeTextureCoordinate = inputTextureCoordinate - offset;
21 | oneStepPositiveTextureCoordinate = inputTextureCoordinate + offset;
22 | twoStepsNegativeTextureCoordinate = inputTextureCoordinate - (offset * 2.0);
23 | twoStepsPositiveTextureCoordinate = inputTextureCoordinate + (offset * 2.0);
24 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ErosionDilation3.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 | attribute vec2 inputTextureCoordinate;
3 |
4 | uniform float texelWidth;
5 | uniform float texelHeight;
6 |
7 | varying vec2 centerTextureCoordinate;
8 | varying vec2 oneStepPositiveTextureCoordinate;
9 | varying vec2 oneStepNegativeTextureCoordinate;
10 | varying vec2 twoStepsPositiveTextureCoordinate;
11 | varying vec2 twoStepsNegativeTextureCoordinate;
12 | varying vec2 threeStepsPositiveTextureCoordinate;
13 | varying vec2 threeStepsNegativeTextureCoordinate;
14 |
15 | void main()
16 | {
17 | gl_Position = position;
18 |
19 | vec2 offset = vec2(texelWidth, texelHeight);
20 |
21 | centerTextureCoordinate = inputTextureCoordinate;
22 | oneStepNegativeTextureCoordinate = inputTextureCoordinate - offset;
23 | oneStepPositiveTextureCoordinate = inputTextureCoordinate + offset;
24 | twoStepsNegativeTextureCoordinate = inputTextureCoordinate - (offset * 2.0);
25 | twoStepsPositiveTextureCoordinate = inputTextureCoordinate + (offset * 2.0);
26 | threeStepsNegativeTextureCoordinate = inputTextureCoordinate - (offset * 3.0);
27 | threeStepsPositiveTextureCoordinate = inputTextureCoordinate + (offset * 3.0);
28 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ExclusionBlend_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | vec4 base = texture2D(inputImageTexture, textureCoordinate);
10 | vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);
11 |
12 | // Dca = (Sca.Da + Dca.Sa - 2.Sca.Dca) + Sca.(1 - Da) + Dca.(1 - Sa)
13 |
14 | gl_FragColor = vec4((overlay.rgb * base.a + base.rgb * overlay.a - 2.0 * overlay.rgb * base.rgb) + overlay.rgb * (1.0 - base.a) + base.rgb * (1.0 - overlay.a), base.a);
15 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ExclusionBlend_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | mediump vec4 base = texture2D(inputImageTexture, textureCoordinate);
10 | mediump vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);
11 |
12 | // Dca = (Sca.Da + Dca.Sa - 2.Sca.Dca) + Sca.(1 - Da) + Dca.(1 - Sa)
13 |
14 | gl_FragColor = vec4((overlay.rgb * base.a + base.rgb * overlay.a - 2.0 * overlay.rgb * base.rgb) + overlay.rgb * (1.0 - base.a) + base.rgb * (1.0 - overlay.a), base.a);
15 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Exposure_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float exposure;
5 |
6 | void main()
7 | {
8 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
9 |
10 | gl_FragColor = vec4(textureColor.rgb * pow(2.0, exposure), textureColor.w);
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Exposure_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform highp float exposure;
5 |
6 | void main()
7 | {
8 | highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
9 |
10 | gl_FragColor = vec4(textureColor.rgb * pow(2.0, exposure), textureColor.w);
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/FalseColor_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float intensity;
5 | uniform vec3 firstColor;
6 | uniform vec3 secondColor;
7 |
8 | const vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);
9 |
10 | void main()
11 | {
12 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
13 | float luminance = dot(textureColor.rgb, luminanceWeighting);
14 |
15 | gl_FragColor = vec4( mix(firstColor.rgb, secondColor.rgb, luminance), textureColor.a);
16 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/FalseColor_GLES.fsh:
--------------------------------------------------------------------------------
1 | precision lowp float;
2 |
3 | varying highp vec2 textureCoordinate;
4 |
5 | uniform sampler2D inputImageTexture;
6 | uniform float intensity;
7 | uniform vec3 firstColor;
8 | uniform vec3 secondColor;
9 |
10 | const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);
11 |
12 | void main()
13 | {
14 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
15 | float luminance = dot(textureColor.rgb, luminanceWeighting);
16 |
17 | gl_FragColor = vec4( mix(firstColor.rgb, secondColor.rgb, luminance), textureColor.a);
18 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/FiveInput.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 | attribute vec4 inputTextureCoordinate;
3 | attribute vec4 inputTextureCoordinate2;
4 | attribute vec4 inputTextureCoordinate3;
5 | attribute vec4 inputTextureCoordinate4;
6 | attribute vec4 inputTextureCoordinate5;
7 |
8 | varying vec2 textureCoordinate;
9 | varying vec2 textureCoordinate2;
10 | varying vec2 textureCoordinate3;
11 | varying vec2 textureCoordinate4;
12 | varying vec2 textureCoordinate5;
13 |
14 | void main()
15 | {
16 | gl_Position = position;
17 | textureCoordinate = inputTextureCoordinate.xy;
18 | textureCoordinate2 = inputTextureCoordinate2.xy;
19 | textureCoordinate3 = inputTextureCoordinate3.xy;
20 | textureCoordinate4 = inputTextureCoordinate4.xy;
21 | textureCoordinate5 = inputTextureCoordinate5.xy;
22 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/FourInput.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 | attribute vec4 inputTextureCoordinate;
3 | attribute vec4 inputTextureCoordinate2;
4 | attribute vec4 inputTextureCoordinate3;
5 | attribute vec4 inputTextureCoordinate4;
6 |
7 | varying vec2 textureCoordinate;
8 | varying vec2 textureCoordinate2;
9 | varying vec2 textureCoordinate3;
10 | varying vec2 textureCoordinate4;
11 |
12 | void main()
13 | {
14 | gl_Position = position;
15 | textureCoordinate = inputTextureCoordinate.xy;
16 | textureCoordinate2 = inputTextureCoordinate2.xy;
17 | textureCoordinate3 = inputTextureCoordinate3.xy;
18 | textureCoordinate4 = inputTextureCoordinate4.xy;
19 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Gamma_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float gamma;
5 |
6 | void main()
7 | {
8 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
9 |
10 | gl_FragColor = vec4(pow(textureColor.rgb, vec3(gamma)), textureColor.w);
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Gamma_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform lowp float gamma;
5 |
6 | void main()
7 | {
8 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
9 |
10 | gl_FragColor = vec4(pow(textureColor.rgb, vec3(gamma)), textureColor.w);
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Halftone_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform float fractionalWidthOfPixel;
6 | uniform float aspectRatio;
7 |
8 | const vec3 W = vec3(0.2125, 0.7154, 0.0721);
9 |
10 | void main()
11 | {
12 | vec2 sampleDivisor = vec2(fractionalWidthOfPixel, fractionalWidthOfPixel / aspectRatio);
13 |
14 | vec2 samplePos = textureCoordinate - mod(textureCoordinate, sampleDivisor) + 0.5 * sampleDivisor;
15 | vec2 textureCoordinateToUse = vec2(textureCoordinate.x, (textureCoordinate.y * aspectRatio + 0.5 - 0.5 * aspectRatio));
16 | vec2 adjustedSamplePos = vec2(samplePos.x, (samplePos.y * aspectRatio + 0.5 - 0.5 * aspectRatio));
17 | float distanceFromSamplePoint = distance(adjustedSamplePos, textureCoordinateToUse);
18 |
19 | vec3 sampledColor = texture2D(inputImageTexture, samplePos ).rgb;
20 | float dotScaling = 1.0 - dot(sampledColor, W);
21 |
22 | float checkForPresenceWithinDot = 1.0 - step(distanceFromSamplePoint, (fractionalWidthOfPixel * 0.5) * dotScaling);
23 |
24 | gl_FragColor = vec4(vec3(checkForPresenceWithinDot), 1.0);
25 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HarrisCornerDetector_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float sensitivity;
5 |
6 | const float harrisConstant = 0.04;
7 |
8 | void main()
9 | {
10 | vec3 derivativeElements = texture2D(inputImageTexture, textureCoordinate).rgb;
11 |
12 | float derivativeSum = derivativeElements.x + derivativeElements.y;
13 |
14 | float zElement = (derivativeElements.z * 2.0) - 1.0;
15 |
16 | // R = Ix^2 * Iy^2 - Ixy * Ixy - k * (Ix^2 + Iy^2)^2
17 | float cornerness = derivativeElements.x * derivativeElements.y - (zElement * zElement) - harrisConstant * derivativeSum * derivativeSum;
18 |
19 | gl_FragColor = vec4(vec3(cornerness * sensitivity), 1.0);
20 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HarrisCornerDetector_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform lowp float sensitivity;
5 |
6 | const mediump float harrisConstant = 0.04;
7 |
8 | void main()
9 | {
10 | mediump vec3 derivativeElements = texture2D(inputImageTexture, textureCoordinate).rgb;
11 |
12 | mediump float derivativeSum = derivativeElements.x + derivativeElements.y;
13 |
14 | mediump float zElement = (derivativeElements.z * 2.0) - 1.0;
15 |
16 | // R = Ix^2 * Iy^2 - Ixy * Ixy - k * (Ix^2 + Iy^2)^2
17 | mediump float cornerness = derivativeElements.x * derivativeElements.y - (zElement * zElement) - harrisConstant * derivativeSum * derivativeSum;
18 |
19 | gl_FragColor = vec4(vec3(cornerness * sensitivity), 1.0);
20 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Haze_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform float hazeDistance;
6 | uniform float slope;
7 |
8 | void main()
9 | {
10 | //todo reconsider precision modifiers
11 | vec4 color = vec4(1.0);//todo reimplement as a parameter
12 |
13 | float d = textureCoordinate.y * slope + hazeDistance;
14 |
15 | vec4 c = texture2D(inputImageTexture, textureCoordinate) ; // consider using unpremultiply
16 |
17 | c = (c - d * color) / (1.0 -d);
18 |
19 | gl_FragColor = c; //consider using premultiply(c);
20 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Haze_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform lowp float hazeDistance;
6 | uniform highp float slope;
7 |
8 | void main()
9 | {
10 | //todo reconsider precision modifiers
11 | highp vec4 color = vec4(1.0);//todo reimplement as a parameter
12 |
13 | highp float d = textureCoordinate.y * slope + hazeDistance;
14 |
15 | highp vec4 c = texture2D(inputImageTexture, textureCoordinate) ; // consider using unpremultiply
16 |
17 | c = (c - d * color) / (1.0 -d);
18 |
19 | gl_FragColor = c; //consider using premultiply(c);
20 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HighlightShadowTint_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float shadowTintIntensity;
5 | uniform float highlightTintIntensity;
6 | uniform vec3 shadowTintColor;
7 | uniform vec3 highlightTintColor;
8 |
9 | const vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);
10 |
11 | void main()
12 | {
13 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
14 | float luminance = dot(textureColor.rgb, luminanceWeighting);
15 |
16 | vec4 shadowResult = mix(textureColor, max(textureColor, vec4( mix(shadowTintColor, textureColor.rgb, luminance), textureColor.a)), shadowTintIntensity);
17 | vec4 highlightResult = mix(textureColor, min(shadowResult, vec4( mix(shadowResult.rgb, highlightTintColor.rgb, luminance), textureColor.a)), highlightTintIntensity);
18 |
19 | gl_FragColor = vec4( mix(shadowResult.rgb, highlightResult.rgb, luminance), textureColor.a);
20 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HighlightShadowTint_GLES.fsh:
--------------------------------------------------------------------------------
1 | precision lowp float;
2 |
3 | varying highp vec2 textureCoordinate;
4 |
5 | uniform sampler2D inputImageTexture;
6 | uniform lowp float shadowTintIntensity;
7 | uniform lowp float highlightTintIntensity;
8 | uniform highp vec3 shadowTintColor;
9 | uniform highp vec3 highlightTintColor;
10 |
11 | const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);
12 |
13 | void main()
14 | {
15 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
16 | highp float luminance = dot(textureColor.rgb, luminanceWeighting);
17 |
18 | highp vec4 shadowResult = mix(textureColor, max(textureColor, vec4( mix(shadowTintColor, textureColor.rgb, luminance), textureColor.a)), shadowTintIntensity);
19 | highp vec4 highlightResult = mix(textureColor, min(shadowResult, vec4( mix(shadowResult.rgb, highlightTintColor, luminance), textureColor.a)), highlightTintIntensity);
20 |
21 | gl_FragColor = vec4( mix(shadowResult.rgb, highlightResult.rgb, luminance), textureColor.a);
22 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HighlightShadow_GL.fsh:
--------------------------------------------------------------------------------
1 | uniform sampler2D inputImageTexture;
2 | varying vec2 textureCoordinate;
3 |
4 | uniform float shadows;
5 | uniform float highlights;
6 |
7 | const vec3 luminanceWeighting = vec3(0.3, 0.3, 0.3);
8 |
9 | void main()
10 | {
11 | vec4 source = texture2D(inputImageTexture, textureCoordinate);
12 | float luminance = dot(source.rgb, luminanceWeighting);
13 |
14 | float shadow = clamp((pow(luminance, 1.0/(shadows+1.0)) + (-0.76)*pow(luminance, 2.0/(shadows+1.0))) - luminance, 0.0, 1.0);
15 | float highlight = clamp((1.0 - (pow(1.0-luminance, 1.0/(2.0-highlights)) + (-0.8)*pow(1.0-luminance, 2.0/(2.0-highlights)))) - luminance, -1.0, 0.0);
16 | vec3 result = vec3(0.0, 0.0, 0.0) + ((luminance + shadow + highlight) - 0.0) * ((source.rgb - vec3(0.0, 0.0, 0.0))/(luminance - 0.0));
17 |
18 | gl_FragColor = vec4(result.rgb, source.a);
19 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HighlightShadow_GLES.fsh:
--------------------------------------------------------------------------------
1 | uniform sampler2D inputImageTexture;
2 | varying highp vec2 textureCoordinate;
3 |
4 | uniform lowp float shadows;
5 | uniform lowp float highlights;
6 |
7 | const mediump vec3 luminanceWeighting = vec3(0.3, 0.3, 0.3);
8 |
9 | void main()
10 | {
11 | lowp vec4 source = texture2D(inputImageTexture, textureCoordinate);
12 | mediump float luminance = dot(source.rgb, luminanceWeighting);
13 |
14 | mediump float shadow = clamp((pow(luminance, 1.0/(shadows+1.0)) + (-0.76)*pow(luminance, 2.0/(shadows+1.0))) - luminance, 0.0, 1.0);
15 | mediump float highlight = clamp((1.0 - (pow(1.0-luminance, 1.0/(2.0-highlights)) + (-0.8)*pow(1.0-luminance, 2.0/(2.0-highlights)))) - luminance, -1.0, 0.0);
16 | lowp vec3 result = vec3(0.0, 0.0, 0.0) + ((luminance + shadow + highlight) - 0.0) * ((source.rgb - vec3(0.0, 0.0, 0.0))/(luminance - 0.0));
17 | gl_FragColor = vec4(result.rgb, source.a);
18 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramAccumulation_GL.fsh:
--------------------------------------------------------------------------------
1 | const float scalingFactor = 1.0 / 256.0;
2 |
3 | varying vec3 colorFactor;
4 |
5 | void main()
6 | {
7 | gl_FragColor = vec4(colorFactor * scalingFactor , 1.0);
8 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramAccumulation_GLES.fsh:
--------------------------------------------------------------------------------
1 | const lowp float scalingFactor = 1.0 / 256.0;
2 |
3 | varying lowp vec3 colorFactor;
4 |
5 | void main()
6 | {
7 | gl_FragColor = vec4(colorFactor * scalingFactor , 1.0);
8 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramBlueSampling.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 |
3 | varying vec3 colorFactor;
4 |
5 | void main()
6 | {
7 | colorFactor = vec3(0.0, 0.0, 1.0);
8 | gl_Position = vec4(-1.0 + (position.z * 0.0078125), 0.0, 0.0, 1.0);
9 | gl_PointSize = 1.0;
10 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramDisplay.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 | attribute vec4 inputTextureCoordinate;
3 |
4 | varying vec2 textureCoordinate;
5 | varying float height;
6 |
7 | void main()
8 | {
9 | gl_Position = position;
10 | textureCoordinate = vec2(inputTextureCoordinate.x, 0.5);
11 | height = 1.0 - inputTextureCoordinate.y;
12 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramDisplay_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying float height;
3 |
4 | uniform sampler2D inputImageTexture;
5 | vec4 backgroundColor = vec4(0.0, 0.0, 0.0, 0.0);
6 |
7 | void main()
8 | {
9 | vec3 colorChannels = texture2D(inputImageTexture, textureCoordinate).rgb;
10 | vec4 heightTest = vec4(step(height, colorChannels), 1.0);
11 | gl_FragColor = mix(backgroundColor, heightTest, heightTest.r + heightTest.g + heightTest.b);
12 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramDisplay_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp float height;
3 |
4 | uniform sampler2D inputImageTexture;
5 | lowp vec4 backgroundColor = vec4(0.0, 0.0, 0.0, 0.0);
6 |
7 | void main()
8 | {
9 | lowp vec3 colorChannels = texture2D(inputImageTexture, textureCoordinate).rgb;
10 | lowp vec4 heightTest = vec4(step(height, colorChannels), 1.0);
11 | gl_FragColor = mix(backgroundColor, heightTest, heightTest.r + heightTest.g + heightTest.b);
12 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramEqualizationBlue_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | uniform sampler2D inputImageTexture;
3 | uniform sampler2D inputImageTexture2;
4 |
5 | void main()
6 | {
7 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
8 | float blueCurveValue = texture2D(inputImageTexture2, vec2(textureColor.b, 0.0)).b;
9 |
10 | gl_FragColor = vec4(textureColor.r, textureColor.g, blueCurveValue, textureColor.a);
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramEqualizationBlue_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | uniform sampler2D inputImageTexture;
3 | uniform sampler2D inputImageTexture2;
4 |
5 | void main()
6 | {
7 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
8 | lowp float blueCurveValue = texture2D(inputImageTexture2, vec2(textureColor.b, 0.0)).b;
9 |
10 | gl_FragColor = vec4(textureColor.r, textureColor.g, blueCurveValue, textureColor.a);
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramEqualizationGreen_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | uniform sampler2D inputImageTexture;
3 | uniform sampler2D inputImageTexture2;
4 |
5 | void main()
6 | {
7 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
8 | float greenCurveValue = texture2D(inputImageTexture2, vec2(textureColor.g, 0.0)).g;
9 |
10 | gl_FragColor = vec4(textureColor.r, greenCurveValue, textureColor.b, textureColor.a);
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramEqualizationGreen_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | uniform sampler2D inputImageTexture;
3 | uniform sampler2D inputImageTexture2;
4 |
5 | void main()
6 | {
7 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
8 | lowp float greenCurveValue = texture2D(inputImageTexture2, vec2(textureColor.g, 0.0)).g;
9 |
10 | gl_FragColor = vec4(textureColor.r, greenCurveValue, textureColor.b, textureColor.a);
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramEqualizationLuminance_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | uniform sampler2D inputImageTexture;
3 | uniform sampler2D inputImageTexture2;
4 |
5 | const vec3 W = vec3(0.2125, 0.7154, 0.0721);
6 |
7 | void main()
8 | {
9 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
10 | float luminance = dot(textureColor.rgb, W);
11 | float newLuminance = texture2D(inputImageTexture2, vec2(luminance, 0.0)).r;
12 | float deltaLuminance = newLuminance - luminance;
13 |
14 | float red = clamp(textureColor.r + deltaLuminance, 0.0, 1.0);
15 | float green = clamp(textureColor.g + deltaLuminance, 0.0, 1.0);
16 | float blue = clamp(textureColor.b + deltaLuminance, 0.0, 1.0);
17 |
18 | gl_FragColor = vec4(red, green, blue, textureColor.a);
19 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramEqualizationLuminance_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | uniform sampler2D inputImageTexture;
3 | uniform sampler2D inputImageTexture2;
4 |
5 | const lowp vec3 W = vec3(0.2125, 0.7154, 0.0721);
6 |
7 | void main()
8 | {
9 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
10 | lowp float luminance = dot(textureColor.rgb, W);
11 | lowp float newLuminance = texture2D(inputImageTexture2, vec2(luminance, 0.0)).r;
12 | lowp float deltaLuminance = newLuminance - luminance;
13 |
14 | lowp float red = clamp(textureColor.r + deltaLuminance, 0.0, 1.0);
15 | lowp float green = clamp(textureColor.g + deltaLuminance, 0.0, 1.0);
16 | lowp float blue = clamp(textureColor.b + deltaLuminance, 0.0, 1.0);
17 |
18 | gl_FragColor = vec4(red, green, blue, textureColor.a);
19 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramEqualizationRGB_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | uniform sampler2D inputImageTexture;
3 | uniform sampler2D inputImageTexture2;
4 |
5 | void main()
6 | {
7 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
8 | float redCurveValue = texture2D(inputImageTexture2, vec2(textureColor.r, 0.0)).r;
9 | float greenCurveValue = texture2D(inputImageTexture2, vec2(textureColor.g, 0.0)).g;
10 | float blueCurveValue = texture2D(inputImageTexture2, vec2(textureColor.b, 0.0)).b;
11 |
12 | gl_FragColor = vec4(redCurveValue, greenCurveValue, blueCurveValue, textureColor.a);
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramEqualizationRGB_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | uniform sampler2D inputImageTexture;
3 | uniform sampler2D inputImageTexture2;
4 |
5 | void main()
6 | {
7 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
8 | lowp float redCurveValue = texture2D(inputImageTexture2, vec2(textureColor.r, 0.0)).r;
9 | lowp float greenCurveValue = texture2D(inputImageTexture2, vec2(textureColor.g, 0.0)).g;
10 | lowp float blueCurveValue = texture2D(inputImageTexture2, vec2(textureColor.b, 0.0)).b;
11 |
12 | gl_FragColor = vec4(redCurveValue, greenCurveValue, blueCurveValue, textureColor.a);
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramEqualizationRed_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | uniform sampler2D inputImageTexture;
3 | uniform sampler2D inputImageTexture2;
4 |
5 | void main()
6 | {
7 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
8 | float redCurveValue = texture2D(inputImageTexture2, vec2(textureColor.r, 0.0)).r;
9 |
10 | gl_FragColor = vec4(redCurveValue, textureColor.g, textureColor.b, textureColor.a);
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramEqualizationRed_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | uniform sampler2D inputImageTexture;
3 | uniform sampler2D inputImageTexture2;
4 |
5 | void main()
6 | {
7 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
8 | lowp float redCurveValue = texture2D(inputImageTexture2, vec2(textureColor.r, 0.0)).r;
9 |
10 | gl_FragColor = vec4(redCurveValue, textureColor.g, textureColor.b, textureColor.a);
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramGreenSampling.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 |
3 | varying vec3 colorFactor;
4 |
5 | void main()
6 | {
7 | colorFactor = vec3(0.0, 1.0, 0.0);
8 | gl_Position = vec4(-1.0 + (position.y * 0.0078125), 0.0, 0.0, 1.0);
9 | gl_PointSize = 1.0;
10 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramLuminanceSampling.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 |
3 | varying vec3 colorFactor;
4 |
5 | const vec3 W = vec3(0.2125, 0.7154, 0.0721);
6 |
7 | void main()
8 | {
9 | float luminance = dot(position.xyz, W);
10 |
11 | colorFactor = vec3(1.0, 1.0, 1.0);
12 | gl_Position = vec4(-1.0 + (luminance * 0.0078125), 0.0, 0.0, 1.0);
13 | gl_PointSize = 1.0;
14 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/HistogramRedSampling.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 |
3 | varying vec3 colorFactor;
4 |
5 | void main()
6 | {
7 | colorFactor = vec3(1.0, 0.0, 0.0);
8 | gl_Position = vec4(-1.0 + (position.x * 0.0078125), 0.0, 0.0, 1.0);
9 | gl_PointSize = 1.0;
10 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/LightenBlend_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
10 | vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
11 |
12 | gl_FragColor = max(textureColor, textureColor2);
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/LightenBlend_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
10 | lowp vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
11 |
12 | gl_FragColor = max(textureColor, textureColor2);
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Line.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 |
3 | void main()
4 | {
5 | gl_Position = position;
6 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Line_GL.fsh:
--------------------------------------------------------------------------------
1 | uniform vec3 lineColor;
2 |
3 | void main()
4 | {
5 | gl_FragColor = vec4(lineColor, 1.0);
6 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Line_GLES.fsh:
--------------------------------------------------------------------------------
1 | uniform lowp vec3 lineColor;
2 |
3 | void main()
4 | {
5 | gl_FragColor = vec4(lineColor, 1.0);
6 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/LinearBurnBlend_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
10 | vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
11 |
12 | gl_FragColor = vec4(clamp(textureColor.rgb + textureColor2.rgb - vec3(1.0), vec3(0.0), vec3(1.0)), textureColor.a);
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/LinearBurnBlend_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | mediump vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
10 | mediump vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
11 |
12 | gl_FragColor = vec4(clamp(textureColor.rgb + textureColor2.rgb - vec3(1.0), vec3(0.0), vec3(1.0)), textureColor.a);
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/LuminanceRange_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float rangeReduction;
5 |
6 | // Values from "Graphics Shaders: Theory and Practice" by Bailey and Cunningham
7 | const vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);
8 |
9 | void main()
10 | {
11 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
12 | float luminance = dot(textureColor.rgb, luminanceWeighting);
13 | float luminanceRatio = ((0.5 - luminance) * rangeReduction);
14 |
15 | gl_FragColor = vec4((textureColor.rgb) + (luminanceRatio), textureColor.w);
16 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/LuminanceRange_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform lowp float rangeReduction;
5 |
6 | // Values from "Graphics Shaders: Theory and Practice" by Bailey and Cunningham
7 | const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);
8 |
9 | void main()
10 | {
11 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
12 | mediump float luminance = dot(textureColor.rgb, luminanceWeighting);
13 | mediump float luminanceRatio = ((0.5 - luminance) * rangeReduction);
14 |
15 | gl_FragColor = vec4((textureColor.rgb) + (luminanceRatio), textureColor.w);
16 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/LuminanceThreshold_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float threshold;
5 |
6 | const vec3 W = vec3(0.2125, 0.7154, 0.0721);
7 |
8 | void main()
9 | {
10 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
11 | float luminance = dot(textureColor.rgb, W);
12 | float thresholdResult = step(threshold, luminance);
13 |
14 | gl_FragColor = vec4(vec3(thresholdResult), textureColor.w);
15 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/LuminanceThreshold_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform highp float threshold;
5 |
6 | const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);
7 |
8 | void main()
9 | {
10 | highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
11 | highp float luminance = dot(textureColor.rgb, W);
12 | highp float thresholdResult = step(threshold, luminance);
13 |
14 | gl_FragColor = vec4(vec3(thresholdResult), textureColor.w);
15 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Luminance_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | // Values from "Graphics Shaders: Theory and Practice" by Bailey and Cunningham
6 | const vec3 W = vec3(0.2125, 0.7154, 0.0721);
7 |
8 | void main()
9 | {
10 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
11 | float luminance = dot(textureColor.rgb, W);
12 |
13 | gl_FragColor = vec4(vec3(luminance), textureColor.a);
14 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Luminance_GLES.fsh:
--------------------------------------------------------------------------------
1 | precision highp float;
2 |
3 | varying vec2 textureCoordinate;
4 |
5 | uniform sampler2D inputImageTexture;
6 |
7 | // Values from "Graphics Shaders: Theory and Practice" by Bailey and Cunningham
8 | const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);
9 |
10 | void main()
11 | {
12 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
13 | float luminance = dot(textureColor.rgb, W);
14 |
15 | gl_FragColor = vec4(vec3(luminance), textureColor.a);
16 | }
17 |
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Monochrome_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float intensity;
5 | uniform vec3 filterColor;
6 |
7 | const vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);
8 |
9 | void main()
10 | {
11 | //desat, then apply overlay blend
12 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
13 | float luminance = dot(textureColor.rgb, luminanceWeighting);
14 |
15 | vec4 desat = vec4(vec3(luminance), 1.0);
16 |
17 | //overlay
18 | vec4 outputColor = vec4(
19 | (desat.r < 0.5 ? (2.0 * desat.r * filterColor.r) : (1.0 - 2.0 * (1.0 - desat.r) * (1.0 - filterColor.r))),
20 | (desat.g < 0.5 ? (2.0 * desat.g * filterColor.g) : (1.0 - 2.0 * (1.0 - desat.g) * (1.0 - filterColor.g))),
21 | (desat.b < 0.5 ? (2.0 * desat.b * filterColor.b) : (1.0 - 2.0 * (1.0 - desat.b) * (1.0 - filterColor.b))),
22 | 1.0
23 | );
24 |
25 | //which is better, or are they equal?
26 | gl_FragColor = vec4( mix(textureColor.rgb, outputColor.rgb, intensity), textureColor.a);
27 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/MotionComparison_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | uniform float intensity;
8 |
9 | void main()
10 | {
11 | vec3 currentImageColor = texture2D(inputImageTexture, textureCoordinate).rgb;
12 | vec3 lowPassImageColor = texture2D(inputImageTexture2, textureCoordinate2).rgb;
13 |
14 | float colorDistance = distance(currentImageColor, lowPassImageColor); // * 0.57735
15 | float movementThreshold = step(0.2, colorDistance);
16 |
17 | gl_FragColor = movementThreshold * vec4(textureCoordinate2.x, textureCoordinate2.y, 1.0, 1.0);
18 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/MotionComparison_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | uniform highp float intensity;
8 |
9 | void main()
10 | {
11 | lowp vec3 currentImageColor = texture2D(inputImageTexture, textureCoordinate).rgb;
12 | lowp vec3 lowPassImageColor = texture2D(inputImageTexture2, textureCoordinate2).rgb;
13 |
14 | mediump float colorDistance = distance(currentImageColor, lowPassImageColor); // * 0.57735
15 | lowp float movementThreshold = step(0.2, colorDistance);
16 |
17 | gl_FragColor = movementThreshold * vec4(textureCoordinate2.x, textureCoordinate2.y, 1.0, 1.0);
18 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/MultiplyBlend_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | vec4 base = texture2D(inputImageTexture, textureCoordinate);
10 | vec4 overlayer = texture2D(inputImageTexture2, textureCoordinate2);
11 |
12 | gl_FragColor = overlayer * base + overlayer * (1.0 - base.a) + base * (1.0 - overlayer.a);
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/MultiplyBlend_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | lowp vec4 base = texture2D(inputImageTexture, textureCoordinate);
10 | lowp vec4 overlayer = texture2D(inputImageTexture2, textureCoordinate2);
11 |
12 | gl_FragColor = overlayer * base + overlayer * (1.0 - base.a) + base * (1.0 - overlayer.a);
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/NobleCornerDetector_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float sensitivity;
5 |
6 | void main()
7 | {
8 | vec3 derivativeElements = texture2D(inputImageTexture, textureCoordinate).rgb;
9 |
10 | float derivativeSum = derivativeElements.x + derivativeElements.y;
11 |
12 | // R = (Ix^2 * Iy^2 - Ixy * Ixy) / (Ix^2 + Iy^2)
13 | float zElement = (derivativeElements.z * 2.0) - 1.0;
14 | // mediump float harrisIntensity = (derivativeElements.x * derivativeElements.y - (derivativeElements.z * derivativeElements.z)) / (derivativeSum);
15 | float cornerness = (derivativeElements.x * derivativeElements.y - (zElement * zElement)) / (derivativeSum);
16 |
17 | // Original Harris detector
18 | // R = Ix^2 * Iy^2 - Ixy * Ixy - k * (Ix^2 + Iy^2)^2
19 | // highp float harrisIntensity = derivativeElements.x * derivativeElements.y - (derivativeElements.z * derivativeElements.z) - harrisConstant * derivativeSum * derivativeSum;
20 |
21 | // gl_FragColor = vec4(vec3(harrisIntensity * 7.0), 1.0);
22 | gl_FragColor = vec4(vec3(cornerness * sensitivity), 1.0);
23 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/OneInput.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 | attribute vec4 inputTextureCoordinate;
3 |
4 | varying vec2 textureCoordinate;
5 |
6 | void main()
7 | {
8 | gl_Position = position;
9 | textureCoordinate = inputTextureCoordinate.xy;
10 | }
11 |
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Opacity_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float opacity;
5 |
6 | void main()
7 | {
8 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
9 |
10 | gl_FragColor = vec4(textureColor.rgb, textureColor.a * opacity);
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Opacity_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform lowp float opacity;
5 |
6 | void main()
7 | {
8 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
9 |
10 | gl_FragColor = vec4(textureColor.rgb, textureColor.a * opacity);
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Passthrough_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | void main()
6 | {
7 | gl_FragColor = texture2D(inputImageTexture, textureCoordinate);
8 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Passthrough_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | void main()
6 | {
7 | gl_FragColor = texture2D(inputImageTexture, textureCoordinate);
8 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/PinchDistortion_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform float aspectRatio;
6 | uniform vec2 center;
7 | uniform float radius;
8 | uniform float scale;
9 |
10 | void main()
11 | {
12 | vec2 textureCoordinateToUse = vec2(textureCoordinate.x, (textureCoordinate.y * aspectRatio + 0.5 - 0.5 * aspectRatio));
13 | float dist = distance(center, textureCoordinateToUse);
14 | textureCoordinateToUse = textureCoordinate;
15 |
16 | if (dist < radius)
17 | {
18 | textureCoordinateToUse -= center;
19 | float percent = 1.0 + ((0.5 - dist) / 0.5) * scale;
20 | textureCoordinateToUse = textureCoordinateToUse * percent;
21 | textureCoordinateToUse += center;
22 |
23 | gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse );
24 | }
25 | else
26 | {
27 | gl_FragColor = texture2D(inputImageTexture, textureCoordinate );
28 | }
29 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/PinchDistortion_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform highp float aspectRatio;
6 | uniform highp vec2 center;
7 | uniform highp float radius;
8 | uniform highp float scale;
9 |
10 | void main()
11 | {
12 | highp vec2 textureCoordinateToUse = vec2(textureCoordinate.x, (textureCoordinate.y * aspectRatio + 0.5 - 0.5 * aspectRatio));
13 | highp float dist = distance(center, textureCoordinateToUse);
14 | textureCoordinateToUse = textureCoordinate;
15 |
16 | if (dist < radius)
17 | {
18 | textureCoordinateToUse -= center;
19 | highp float percent = 1.0 + ((0.5 - dist) / 0.5) * scale;
20 | textureCoordinateToUse = textureCoordinateToUse * percent;
21 | textureCoordinateToUse += center;
22 |
23 | gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse );
24 | }
25 | else
26 | {
27 | gl_FragColor = texture2D(inputImageTexture, textureCoordinate );
28 | }
29 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Pixellate_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform float fractionalWidthOfPixel;
6 | uniform float aspectRatio;
7 |
8 | void main()
9 | {
10 | vec2 sampleDivisor = vec2(fractionalWidthOfPixel, fractionalWidthOfPixel / aspectRatio);
11 |
12 | vec2 samplePos = textureCoordinate - mod(textureCoordinate, sampleDivisor) + 0.5 * sampleDivisor;
13 | gl_FragColor = texture2D(inputImageTexture, samplePos );
14 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Pixellate_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform highp float fractionalWidthOfPixel;
6 | uniform highp float aspectRatio;
7 |
8 | void main()
9 | {
10 | highp vec2 sampleDivisor = vec2(fractionalWidthOfPixel, fractionalWidthOfPixel / aspectRatio);
11 |
12 | highp vec2 samplePos = textureCoordinate - mod(textureCoordinate, sampleDivisor) + 0.5 * sampleDivisor;
13 | gl_FragColor = texture2D(inputImageTexture, samplePos );
14 | }
15 |
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/PolarPixellate_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform vec2 center;
6 | uniform vec2 pixelSize;
7 |
8 |
9 | void main()
10 | {
11 | vec2 normCoord = 2.0 * textureCoordinate - 1.0;
12 | vec2 normCenter = 2.0 * center - 1.0;
13 |
14 | normCoord -= normCenter;
15 |
16 | float r = length(normCoord); // to polar coords
17 | float phi = atan(normCoord.y, normCoord.x); // to polar coords
18 |
19 | r = r - mod(r, pixelSize.x) + 0.03;
20 | phi = phi - mod(phi, pixelSize.y);
21 |
22 | normCoord.x = r * cos(phi);
23 | normCoord.y = r * sin(phi);
24 |
25 | normCoord += normCenter;
26 |
27 | vec2 textureCoordinateToUse = normCoord / 2.0 + 0.5;
28 |
29 | gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse );
30 |
31 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/PolarPixellate_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform highp vec2 center;
6 | uniform highp vec2 pixelSize;
7 |
8 |
9 | void main()
10 | {
11 | highp vec2 normCoord = 2.0 * textureCoordinate - 1.0;
12 | highp vec2 normCenter = 2.0 * center - 1.0;
13 |
14 | normCoord -= normCenter;
15 |
16 | highp float r = length(normCoord); // to polar coords
17 | highp float phi = atan(normCoord.y, normCoord.x); // to polar coords
18 |
19 | r = r - mod(r, pixelSize.x) + 0.03;
20 | phi = phi - mod(phi, pixelSize.y);
21 |
22 | normCoord.x = r * cos(phi);
23 | normCoord.y = r * sin(phi);
24 |
25 | normCoord += normCenter;
26 |
27 | mediump vec2 textureCoordinateToUse = normCoord / 2.0 + 0.5;
28 |
29 | gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse );
30 |
31 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/PolkaDot_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform float fractionalWidthOfPixel;
6 | uniform float aspectRatio;
7 | uniform float dotScaling;
8 |
9 | void main()
10 | {
11 | vec2 sampleDivisor = vec2(fractionalWidthOfPixel, fractionalWidthOfPixel / aspectRatio);
12 |
13 | vec2 samplePos = textureCoordinate - mod(textureCoordinate, sampleDivisor) + 0.5 * sampleDivisor;
14 | vec2 textureCoordinateToUse = vec2(textureCoordinate.x, (textureCoordinate.y * aspectRatio + 0.5 - 0.5 * aspectRatio));
15 | vec2 adjustedSamplePos = vec2(samplePos.x, (samplePos.y * aspectRatio + 0.5 - 0.5 * aspectRatio));
16 | float distanceFromSamplePoint = distance(adjustedSamplePos, textureCoordinateToUse);
17 | float checkForPresenceWithinDot = step(distanceFromSamplePoint, (fractionalWidthOfPixel * 0.5) * dotScaling);
18 |
19 | vec4 inputColor = texture2D(inputImageTexture, samplePos);
20 |
21 | gl_FragColor = vec4(inputColor.rgb * checkForPresenceWithinDot, inputColor.a);
22 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/PolkaDot_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform highp float fractionalWidthOfPixel;
6 | uniform highp float aspectRatio;
7 | uniform highp float dotScaling;
8 |
9 | void main()
10 | {
11 | highp vec2 sampleDivisor = vec2(fractionalWidthOfPixel, fractionalWidthOfPixel / aspectRatio);
12 |
13 | highp vec2 samplePos = textureCoordinate - mod(textureCoordinate, sampleDivisor) + 0.5 * sampleDivisor;
14 | highp vec2 textureCoordinateToUse = vec2(textureCoordinate.x, (textureCoordinate.y * aspectRatio + 0.5 - 0.5 * aspectRatio));
15 | highp vec2 adjustedSamplePos = vec2(samplePos.x, (samplePos.y * aspectRatio + 0.5 - 0.5 * aspectRatio));
16 | highp float distanceFromSamplePoint = distance(adjustedSamplePos, textureCoordinateToUse);
17 | lowp float checkForPresenceWithinDot = step(distanceFromSamplePoint, (fractionalWidthOfPixel * 0.5) * dotScaling);
18 |
19 | lowp vec4 inputColor = texture2D(inputImageTexture, samplePos);
20 |
21 | gl_FragColor = vec4(inputColor.rgb * checkForPresenceWithinDot, inputColor.a);
22 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Posterize_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float colorLevels;
5 |
6 | void main()
7 | {
8 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
9 |
10 | gl_FragColor = floor((textureColor * colorLevels) + vec4(0.5)) / colorLevels;
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Posterize_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform highp float colorLevels;
5 |
6 | void main()
7 | {
8 | highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
9 |
10 | gl_FragColor = floor((textureColor * colorLevels) + vec4(0.5)) / colorLevels;
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/RGBAdjustment_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float redAdjustment;
5 | uniform float greenAdjustment;
6 | uniform float blueAdjustment;
7 |
8 | void main()
9 | {
10 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
11 |
12 | gl_FragColor = vec4(textureColor.r * redAdjustment, textureColor.g * greenAdjustment, textureColor.b * blueAdjustment, textureColor.a);
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/RGBAdjustment_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform highp float redAdjustment;
5 | uniform highp float greenAdjustment;
6 | uniform highp float blueAdjustment;
7 |
8 | void main()
9 | {
10 | highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
11 |
12 | gl_FragColor = vec4(textureColor.r * redAdjustment, textureColor.g * greenAdjustment, textureColor.b * blueAdjustment, textureColor.a);
13 | }
14 |
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Saturation_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float saturation;
5 |
6 | // Values from "Graphics Shaders: Theory and Practice" by Bailey and Cunningham
7 | const vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);
8 |
9 | void main()
10 | {
11 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
12 | float luminance = dot(textureColor.rgb, luminanceWeighting);
13 | vec3 greyScaleColor = vec3(luminance);
14 |
15 | gl_FragColor = vec4(mix(greyScaleColor, textureColor.rgb, saturation), textureColor.w);
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Saturation_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform lowp float saturation;
5 |
6 | // Values from "Graphics Shaders: Theory and Practice" by Bailey and Cunningham
7 | const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);
8 |
9 | void main()
10 | {
11 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
12 | lowp float luminance = dot(textureColor.rgb, luminanceWeighting);
13 | lowp vec3 greyScaleColor = vec3(luminance);
14 | gl_FragColor = vec4(mix(greyScaleColor, textureColor.rgb, saturation), textureColor.w);
15 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ScreenBlend_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
10 | vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
11 | vec4 whiteColor = vec4(1.0);
12 | gl_FragColor = whiteColor - ((whiteColor - textureColor2) * (whiteColor - textureColor));
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ScreenBlend_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | mediump vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
10 | mediump vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
11 | mediump vec4 whiteColor = vec4(1.0);
12 | gl_FragColor = whiteColor - ((whiteColor - textureColor2) * (whiteColor - textureColor));
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Sharpen.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 | attribute vec4 inputTextureCoordinate;
3 |
4 | uniform float texelWidth;
5 | uniform float texelHeight;
6 | uniform float sharpness;
7 |
8 | varying vec2 textureCoordinate;
9 | varying vec2 leftTextureCoordinate;
10 | varying vec2 rightTextureCoordinate;
11 | varying vec2 topTextureCoordinate;
12 | varying vec2 bottomTextureCoordinate;
13 |
14 | varying float centerMultiplier;
15 | varying float edgeMultiplier;
16 |
17 | void main()
18 | {
19 | gl_Position = position;
20 |
21 | vec2 widthStep = vec2(texelWidth, 0.0);
22 | vec2 heightStep = vec2(0.0, texelHeight);
23 |
24 | textureCoordinate = inputTextureCoordinate.xy;
25 | leftTextureCoordinate = inputTextureCoordinate.xy - widthStep;
26 | rightTextureCoordinate = inputTextureCoordinate.xy + widthStep;
27 | topTextureCoordinate = inputTextureCoordinate.xy + heightStep;
28 | bottomTextureCoordinate = inputTextureCoordinate.xy - heightStep;
29 |
30 | centerMultiplier = 1.0 + 4.0 * sharpness;
31 | edgeMultiplier = sharpness;
32 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Sharpen_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 leftTextureCoordinate;
3 | varying vec2 rightTextureCoordinate;
4 | varying vec2 topTextureCoordinate;
5 | varying vec2 bottomTextureCoordinate;
6 |
7 | varying float centerMultiplier;
8 | varying float edgeMultiplier;
9 |
10 | uniform sampler2D inputImageTexture;
11 |
12 | void main()
13 | {
14 | vec3 textureColor = texture2D(inputImageTexture, textureCoordinate).rgb;
15 | vec3 leftTextureColor = texture2D(inputImageTexture, leftTextureCoordinate).rgb;
16 | vec3 rightTextureColor = texture2D(inputImageTexture, rightTextureCoordinate).rgb;
17 | vec3 topTextureColor = texture2D(inputImageTexture, topTextureCoordinate).rgb;
18 | vec3 bottomTextureColor = texture2D(inputImageTexture, bottomTextureCoordinate).rgb;
19 |
20 | gl_FragColor = vec4((textureColor * centerMultiplier - (leftTextureColor * edgeMultiplier + rightTextureColor * edgeMultiplier + topTextureColor * edgeMultiplier + bottomTextureColor * edgeMultiplier)), texture2D(inputImageTexture, bottomTextureCoordinate).w);
21 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Sharpen_GLES.fsh:
--------------------------------------------------------------------------------
1 | precision highp float;
2 |
3 | varying highp vec2 textureCoordinate;
4 | varying highp vec2 leftTextureCoordinate;
5 | varying highp vec2 rightTextureCoordinate;
6 | varying highp vec2 topTextureCoordinate;
7 | varying highp vec2 bottomTextureCoordinate;
8 |
9 | varying highp float centerMultiplier;
10 | varying highp float edgeMultiplier;
11 |
12 | uniform sampler2D inputImageTexture;
13 |
14 | void main()
15 | {
16 | mediump vec3 textureColor = texture2D(inputImageTexture, textureCoordinate).rgb;
17 | mediump vec3 leftTextureColor = texture2D(inputImageTexture, leftTextureCoordinate).rgb;
18 | mediump vec3 rightTextureColor = texture2D(inputImageTexture, rightTextureCoordinate).rgb;
19 | mediump vec3 topTextureColor = texture2D(inputImageTexture, topTextureCoordinate).rgb;
20 | mediump vec3 bottomTextureColor = texture2D(inputImageTexture, bottomTextureCoordinate).rgb;
21 |
22 | gl_FragColor = vec4((textureColor * centerMultiplier - (leftTextureColor * edgeMultiplier + rightTextureColor * edgeMultiplier + topTextureColor * edgeMultiplier + bottomTextureColor * edgeMultiplier)), texture2D(inputImageTexture, bottomTextureCoordinate).w);
23 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ShiTomasiFeatureDetector_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float sensitivity;
5 |
6 | void main()
7 | {
8 | vec3 derivativeElements = texture2D(inputImageTexture, textureCoordinate).rgb;
9 |
10 | float derivativeDifference = derivativeElements.x - derivativeElements.y;
11 | float zElement = (derivativeElements.z * 2.0) - 1.0;
12 |
13 | // R = Ix^2 + Iy^2 - sqrt( (Ix^2 - Iy^2)^2 + 4 * Ixy * Ixy)
14 | float cornerness = derivativeElements.x + derivativeElements.y - sqrt(derivativeDifference * derivativeDifference + 4.0 * zElement * zElement);
15 |
16 | gl_FragColor = vec4(vec3(cornerness * sensitivity), 1.0);
17 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ShiTomasiFeatureDetector_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform lowp float sensitivity;
5 |
6 | void main()
7 | {
8 | mediump vec3 derivativeElements = texture2D(inputImageTexture, textureCoordinate).rgb;
9 |
10 | mediump float derivativeDifference = derivativeElements.x - derivativeElements.y;
11 | mediump float zElement = (derivativeElements.z * 2.0) - 1.0;
12 |
13 | // R = Ix^2 + Iy^2 - sqrt( (Ix^2 - Iy^2)^2 + 4 * Ixy * Ixy)
14 | mediump float cornerness = derivativeElements.x + derivativeElements.y - sqrt(derivativeDifference * derivativeDifference + 4.0 * zElement * zElement);
15 |
16 | gl_FragColor = vec4(vec3(cornerness * sensitivity), 1.0);
17 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/SoftLightBlend_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | vec4 base = texture2D(inputImageTexture, textureCoordinate);
10 | vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);
11 |
12 | float alphaDivisor = base.a + step(base.a, 0.0); // Protect against a divide-by-zero blacking out things in the output
13 | gl_FragColor = base * (overlay.a * (base / alphaDivisor) + (2.0 * overlay * (1.0 - (base / alphaDivisor)))) + overlay * (1.0 - base.a) + base * (1.0 - overlay.a);
14 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/SoftLightBlend_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | mediump vec4 base = texture2D(inputImageTexture, textureCoordinate);
10 | mediump vec4 overlay = texture2D(inputImageTexture2, textureCoordinate2);
11 |
12 | lowp float alphaDivisor = base.a + step(base.a, 0.0); // Protect against a divide-by-zero blacking out things in the output
13 | gl_FragColor = base * (overlay.a * (base / alphaDivisor) + (2.0 * overlay * (1.0 - (base / alphaDivisor)))) + overlay * (1.0 - base.a) + base * (1.0 - overlay.a);
14 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Solarize_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float threshold;
5 |
6 | const vec3 W = vec3(0.2125, 0.7154, 0.0721);
7 |
8 | void main()
9 | {
10 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
11 | float luminance = dot(textureColor.rgb, W);
12 | float thresholdResult = step(luminance, threshold);
13 | vec3 finalColor = abs(thresholdResult - textureColor.rgb);
14 |
15 | gl_FragColor = vec4(vec3(finalColor), textureColor.w);
16 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Solarize_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform highp float threshold;
5 |
6 | const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);
7 |
8 | void main()
9 | {
10 | highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
11 | highp float luminance = dot(textureColor.rgb, W);
12 | highp float thresholdResult = step(luminance, threshold);
13 | highp vec3 finalColor = abs(thresholdResult - textureColor.rgb);
14 |
15 | gl_FragColor = vec4(finalColor, textureColor.w);
16 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/SourceOverBlend_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
10 | vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate);
11 |
12 | gl_FragColor = mix(textureColor, textureColor2, textureColor2.a);
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/SourceOverBlend_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
10 | lowp vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate);
11 |
12 | gl_FragColor = mix(textureColor, textureColor2, textureColor2.a);
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/SphereRefraction_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform vec2 center;
6 | uniform float radius;
7 | uniform float aspectRatio;
8 | uniform float refractiveIndex;
9 |
10 | void main()
11 | {
12 | vec2 textureCoordinateToUse = vec2(textureCoordinate.x, (textureCoordinate.y * aspectRatio + 0.5 - 0.5 * aspectRatio));
13 | float distanceFromCenter = distance(center, textureCoordinateToUse);
14 | float checkForPresenceWithinSphere = step(distanceFromCenter, radius);
15 |
16 | distanceFromCenter = distanceFromCenter / radius;
17 |
18 | float normalizedDepth = radius * sqrt(1.0 - distanceFromCenter * distanceFromCenter);
19 | vec3 sphereNormal = normalize(vec3(textureCoordinateToUse - center, normalizedDepth));
20 |
21 | vec3 refractedVector = refract(vec3(0.0, 0.0, -1.0), sphereNormal, refractiveIndex);
22 |
23 | gl_FragColor = texture2D(inputImageTexture, (refractedVector.xy + 1.0) * 0.5) * checkForPresenceWithinSphere;
24 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/SphereRefraction_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform highp vec2 center;
6 | uniform highp float radius;
7 | uniform highp float aspectRatio;
8 | uniform highp float refractiveIndex;
9 |
10 | void main()
11 | {
12 | highp vec2 textureCoordinateToUse = vec2(textureCoordinate.x, (textureCoordinate.y * aspectRatio + 0.5 - 0.5 * aspectRatio));
13 | highp float distanceFromCenter = distance(center, textureCoordinateToUse);
14 | lowp float checkForPresenceWithinSphere = step(distanceFromCenter, radius);
15 |
16 | distanceFromCenter = distanceFromCenter / radius;
17 |
18 | highp float normalizedDepth = radius * sqrt(1.0 - distanceFromCenter * distanceFromCenter);
19 | highp vec3 sphereNormal = normalize(vec3(textureCoordinateToUse - center, normalizedDepth));
20 |
21 | highp vec3 refractedVector = refract(vec3(0.0, 0.0, -1.0), sphereNormal, refractiveIndex);
22 |
23 | gl_FragColor = texture2D(inputImageTexture, (refractedVector.xy + 1.0) * 0.5) * checkForPresenceWithinSphere;
24 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/StretchDistortion_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform vec2 center;
6 |
7 | void main()
8 | {
9 | vec2 normCoord = 2.0 * textureCoordinate - 1.0;
10 | vec2 normCenter = 2.0 * center - 1.0;
11 |
12 | normCoord -= normCenter;
13 | vec2 s = sign(normCoord);
14 | normCoord = abs(normCoord);
15 | normCoord = 0.5 * normCoord + 0.5 * smoothstep(0.25, 0.5, normCoord) * normCoord;
16 | normCoord = s * normCoord;
17 |
18 | normCoord += normCenter;
19 |
20 | vec2 textureCoordinateToUse = normCoord / 2.0 + 0.5;
21 |
22 | gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse);
23 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/StretchDistortion_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform highp vec2 center;
6 |
7 | void main()
8 | {
9 | highp vec2 normCoord = 2.0 * textureCoordinate - 1.0;
10 | highp vec2 normCenter = 2.0 * center - 1.0;
11 |
12 | normCoord -= normCenter;
13 | mediump vec2 s = sign(normCoord);
14 | normCoord = abs(normCoord);
15 | normCoord = 0.5 * normCoord + 0.5 * smoothstep(0.25, 0.5, normCoord) * normCoord;
16 | normCoord = s * normCoord;
17 |
18 | normCoord += normCenter;
19 |
20 | mediump vec2 textureCoordinateToUse = normCoord / 2.0 + 0.5;
21 |
22 |
23 | gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse );
24 |
25 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/SubtractBlend_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
10 | vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
11 |
12 | gl_FragColor = vec4(textureColor.rgb - textureColor2.rgb, textureColor.a);
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/SubtractBlend_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | void main()
8 | {
9 | lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
10 | lowp vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
11 |
12 | gl_FragColor = vec4(textureColor.rgb - textureColor2.rgb, textureColor.a);
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Swirl_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform vec2 center;
6 | uniform float radius;
7 | uniform float angle;
8 |
9 | void main()
10 | {
11 | vec2 textureCoordinateToUse = textureCoordinate;
12 | float dist = distance(center, textureCoordinate);
13 | if (dist < radius)
14 | {
15 | textureCoordinateToUse -= center;
16 | float percent = (radius - dist) / radius;
17 | float theta = percent * percent * angle * 8.0;
18 | float s = sin(theta);
19 | float c = cos(theta);
20 | textureCoordinateToUse = vec2(dot(textureCoordinateToUse, vec2(c, -s)), dot(textureCoordinateToUse, vec2(s, c)));
21 | textureCoordinateToUse += center;
22 | }
23 |
24 | gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse );
25 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Swirl_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 |
5 | uniform highp vec2 center;
6 | uniform highp float radius;
7 | uniform highp float angle;
8 |
9 | void main()
10 | {
11 | highp vec2 textureCoordinateToUse = textureCoordinate;
12 | highp float dist = distance(center, textureCoordinate);
13 | if (dist < radius)
14 | {
15 | textureCoordinateToUse -= center;
16 | highp float percent = (radius - dist) / radius;
17 | highp float theta = percent * percent * angle * 8.0;
18 | highp float s = sin(theta);
19 | highp float c = cos(theta);
20 | textureCoordinateToUse = vec2(dot(textureCoordinateToUse, vec2(c, -s)), dot(textureCoordinateToUse, vec2(s, c)));
21 | textureCoordinateToUse += center;
22 | }
23 |
24 | gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse );
25 |
26 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/ThreeInput.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 | attribute vec4 inputTextureCoordinate;
3 | attribute vec4 inputTextureCoordinate2;
4 | attribute vec4 inputTextureCoordinate3;
5 |
6 | varying vec2 textureCoordinate;
7 | varying vec2 textureCoordinate2;
8 | varying vec2 textureCoordinate3;
9 |
10 | void main()
11 | {
12 | gl_Position = position;
13 | textureCoordinate = inputTextureCoordinate.xy;
14 | textureCoordinate2 = inputTextureCoordinate2.xy;
15 | textureCoordinate3 = inputTextureCoordinate3.xy;
16 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/TiltShift_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | uniform float topFocusLevel;
8 | uniform float bottomFocusLevel;
9 | uniform float focusFallOffRate;
10 |
11 | void main()
12 | {
13 | vec4 sharpImageColor = texture2D(inputImageTexture, textureCoordinate);
14 | vec4 blurredImageColor = texture2D(inputImageTexture2, textureCoordinate2);
15 |
16 | float blurIntensity = 1.0 - smoothstep(topFocusLevel - focusFallOffRate, topFocusLevel, textureCoordinate2.y);
17 | blurIntensity += smoothstep(bottomFocusLevel, bottomFocusLevel + focusFallOffRate, textureCoordinate2.y);
18 |
19 | gl_FragColor = mix(sharpImageColor, blurredImageColor, blurIntensity);
20 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/TiltShift_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | uniform highp float topFocusLevel;
8 | uniform highp float bottomFocusLevel;
9 | uniform highp float focusFallOffRate;
10 |
11 | void main()
12 | {
13 | lowp vec4 sharpImageColor = texture2D(inputImageTexture, textureCoordinate);
14 | lowp vec4 blurredImageColor = texture2D(inputImageTexture2, textureCoordinate2);
15 |
16 | lowp float blurIntensity = 1.0 - smoothstep(topFocusLevel - focusFallOffRate, topFocusLevel, textureCoordinate2.y);
17 | blurIntensity += smoothstep(bottomFocusLevel, bottomFocusLevel + focusFallOffRate, textureCoordinate2.y);
18 |
19 | gl_FragColor = mix(sharpImageColor, blurredImageColor, blurIntensity);
20 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Transform.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 | attribute vec4 inputTextureCoordinate;
3 |
4 | uniform mat4 transformMatrix;
5 | uniform mat4 orthographicMatrix;
6 |
7 | varying vec2 textureCoordinate;
8 |
9 | void main()
10 | {
11 | gl_Position = transformMatrix * vec4(position.xyz, 1.0) * orthographicMatrix;
12 | textureCoordinate = inputTextureCoordinate.xy;
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/TwoInput.vsh:
--------------------------------------------------------------------------------
1 | attribute vec4 position;
2 | attribute vec4 inputTextureCoordinate;
3 | attribute vec4 inputTextureCoordinate2;
4 |
5 | varying vec2 textureCoordinate;
6 | varying vec2 textureCoordinate2;
7 |
8 | void main()
9 | {
10 | gl_Position = position;
11 | textureCoordinate = inputTextureCoordinate.xy;
12 | textureCoordinate2 = inputTextureCoordinate2.xy;
13 | }
14 |
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/UnsharpMask_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | uniform float intensity;
8 |
9 | void main()
10 | {
11 | vec4 sharpImageColor = texture2D(inputImageTexture, textureCoordinate);
12 | vec3 blurredImageColor = texture2D(inputImageTexture2, textureCoordinate2).rgb;
13 |
14 | gl_FragColor = vec4(sharpImageColor.rgb * intensity + blurredImageColor * (1.0 - intensity), sharpImageColor.a);
15 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/UnsharpMask_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | uniform highp float intensity;
8 |
9 | void main()
10 | {
11 | lowp vec4 sharpImageColor = texture2D(inputImageTexture, textureCoordinate);
12 | lowp vec3 blurredImageColor = texture2D(inputImageTexture2, textureCoordinate2).rgb;
13 |
14 | gl_FragColor = vec4(sharpImageColor.rgb * intensity + blurredImageColor * (1.0 - intensity), sharpImageColor.a);
15 | }
16 |
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Vibrance_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform float vibrance;
5 |
6 | void main() {
7 | vec4 color = texture2D(inputImageTexture, textureCoordinate);
8 | float average = (color.r + color.g + color.b) / 3.0;
9 | float mx = max(color.r, max(color.g, color.b));
10 | float amt = (mx - average) * (-vibrance * 3.0);
11 | color.rgb = mix(color.rgb, vec3(mx), amt);
12 | gl_FragColor = color;
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Vibrance_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 |
3 | uniform sampler2D inputImageTexture;
4 | uniform lowp float vibrance;
5 |
6 | void main() {
7 | lowp vec4 color = texture2D(inputImageTexture, textureCoordinate);
8 | lowp float average = (color.r + color.g + color.b) / 3.0;
9 | lowp float mx = max(color.r, max(color.g, color.b));
10 | lowp float amt = (mx - average) * (-vibrance * 3.0);
11 | color.rgb = mix(color.rgb, vec3(mx), amt);
12 | gl_FragColor = color;
13 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Vignette_GL.fsh:
--------------------------------------------------------------------------------
1 | uniform sampler2D inputImageTexture;
2 | varying vec2 textureCoordinate;
3 |
4 | uniform vec2 vignetteCenter;
5 | uniform vec3 vignetteColor;
6 | uniform float vignetteStart;
7 | uniform float vignetteEnd;
8 |
9 | void main()
10 | {
11 | vec4 sourceImageColor = texture2D(inputImageTexture, textureCoordinate);
12 | float d = distance(textureCoordinate, vec2(vignetteCenter.x, vignetteCenter.y));
13 | float percent = smoothstep(vignetteStart, vignetteEnd, d);
14 | gl_FragColor = vec4(mix(sourceImageColor.rgb, vignetteColor, percent), sourceImageColor.a);
15 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/Vignette_GLES.fsh:
--------------------------------------------------------------------------------
1 | uniform sampler2D inputImageTexture;
2 | varying highp vec2 textureCoordinate;
3 |
4 | uniform lowp vec2 vignetteCenter;
5 | uniform lowp vec3 vignetteColor;
6 | uniform highp float vignetteStart;
7 | uniform highp float vignetteEnd;
8 |
9 | void main()
10 | {
11 | lowp vec4 sourceImageColor = texture2D(inputImageTexture, textureCoordinate);
12 | lowp float d = distance(textureCoordinate, vec2(vignetteCenter.x, vignetteCenter.y));
13 | lowp float percent = smoothstep(vignetteStart, vignetteEnd, d);
14 | gl_FragColor = vec4(mix(sourceImageColor.rgb, vignetteColor, percent), sourceImageColor.a);
15 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/WhiteBalance_GL.fsh:
--------------------------------------------------------------------------------
1 | uniform sampler2D inputImageTexture;
2 | varying vec2 textureCoordinate;
3 |
4 | uniform float temperature;
5 | uniform float tint;
6 |
7 | const vec3 warmFilter = vec3(0.93, 0.54, 0.0);
8 |
9 | const mat3 RGBtoYIQ = mat3(0.299, 0.587, 0.114, 0.596, -0.274, -0.322, 0.212, -0.523, 0.311);
10 | const mat3 YIQtoRGB = mat3(1.0, 0.956, 0.621, 1.0, -0.272, -0.647, 1.0, -1.105, 1.702);
11 |
12 | void main()
13 | {
14 | vec4 source = texture2D(inputImageTexture, textureCoordinate);
15 |
16 | vec3 yiq = RGBtoYIQ * source.rgb; //adjusting tint
17 | yiq.b = clamp(yiq.b + tint*0.5226*0.1, -0.5226, 0.5226);
18 | vec3 rgb = YIQtoRGB * yiq;
19 |
20 | vec3 processed = vec3(
21 | (rgb.r < 0.5 ? (2.0 * rgb.r * warmFilter.r) : (1.0 - 2.0 * (1.0 - rgb.r) * (1.0 - warmFilter.r))), //adjusting temperature
22 | (rgb.g < 0.5 ? (2.0 * rgb.g * warmFilter.g) : (1.0 - 2.0 * (1.0 - rgb.g) * (1.0 - warmFilter.g))),
23 | (rgb.b < 0.5 ? (2.0 * rgb.b * warmFilter.b) : (1.0 - 2.0 * (1.0 - rgb.b) * (1.0 - warmFilter.b))));
24 |
25 | gl_FragColor = vec4(mix(rgb, processed, temperature), source.a);
26 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/WhiteBalance_GLES.fsh:
--------------------------------------------------------------------------------
1 | uniform sampler2D inputImageTexture;
2 | varying highp vec2 textureCoordinate;
3 |
4 | uniform lowp float temperature;
5 | uniform lowp float tint;
6 |
7 | const lowp vec3 warmFilter = vec3(0.93, 0.54, 0.0);
8 |
9 | const mediump mat3 RGBtoYIQ = mat3(0.299, 0.587, 0.114, 0.596, -0.274, -0.322, 0.212, -0.523, 0.311);
10 | const mediump mat3 YIQtoRGB = mat3(1.0, 0.956, 0.621, 1.0, -0.272, -0.647, 1.0, -1.105, 1.702);
11 |
12 | void main()
13 | {
14 | lowp vec4 source = texture2D(inputImageTexture, textureCoordinate);
15 |
16 | mediump vec3 yiq = RGBtoYIQ * source.rgb; //adjusting tint
17 | yiq.b = clamp(yiq.b + tint*0.5226*0.1, -0.5226, 0.5226);
18 | lowp vec3 rgb = YIQtoRGB * yiq;
19 |
20 | lowp vec3 processed = vec3(
21 | (rgb.r < 0.5 ? (2.0 * rgb.r * warmFilter.r) : (1.0 - 2.0 * (1.0 - rgb.r) * (1.0 - warmFilter.r))), //adjusting temperature
22 | (rgb.g < 0.5 ? (2.0 * rgb.g * warmFilter.g) : (1.0 - 2.0 * (1.0 - rgb.g) * (1.0 - warmFilter.g))),
23 | (rgb.b < 0.5 ? (2.0 * rgb.b * warmFilter.b) : (1.0 - 2.0 * (1.0 - rgb.b) * (1.0 - warmFilter.b))));
24 |
25 | gl_FragColor = vec4(mix(rgb, processed, temperature), source.a);
26 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/YUVConversionFullRangeUVPlanar_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 | varying vec2 textureCoordinate3;
4 |
5 | uniform sampler2D inputImageTexture;
6 | uniform sampler2D inputImageTexture2;
7 | uniform sampler2D inputImageTexture3;
8 |
9 | uniform mat3 colorConversionMatrix;
10 |
11 | void main()
12 | {
13 | vec3 yuv;
14 |
15 | yuv.x = texture2D(inputImageTexture, textureCoordinate).r;
16 | yuv.y = texture2D(inputImageTexture2, textureCoordinate).r - 0.5;
17 | yuv.z = texture2D(inputImageTexture3, textureCoordinate).r - 0.5;
18 | vec3 rgb = colorConversionMatrix * yuv;
19 |
20 | gl_FragColor = vec4(rgb, 1.0);
21 | }
22 |
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/YUVConversionFullRangeUVPlanar_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 | varying highp vec2 textureCoordinate3;
4 |
5 | uniform sampler2D inputImageTexture;
6 | uniform sampler2D inputImageTexture2;
7 | uniform sampler2D inputImageTexture3;
8 |
9 | uniform mediump mat3 colorConversionMatrix;
10 |
11 | void main()
12 | {
13 | mediump vec3 yuv;
14 |
15 | yuv.x = texture2D(inputImageTexture, textureCoordinate).r;
16 | yuv.y = texture2D(inputImageTexture2, textureCoordinate).r - 0.5;
17 | yuv.z = texture2D(inputImageTexture3, textureCoordinate).r - 0.5;
18 | lowp vec3 rgb = colorConversionMatrix * yuv;
19 |
20 | gl_FragColor = vec4(rgb, 1.0);
21 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/YUVConversionFullRange_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | uniform mat3 colorConversionMatrix;
8 |
9 | void main()
10 | {
11 | vec3 yuv;
12 |
13 | yuv.x = texture2D(inputImageTexture, textureCoordinate).r;
14 | yuv.yz = texture2D(inputImageTexture2, textureCoordinate).ra - vec2(0.5, 0.5);
15 | vec3 rgb = colorConversionMatrix * yuv;
16 |
17 | gl_FragColor = vec4(rgb, 1.0);
18 | }
19 |
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/YUVConversionFullRange_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | uniform mediump mat3 colorConversionMatrix;
8 |
9 | void main()
10 | {
11 | mediump vec3 yuv;
12 |
13 | yuv.x = texture2D(inputImageTexture, textureCoordinate).r;
14 | yuv.yz = texture2D(inputImageTexture2, textureCoordinate).ra - vec2(0.5, 0.5);
15 | lowp vec3 rgb = colorConversionMatrix * yuv;
16 |
17 | gl_FragColor = vec4(rgb, 1.0);
18 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/YUVConversionVideoRange_GL.fsh:
--------------------------------------------------------------------------------
1 | varying vec2 textureCoordinate;
2 | varying vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | uniform mat3 colorConversionMatrix;
8 |
9 | void main()
10 | {
11 | vec3 yuv;
12 |
13 | yuv.x = texture2D(inputImageTexture, textureCoordinate).r - (16.0/255.0);
14 | yuv.yz = texture2D(inputImageTexture2, textureCoordinate).ra - vec2(0.5, 0.5);
15 | vec3 rgb = colorConversionMatrix * yuv;
16 |
17 | gl_FragColor = vec4(rgb, 1.0);
18 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Shaders/YUVConversionVideoRange_GLES.fsh:
--------------------------------------------------------------------------------
1 | varying highp vec2 textureCoordinate;
2 | varying highp vec2 textureCoordinate2;
3 |
4 | uniform sampler2D inputImageTexture;
5 | uniform sampler2D inputImageTexture2;
6 |
7 | uniform mediump mat3 colorConversionMatrix;
8 |
9 | void main()
10 | {
11 | mediump vec3 yuv;
12 |
13 | yuv.x = texture2D(inputImageTexture, textureCoordinate).r - (16.0/255.0);
14 | yuv.yz = texture2D(inputImageTexture2, textureCoordinate).ra - vec2(0.5, 0.5);
15 | lowp vec3 rgb = colorConversionMatrix * yuv;
16 |
17 | gl_FragColor = vec4(rgb, 1.0);
18 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Sharpen.swift:
--------------------------------------------------------------------------------
1 | public class Sharpen: BasicOperation {
2 | public var sharpness:Float = 0.0 { didSet { uniformSettings["sharpness"] = sharpness } }
3 | public var overriddenTexelSize:Size?
4 |
5 | public init() {
6 | super.init(vertexShader:SharpenVertexShader, fragmentShader:SharpenFragmentShader, numberOfInputs:1)
7 |
8 | ({sharpness = 0.0})()
9 | }
10 |
11 | override func configureFramebufferSpecificUniforms(_ inputFramebuffer:Framebuffer) {
12 | let outputRotation = overriddenOutputRotation ?? inputFramebuffer.orientation.rotationNeededForOrientation(.portrait)
13 | let texelSize = overriddenTexelSize ?? inputFramebuffer.texelSize(for:outputRotation)
14 | uniformSettings["texelWidth"] = texelSize.width
15 | uniformSettings["texelHeight"] = texelSize.height
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/framework/Source/Operations/ShiTomasiFeatureDetector.swift:
--------------------------------------------------------------------------------
1 | /** Shi-Tomasi feature detector
2 |
3 | This is the Shi-Tomasi feature detector, as described in
4 | J. Shi and C. Tomasi. Good features to track. Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 593-600, June 1994.
5 | */
6 |
7 | public class ShiTomasiFeatureDetector: HarrisCornerDetector {
8 | public init() {
9 | super.init(fragmentShader:ShiTomasiFeatureDetectorFragmentShader)
10 | }
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/SketchFilter.swift:
--------------------------------------------------------------------------------
1 | public class SketchFilter: TextureSamplingOperation {
2 | public var edgeStrength:Float = 1.0 { didSet { uniformSettings["edgeStrength"] = edgeStrength } }
3 |
4 | public init() {
5 | super.init(fragmentShader:SketchFragmentShader)
6 |
7 | ({edgeStrength = 1.0})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/SmoothToonFilter.swift:
--------------------------------------------------------------------------------
1 | public class SmoothToonFilter: OperationGroup {
2 | public var blurRadiusInPixels: Float = 2.0 { didSet { gaussianBlur.blurRadiusInPixels = blurRadiusInPixels } }
3 | public var threshold: Float = 0.2 { didSet { toonFilter.threshold = threshold } }
4 | public var quantizationLevels: Float = 10.0 { didSet { toonFilter.quantizationLevels = quantizationLevels } }
5 |
6 | let gaussianBlur = GaussianBlur()
7 | let toonFilter = ToonFilter()
8 |
9 | public override init() {
10 | super.init()
11 |
12 | ({blurRadiusInPixels = 2.0})()
13 | ({threshold = 0.2})()
14 | ({quantizationLevels = 10.0})()
15 |
16 | self.configureGroup{input, output in
17 | input --> self.gaussianBlur --> self.toonFilter --> output
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/SobelEdgeDetection.swift:
--------------------------------------------------------------------------------
1 | public class SobelEdgeDetection: TextureSamplingOperation {
2 | public var edgeStrength:Float = 1.0 { didSet { uniformSettings["edgeStrength"] = edgeStrength } }
3 |
4 | public init() {
5 | super.init(fragmentShader:SobelEdgeDetectionFragmentShader)
6 |
7 | ({edgeStrength = 1.0})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/SoftElegance.swift:
--------------------------------------------------------------------------------
1 | #if !os(Linux)
2 | public class SoftElegance: OperationGroup {
3 | let lookup1 = LookupFilter()
4 | let lookup2 = LookupFilter()
5 | let gaussianBlur = GaussianBlur()
6 | let alphaBlend = AlphaBlend()
7 |
8 | public override init() {
9 | super.init()
10 |
11 | self.configureGroup{input, output in
12 | self.lookup1.lookupImage = PictureInput(imageName:"lookup_soft_elegance_1.png")
13 | self.lookup2.lookupImage = PictureInput(imageName:"lookup_soft_elegance_2.png")
14 | self.gaussianBlur.blurRadiusInPixels = 10.0
15 | self.alphaBlend.mix = 0.14
16 |
17 | input --> self.lookup1 --> self.alphaBlend --> self.lookup2 --> output
18 | self.lookup1 --> self.gaussianBlur --> self.alphaBlend
19 | }
20 | }
21 | }
22 | #endif
23 |
--------------------------------------------------------------------------------
/framework/Source/Operations/SoftLightBlend.swift:
--------------------------------------------------------------------------------
1 | public class SoftLightBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:SoftLightBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Solarize.swift:
--------------------------------------------------------------------------------
1 | public class Solarize: BasicOperation {
2 | public var threshold:Float = 0.5 { didSet { uniformSettings["threshold"] = threshold } }
3 |
4 | public init() {
5 | super.init(fragmentShader:SolarizeFragmentShader, numberOfInputs:1)
6 |
7 | ({threshold = 0.5})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/SolidColorGenerator.swift:
--------------------------------------------------------------------------------
1 | public class SolidColorGenerator: ImageGenerator {
2 |
3 | public func renderColor(_ color:Color) {
4 | imageFramebuffer.activateFramebufferForRendering()
5 |
6 | clearFramebufferWithColor(color)
7 |
8 | notifyTargets()
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/framework/Source/Operations/SourceOverBlend.swift:
--------------------------------------------------------------------------------
1 | public class SourceOverBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:SourceOverBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/SphereRefraction.swift:
--------------------------------------------------------------------------------
1 | public class SphereRefraction: BasicOperation {
2 | public var radius:Float = 0.25 { didSet { uniformSettings["radius"] = radius } }
3 | public var refractiveIndex:Float = 0.71 { didSet { uniformSettings["refractiveIndex"] = refractiveIndex } }
4 | public var center:Position = Position.center { didSet { uniformSettings["center"] = center } }
5 |
6 | public init() {
7 | super.init(fragmentShader:SphereRefractionFragmentShader, numberOfInputs:1)
8 |
9 | ({radius = 0.25})()
10 | ({refractiveIndex = 0.71})()
11 | ({center = Position.center})()
12 |
13 | self.backgroundColor = Color(red:0.0, green:0.0, blue:0.0, alpha:0.0)
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/framework/Source/Operations/StretchDistortion.swift:
--------------------------------------------------------------------------------
1 | public class StretchDistortion: BasicOperation {
2 | public var center:Position = Position.center { didSet { uniformSettings["center"] = center } }
3 |
4 | public init() {
5 | super.init(fragmentShader:StretchDistortionFragmentShader, numberOfInputs:1)
6 |
7 | ({center = Position.center})()
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/framework/Source/Operations/SubtractBlend.swift:
--------------------------------------------------------------------------------
1 | public class SubtractBlend: BasicOperation {
2 | public init() {
3 | super.init(fragmentShader:SubtractBlendFragmentShader, numberOfInputs:2)
4 | }
5 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/SwirlDistortion.swift:
--------------------------------------------------------------------------------
1 | public class SwirlDistortion: BasicOperation {
2 | public var radius:Float = 0.5 { didSet { uniformSettings["radius"] = radius } }
3 | public var angle:Float = 1.0 { didSet { uniformSettings["angle"] = angle } }
4 | public var center:Position = Position.center { didSet { uniformSettings["center"] = center } }
5 |
6 | public init() {
7 | super.init(fragmentShader:SwirlFragmentShader, numberOfInputs:1)
8 |
9 | ({radius = 0.5})()
10 | ({angle = 1.0})()
11 | ({center = Position.center})()
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/framework/Source/Operations/ThresholdSketch.swift:
--------------------------------------------------------------------------------
1 | public class ThresholdSketchFilter: TextureSamplingOperation {
2 | public var edgeStrength:Float = 1.0 { didSet { uniformSettings["edgeStrength"] = edgeStrength } }
3 | public var threshold:Float = 0.25 { didSet { uniformSettings["threshold"] = threshold } }
4 |
5 | public init() {
6 | super.init(fragmentShader:ThresholdSketchFragmentShader)
7 |
8 | ({edgeStrength = 1.0})()
9 | ({threshold = 0.25})()
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/framework/Source/Operations/ThresholdSobelEdgeDetection.swift:
--------------------------------------------------------------------------------
1 | public class ThresholdSobelEdgeDetection: TextureSamplingOperation {
2 | public var edgeStrength:Float = 1.0 { didSet { uniformSettings["edgeStrength"] = edgeStrength } }
3 | public var threshold:Float = 0.25 { didSet { uniformSettings["threshold"] = threshold } }
4 |
5 | public init() {
6 | super.init(fragmentShader:ThresholdEdgeDetectionFragmentShader)
7 |
8 | ({edgeStrength = 1.0})()
9 | ({threshold = 0.25})()
10 | }
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/TiltShift.swift:
--------------------------------------------------------------------------------
1 | public class TiltShift: OperationGroup {
2 | public var blurRadiusInPixels:Float = 7.0 { didSet { gaussianBlur.blurRadiusInPixels = blurRadiusInPixels } }
3 | public var topFocusLevel:Float = 0.4 { didSet { tiltShift.uniformSettings["topFocusLevel"] = topFocusLevel } }
4 | public var bottomFocusLevel:Float = 0.6 { didSet { tiltShift.uniformSettings["bottomFocusLevel"] = bottomFocusLevel } }
5 | public var focusFallOffRate:Float = 0.2 { didSet { tiltShift.uniformSettings["focusFallOffRate"] = focusFallOffRate } }
6 |
7 | let gaussianBlur = GaussianBlur()
8 | let tiltShift = BasicOperation(fragmentShader:TiltShiftFragmentShader, numberOfInputs:2)
9 |
10 | public override init() {
11 | super.init()
12 |
13 | ({blurRadiusInPixels = 7.0})()
14 | ({topFocusLevel = 0.4})()
15 | ({bottomFocusLevel = 0.6})()
16 | ({focusFallOffRate = 0.2})()
17 |
18 | self.configureGroup{input, output in
19 | input --> self.tiltShift --> output
20 | input --> self.gaussianBlur --> self.tiltShift
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/ToonFilter.swift:
--------------------------------------------------------------------------------
1 | public class ToonFilter: TextureSamplingOperation {
2 | public var threshold:Float = 0.2 { didSet { uniformSettings["threshold"] = threshold } }
3 | public var quantizationLevels:Float = 10.0 { didSet { uniformSettings["quantizationLevels"] = quantizationLevels } }
4 |
5 | public init() {
6 | super.init(fragmentShader:ToonFragmentShader)
7 |
8 | ({threshold = 0.2})()
9 | ({quantizationLevels = 10.0})()
10 | }
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/UnsharpMask.swift:
--------------------------------------------------------------------------------
1 | public class UnsharpMask: OperationGroup {
2 | public var blurRadiusInPixels: Float { didSet { gaussianBlur.blurRadiusInPixels = blurRadiusInPixels } }
3 | public var intensity: Float = 1.0 { didSet { unsharpMask.uniformSettings["intensity"] = intensity } }
4 |
5 | let gaussianBlur = GaussianBlur()
6 | let unsharpMask = BasicOperation(fragmentShader:UnsharpMaskFragmentShader, numberOfInputs:2)
7 |
8 | public override init() {
9 | blurRadiusInPixels = 4.0
10 | super.init()
11 |
12 | ({intensity = 1.0})()
13 |
14 | self.configureGroup{input, output in
15 | input --> self.unsharpMask
16 | input --> self.gaussianBlur --> self.unsharpMask --> output
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Vibrance.swift:
--------------------------------------------------------------------------------
1 | public class Vibrance: BasicOperation {
2 | public var vibrance:Float = 0.0 { didSet { uniformSettings["vibrance"] = vibrance } }
3 |
4 | public init() {
5 | super.init(fragmentShader:VibranceFragmentShader, numberOfInputs:1)
6 |
7 | ({vibrance = 0.0})()
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/Vignette.swift:
--------------------------------------------------------------------------------
1 | public class Vignette: BasicOperation {
2 | public var center:Position = Position.center { didSet { uniformSettings["vignetteCenter"] = center } }
3 | public var color:Color = Color.black { didSet { uniformSettings["vignetteColor"] = color } }
4 | public var start:Float = 0.3 { didSet { uniformSettings["vignetteStart"] = start } }
5 | public var end:Float = 0.75 { didSet { uniformSettings["vignetteEnd"] = end } }
6 |
7 | public init() {
8 | super.init(fragmentShader:VignetteFragmentShader, numberOfInputs:1)
9 |
10 | ({center = Position.center})()
11 | ({color = Color.black})()
12 | ({start = 0.3})()
13 | ({end = 0.75})()
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/framework/Source/Operations/WhiteBalance.swift:
--------------------------------------------------------------------------------
1 | public class WhiteBalance: BasicOperation {
2 | public var temperature:Float = 5000.0 { didSet { uniformSettings["temperature"] = temperature < 5000.0 ? 0.0004 * (temperature - 5000.0) : 0.00006 * (temperature - 5000.0) } }
3 | public var tint:Float = 0.0 { didSet { uniformSettings["tint"] = tint / 100.0 } }
4 |
5 | public init() {
6 | super.init(fragmentShader:WhiteBalanceFragmentShader, numberOfInputs:1)
7 |
8 | ({temperature = 5000.0})()
9 | ({tint = 0.0})()
10 | }
11 | }
--------------------------------------------------------------------------------
/framework/Source/Operations/ZoomBlur.swift:
--------------------------------------------------------------------------------
1 | public class ZoomBlur: BasicOperation {
2 | public var blurSize:Float = 1.0 { didSet { uniformSettings["blurSize"] = blurSize } }
3 | public var blurCenter:Position = Position.center { didSet { uniformSettings["blurCenter"] = blurCenter } }
4 |
5 | public init() {
6 | super.init(fragmentShader:ZoomBlurFragmentShader, numberOfInputs:1)
7 |
8 | ({blurSize = 1.0})()
9 | ({blurCenter = Position.center})()
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/framework/Source/Operations/iOSBlur.swift:
--------------------------------------------------------------------------------
1 | public class iOSBlur: OperationGroup {
2 | public var blurRadiusInPixels:Float = 48.0 { didSet { gaussianBlur.blurRadiusInPixels = blurRadiusInPixels } }
3 | public var saturation:Float = 0.8 { didSet { saturationFilter.saturation = saturation } }
4 | public var rangeReductionFactor:Float = 0.6 { didSet { luminanceRange.rangeReductionFactor = rangeReductionFactor } }
5 |
6 | let saturationFilter = SaturationAdjustment()
7 | let gaussianBlur = GaussianBlur()
8 | let luminanceRange = LuminanceRangeReduction()
9 |
10 | public override init() {
11 | super.init()
12 |
13 | ({blurRadiusInPixels = 48.0})()
14 | ({saturation = 0.8})()
15 | ({rangeReductionFactor = 0.6})()
16 |
17 | self.configureGroup{input, output in
18 | input --> self.saturationFilter --> self.gaussianBlur --> self.luminanceRange --> output
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/framework/Source/Position.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | #if os(iOS)
4 | import UIKit
5 | #endif
6 |
7 | public struct Position {
8 | public let x:Float
9 | public let y:Float
10 | public let z:Float?
11 |
12 | public init (_ x:Float, _ y:Float, _ z:Float? = nil) {
13 | self.x = x
14 | self.y = y
15 | self.z = z
16 | }
17 |
18 | #if !os(Linux)
19 | public init(point:CGPoint) {
20 | self.x = Float(point.x)
21 | self.y = Float(point.y)
22 | self.z = nil
23 | }
24 | #endif
25 |
26 | public static let center = Position(0.5, 0.5)
27 | public static let zero = Position(0.0, 0.0)
28 | }
29 |
--------------------------------------------------------------------------------
/framework/Source/Size.swift:
--------------------------------------------------------------------------------
1 | public struct Size {
2 | public let width:Float
3 | public let height:Float
4 |
5 | public init(width:Float, height:Float) {
6 | self.width = width
7 | self.height = height
8 | }
9 | }
--------------------------------------------------------------------------------
/framework/Source/TextureInput.swift:
--------------------------------------------------------------------------------
1 | #if canImport(OpenGL)
2 | import OpenGL.GL3
3 | #endif
4 |
5 | #if canImport(OpenGLES)
6 | import OpenGLES
7 | #endif
8 |
9 | #if canImport(COpenGLES)
10 | import COpenGLES.gles2
11 | #endif
12 |
13 | #if canImport(COpenGL)
14 | import COpenGL
15 | #endif
16 |
17 | public class TextureInput: ImageSource {
18 | public let targets = TargetContainer()
19 |
20 | let textureFramebuffer:Framebuffer
21 |
22 | public init(texture:GLuint, size:Size, orientation:ImageOrientation = .portrait) {
23 | do {
24 | textureFramebuffer = try Framebuffer(context:sharedImageProcessingContext, orientation:orientation, size:GLSize(size), textureOnly:true, overriddenTexture:texture)
25 | } catch {
26 | fatalError("Could not create framebuffer for custom input texture.")
27 | }
28 | }
29 |
30 | public func processTexture() {
31 | updateTargetsWithFramebuffer(textureFramebuffer)
32 | }
33 |
34 | public func transmitPreviousImage(to target:ImageConsumer, atIndex:UInt) {
35 | textureFramebuffer.lock()
36 | target.newFramebufferAvailable(textureFramebuffer, fromSourceIndex:atIndex)
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/framework/Source/TextureOutput.swift:
--------------------------------------------------------------------------------
1 | #if canImport(OpenGL)
2 | import OpenGL.GL3
3 | #endif
4 |
5 | #if canImport(OpenGLES)
6 | import OpenGLES
7 | #endif
8 |
9 | #if canImport(COpenGLES)
10 | import COpenGLES.gles2
11 | #endif
12 |
13 | #if canImport(COpenGL)
14 | import COpenGL
15 | #endif
16 |
17 | public class TextureOutput: ImageConsumer {
18 | public var newTextureAvailableCallback:((GLuint) -> ())?
19 |
20 | public let sources = SourceContainer()
21 | public let maximumInputs:UInt = 1
22 |
23 | public func newFramebufferAvailable(_ framebuffer:Framebuffer, fromSourceIndex:UInt) {
24 | newTextureAvailableCallback?(framebuffer.texture)
25 | // TODO: Maybe extend the lifetime of the texture past this if needed
26 | framebuffer.unlock()
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/framework/Source/TextureSamplingOperation.swift:
--------------------------------------------------------------------------------
1 | open class TextureSamplingOperation: BasicOperation {
2 | public var overriddenTexelSize:Size?
3 |
4 | public init(vertexShader:String = NearbyTexelSamplingVertexShader, fragmentShader:String, numberOfInputs:UInt = 1) {
5 | super.init(vertexShader:vertexShader, fragmentShader:fragmentShader, numberOfInputs:numberOfInputs)
6 | }
7 |
8 | override func configureFramebufferSpecificUniforms(_ inputFramebuffer:Framebuffer) {
9 | let outputRotation = overriddenOutputRotation ?? inputFramebuffer.orientation.rotationNeededForOrientation(.portrait)
10 | let texelSize = overriddenTexelSize ?? inputFramebuffer.texelSize(for:outputRotation)
11 | uniformSettings["texelWidth"] = texelSize.width
12 | uniformSettings["texelHeight"] = texelSize.height
13 | }
14 | }
15 |
--------------------------------------------------------------------------------