Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Sharpen operation, update README #135

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
249 changes: 217 additions & 32 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/AddBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fragment half4 addBlendFragment(TwoInputVertexIO fragmentInput [[stage_in]],
constexpr sampler quadSampler;
half4 base = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 overlay = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 overlay = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

half r;
if (overlay.r * base.a + base.r * overlay.a >= overlay.a * base.a) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/AlphaBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fragment half4 alphaBlendFragment(TwoInputVertexIO fragmentInput [[stage_in]],
constexpr sampler quadSampler;
half4 textureColor = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 textureColor2 = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 textureColor2 = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

return half4(mix(textureColor.rgb, textureColor2.rgb, textureColor2.a * half(uniform.mixturePercent)), textureColor.a);
}
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/ChromaKeyBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fragment half4 chromaKeyBlendFragment(TwoInputVertexIO fragmentInput [[stage_in]
constexpr sampler quadSampler;
half4 textureColor = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 textureColor2 = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 textureColor2 = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

half maskY = 0.2989h * uniform.colorToReplace.r + 0.5866h * uniform.colorToReplace.g + 0.1145h * uniform.colorToReplace.b;
half maskCr = 0.7132h * (uniform.colorToReplace.r - maskY);
Expand Down
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/ColorBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fragment half4 colorBlendFragment(TwoInputVertexIO fragmentInput [[stage_in]],
constexpr sampler quadSampler;
half4 base = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 overlay = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 overlay = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

return half4(base.rgb * (1.0h - overlay.a) + setlum(overlay.rgb, lum(base.rgb)) * overlay.a, base.a);
}
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/ColorBurnBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fragment half4 colorBurnBlendFragment(TwoInputVertexIO fragmentInput [[stage_in]
constexpr sampler quadSampler;
half4 textureColor = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 textureColor2 = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 textureColor2 = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);
half4 whiteColor = half4(1.0);

return whiteColor - (whiteColor - textureColor) / textureColor2;
Expand Down
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/ColorDodgeBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fragment half4 colorDodgeBlendFragment(TwoInputVertexIO fragmentInput [[stage_in
constexpr sampler quadSampler;
half4 base = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 overlay = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 overlay = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

half3 baseOverlayAlphaProduct = half3(overlay.a * base.a);
half3 rightHandProduct = overlay.rgb * (1.0h - base.a) + base.rgb * (1.0h - overlay.a);
Expand Down
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/DarkenBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fragment half4 darkenBlendFragment(TwoInputVertexIO fragmentInput [[stage_in]],
constexpr sampler quadSampler;
half4 base = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 overlay = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 overlay = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

return half4(min(overlay.rgb * base.a, base.rgb * overlay.a) + overlay.rgb * (1.0h - base.a) + base.rgb * (1.0h - overlay.a), 1.0h);
}
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/DifferenceBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fragment half4 differenceBlendFragment(TwoInputVertexIO fragmentInput [[stage_in
constexpr sampler quadSampler;
half4 textureColor = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 textureColor2 = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 textureColor2 = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

return half4(abs(textureColor2.rgb - textureColor.rgb), textureColor.a);
}
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/DissolveBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fragment half4 dissolveBlendFragment(TwoInputVertexIO fragmentInput [[stage_in]]
constexpr sampler quadSampler;
half4 textureColor = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 textureColor2 = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 textureColor2 = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

return mix(textureColor, textureColor2, half(uniform.mixturePercent));
}
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/DivideBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fragment half4 divideBlendFragment(TwoInputVertexIO fragmentInput [[stage_in]],
constexpr sampler quadSampler;
half4 base = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 overlay = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 overlay = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

half ra;
if (overlay.a == 0.0h || ((base.r / overlay.r) > (base.a / overlay.a)))
Expand Down
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/ExclusionBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fragment half4 exclusionBlendFragment(TwoInputVertexIO fragmentInput [[stage_in]
constexpr sampler quadSampler;
half4 base = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 overlay = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 overlay = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

return half4((overlay.rgb * base.a + base.rgb * overlay.a - 2.0h * overlay.rgb * base.rgb) + overlay.rgb * (1.0h - base.a) + base.rgb * (1.0h - overlay.a), base.a);
}
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/HardLightBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fragment half4 hardLightBlendFragment(TwoInputVertexIO fragmentInput [[stage_in]
constexpr sampler quadSampler;
half4 base = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 overlay = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 overlay = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

half ra;
if (2.0h * overlay.r < overlay.a) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/HueBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fragment half4 hueBlendFragment(TwoInputVertexIO fragmentInput [[stage_in]],
constexpr sampler quadSampler;
half4 base = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 overlay = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 overlay = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

return half4(base.rgb * (1.0h - overlay.a) + setlum(setsat(overlay.rgb, sat(base.rgb)), lum(base.rgb)) * overlay.a, base.a);
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/LightenBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fragment half4 lightenBlendFragment(TwoInputVertexIO fragmentInput [[stage_in]],
constexpr sampler quadSampler;
half4 textureColor = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 textureColor2 = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 textureColor2 = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

return max(textureColor, textureColor2);
}
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/LinearBurnBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fragment half4 linearBurnBlendFragment(TwoInputVertexIO fragmentInput [[stage_in
constexpr sampler quadSampler;
half4 textureColor = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 textureColor2 = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 textureColor2 = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

return half4(clamp(textureColor.rgb + textureColor2.rgb - half3(1.0h), half3(0.0h), half3(1.0h)), textureColor.a);
}
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/LuminosityBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fragment half4 luminosityBlendFragment(TwoInputVertexIO fragmentInput [[stage_in
constexpr sampler quadSampler;
half4 base = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 overlay = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 overlay = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

return half4(base.rgb * (1.0h - overlay.a) + setlum(base.rgb, lum(overlay.rgb)) * overlay.a, base.a);
}
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/MultiplyBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fragment half4 multiplyBlendFragment(TwoInputVertexIO fragmentInput [[stage_in]]
constexpr sampler quadSampler;
half4 base = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 overlay = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 overlay = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

return overlay * base + overlay * (1.0h - base.a) + base * (1.0h - overlay.a);
}
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/OverlayBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fragment half4 overlayBlendFragment(TwoInputVertexIO fragmentInput [[stage_in]],
constexpr sampler quadSampler;
half4 base = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 overlay = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 overlay = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

half ra;
if (2.0h * base.r < base.a) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/SaturationBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fragment half4 saturationBlendFragment(TwoInputVertexIO fragmentInput [[stage_in
constexpr sampler quadSampler;
half4 base = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 overlay = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 overlay = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

return half4(base.rgb * (1.0h - overlay.a) + setlum(setsat(base.rgb, sat(overlay.rgb)), lum(base.rgb)) * overlay.a, base.a);
}
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/ScreenBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fragment half4 screenBlendFragment(TwoInputVertexIO fragmentInput [[stage_in]],
constexpr sampler quadSampler;
half4 textureColor = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 textureColor2 = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 textureColor2 = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);
half4 whiteColor = half4(1.0);

return whiteColor - ((whiteColor - textureColor2) * (whiteColor - textureColor));
Expand Down
106 changes: 6 additions & 100 deletions Sources/GPUImage/Operations/Sharpen.metal
Original file line number Diff line number Diff line change
@@ -1,87 +1,18 @@
#include <metal_stdlib>
#include "TexelSamplingTypes.h"
using namespace metal;

typedef struct
{
float4 position [[position]];

float2 textureCoordinate [[user(textureCoordinate)]];
float2 leftTextureCoordinate [[user(leftTextureCoordinate)]];
float2 rightTextureCoordinate [[user(rightTextureCoordinate)]];
float2 topTextureCoordinate [[user(topTextureCoordinate)]];
float2 bottomTextureCoordinate [[user(bottomTextureCoordinate)]];
} SharpenVertexIO;



vertex SharpenVertexIO sharpenVertex(const device packed_float2 *position [[buffer(0)]],
const device packed_float2 *textureCoordinate [[buffer(1)]],
uint vid [[vertex_id]])
{
SharpenVertexIO outputVertices;

outputVertices.position = float4(position[vid], 0, 1.0);

float2 widthStep = float2(1.0, 0.0);
float2 heightStep = float2(0.0, 1.0);

outputVertices.textureCoordinate = textureCoordinate[vid];
outputVertices.leftTextureCoordinate = textureCoordinate[vid] - widthStep;
outputVertices.rightTextureCoordinate = textureCoordinate[vid] + widthStep;
outputVertices.topTextureCoordinate = textureCoordinate[vid] + heightStep;
outputVertices.bottomTextureCoordinate = textureCoordinate[vid] - heightStep;

return outputVertices;
}


// Vertex Shader
/*
attribute vec4 position;
attribute vec4 inputTextureCoordinate;

uniform float texelWidth;
uniform float texelHeight;
uniform float sharpness;

varying vec2 textureCoordinate;
varying vec2 leftTextureCoordinate;
varying vec2 rightTextureCoordinate;
varying vec2 topTextureCoordinate;
varying vec2 bottomTextureCoordinate;

varying float centerMultiplier;
varying float edgeMultiplier;

void main()
{
gl_Position = position;

vec2 widthStep = vec2(texelWidth, 0.0);
vec2 heightStep = vec2(0.0, texelHeight);

textureCoordinate = inputTextureCoordinate.xy;
leftTextureCoordinate = inputTextureCoordinate.xy - widthStep;
rightTextureCoordinate = inputTextureCoordinate.xy + widthStep;
topTextureCoordinate = inputTextureCoordinate.xy + heightStep;
bottomTextureCoordinate = inputTextureCoordinate.xy - heightStep;

centerMultiplier = 1.0 + 4.0 * sharpness;
edgeMultiplier = sharpness;
}

*/

typedef struct {
float sharpness;
} SharpenUniform;

fragment half4 sharpenFragment(SharpenVertexIO fragmentInput [[stage_in]],
fragment half4 sharpenFragment(NearbyTexelVertexIO fragmentInput [[stage_in]],
texture2d<half> inputTexture [[texture(0)]],
constant SharpenUniform& uniform [[buffer(1)]])
{
constexpr sampler quadSampler(coord::pixel);
half3 centerColor = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate).rgb;
half4 centerColorWithAlpha = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
half3 centerColor = centerColorWithAlpha.rgb;
half3 leftColor = inputTexture.sample(quadSampler, fragmentInput.leftTextureCoordinate).rgb;
half3 rightColor = inputTexture.sample(quadSampler, fragmentInput.rightTextureCoordinate).rgb;
half3 topColor = inputTexture.sample(quadSampler, fragmentInput.topTextureCoordinate).rgb;
Expand All @@ -91,32 +22,7 @@ fragment half4 sharpenFragment(SharpenVertexIO fragmentInput [[stage_in]],
half centerMultiplier = 1.0 + 4.0 * edgeMultiplier;

return half4((centerColor * centerMultiplier
- (leftColor * edgeMultiplier + rightColor * edgeMultiplier+ topColor * edgeMultiplier + bottomColor * edgeMultiplier)),
inputTexture.sample(quadSampler, fragmentInput.bottomTextureCoordinate).w);
- (leftColor * edgeMultiplier + rightColor * edgeMultiplier + topColor * edgeMultiplier + bottomColor * edgeMultiplier)),
centerColorWithAlpha.a);

}
// Fragment Shader
/*
varying vec2 textureCoordinate;
varying vec2 leftTextureCoordinate;
varying vec2 rightTextureCoordinate;
varying vec2 topTextureCoordinate;
varying vec2 bottomTextureCoordinate;

varying float centerMultiplier;
varying float edgeMultiplier;

uniform sampler2D inputImageTexture;

void main()
{
vec3 textureColor = texture2D(inputImageTexture, textureCoordinate).rgb;
vec3 leftTextureColor = texture2D(inputImageTexture, leftTextureCoordinate).rgb;
vec3 rightTextureColor = texture2D(inputImageTexture, rightTextureCoordinate).rgb;
vec3 topTextureColor = texture2D(inputImageTexture, topTextureCoordinate).rgb;
vec3 bottomTextureColor = texture2D(inputImageTexture, bottomTextureCoordinate).rgb;

gl_FragColor = vec4((textureColor * centerMultiplier - (leftTextureColor * edgeMultiplier + rightTextureColor * edgeMultiplier + topTextureColor * edgeMultiplier + bottomTextureColor * edgeMultiplier)), texture2D(inputImageTexture, bottomTextureCoordinate).w);
}

*/
15 changes: 2 additions & 13 deletions Sources/GPUImage/Operations/Sharpen.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
public class Sharpen: BasicOperation {
public class Sharpen: TextureSamplingOperation {
public var sharpness: Float = 0.0 { didSet { uniformSettings["sharpness"] = sharpness } }
public var overriddenTexelSize: Size?

public init() {
super.init(
vertexFunctionName: "sharpenVertex", fragmentFunctionName: "sharpenFragment",
numberOfInputs: 1)
super.init(fragmentFunctionName: "sharpenFragment")

({ sharpness = 0.0 })()
}

// Pretty sure this is OpenGL only
// override func configureFramebufferSpecificUniforms(_ inputFramebuffer:Framebuffer) {
// let outputRotation = overriddenOutputRotation ?? inputFramebuffer.orientation.rotationNeededForOrientation(.portrait)
// let texelSize = overriddenTexelSize ?? inputFramebuffer.texelSize(for:outputRotation)
// uniformSettings["texelWidth"] = texelSize.width
// uniformSettings["texelHeight"] = texelSize.height
// }
}
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/SoftLightBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fragment half4 softLightBlendFragment(TwoInputVertexIO fragmentInput [[stage_in]
constexpr sampler quadSampler;
half4 base = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 overlay = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 overlay = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

half alphaDivisor = base.a + step(base.a, 0.0h); // Protect against a divide-by-zero blacking out things in the output

Expand Down
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/SourceOverBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fragment half4 sourceOverBlendFragment(TwoInputVertexIO fragmentInput [[stage_in
constexpr sampler quadSampler;
half4 textureColor = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 textureColor2 = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 textureColor2 = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

return mix(textureColor, textureColor2, textureColor2.a);
}
2 changes: 1 addition & 1 deletion Sources/GPUImage/Operations/SubtractBlend.metal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fragment half4 subtractBlendFragment(TwoInputVertexIO fragmentInput [[stage_in]]
constexpr sampler quadSampler;
half4 textureColor = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
constexpr sampler quadSampler2;
half4 textureColor2 = inputTexture2.sample(quadSampler, fragmentInput.textureCoordinate2);
half4 textureColor2 = inputTexture2.sample(quadSampler2, fragmentInput.textureCoordinate2);

return half4(textureColor.rgb - textureColor2.rgb, textureColor.a);
}
20 changes: 10 additions & 10 deletions examples/Mac/FilterShowcase/FilterShowcase/FilterOperations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,16 @@ let filterOperations: [FilterOperationInterface] = [
sliderUpdateCallback: nil,
filterOperationType: .singleInput
),
// FilterOperation(
// filter:{Sharpen()},
// listName:"Sharpen",
// titleName:"Sharpen",
// sliderConfiguration:.enabled(minimumValue:-1.0, maximumValue:4.0, initialValue:0.0),
// sliderUpdateCallback: {(filter, sliderValue) in
// filter.sharpness = sliderValue
// },
// filterOperationType:.singleInput
// ),
FilterOperation(
filter: { Sharpen() },
listName: "Sharpen",
titleName: "Sharpen",
sliderConfiguration: .enabled(minimumValue: -1.0, maximumValue: 4.0, initialValue: 0.0),
sliderUpdateCallback: { (filter, sliderValue) in
filter.sharpness = sliderValue
},
filterOperationType: .singleInput
),
// FilterOperation(
// filter:{UnsharpMask()},
// listName:"Unsharp mask",
Expand Down
Loading