forked from Snapble/MetalFilters
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
徐水峰
authored and
xu.shuifeng
committed
Jun 15, 2018
1 parent
2878a1c
commit 262c2ce
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// MTImageOverlayFilter.metal | ||
// MetalFilters | ||
// | ||
// Created by xu.shuifeng on 2018/6/15. | ||
// Copyright © 2018 shuifeng.me. All rights reserved. | ||
// | ||
|
||
#include <metal_stdlib> | ||
#include "MTIShaderLib.h" | ||
using namespace metalpetal; | ||
|
||
fragment float4 MTImageOverlayFilterFragment(VertexOut vertexIn [[ stage_in ]], | ||
texture2d<float, access::sample> inputTexture [[ texture(0) ]], | ||
texture2d<float, access::sample> overlay [[ texture(1) ]], | ||
sampler textureSampler [[ sampler(0) ]]) | ||
{ | ||
constexpr sampler s(coord::normalized, address::clamp_to_edge, filter::linear); | ||
float4 texel = inputTexture.sample(s, vertexIn.textureCoordinate); | ||
float4 overlayTexel = overlay.sample(s, vertexIn.textureCoordinate); | ||
texel.rgb = texel.rgb * (1.0 - overlayTexel.a) + overlayTexel.rgb; | ||
return texel; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// MTImageOverlayFilter.swift | ||
// MetalFilters | ||
// | ||
// Created by xu.shuifeng on 2018/6/15. | ||
// Copyright © 2018 shuifeng.me. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
class MTImageOverlayFilter: MTFilter { | ||
|
||
override var fragmentName: String { | ||
return "MTImageOverlayFilterFragment" | ||
} | ||
|
||
} |