forked from shugen002/shader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmerge alpha.hlsl
More file actions
87 lines (72 loc) · 2.6 KB
/
merge alpha.hlsl
File metadata and controls
87 lines (72 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright 2022 Shugen002
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
// (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// Version: 0.2
// Usage: Load this file as shader in shader filter of Xaymar's OBS StreamFX Plugin
// (https://obsproject.com/forum/resources/streamfx-for-obs%C2%AE-studio.578/)
// and apply it to your source.
// version history:
// 0.1: initial release
// 0.2: cleaned up code.
// Always provided by OBS
uniform float4x4 ViewProj<
bool automatic = true;
string name = "View Projection Matrix";
>;
uniform texture2d InputA<
bool automatic = true;
>;
// ---------- Shader Code
sampler_state def_sampler {
AddressU = Clamp;
AddressV = Clamp;
Filter = Linear;
};
struct VertData {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};
VertData VSDefault(VertData vtx) {
vtx.pos = mul(float4(vtx.pos.xyz, 1.0), ViewProj);
return vtx;
}
float4 PSTemplate(VertData vtx) : TARGET {
float2 uv = vtx.uv;
if(uv.x <= 0.25){
float4 rgb= InputA.Sample(def_sampler, uv);
uv.x += 0.75;
float4 rgb2= InputA.Sample(def_sampler, uv);
rgb.a = rgb2.r;
return rgb;
}else if(uv.x <= 0.5){
float4 rgb= InputA.Sample(def_sampler, uv);
uv.x += 0.5;
float4 rgb2= InputA.Sample(def_sampler, uv);
rgb.a = rgb2.g;
return rgb;
}else if(uv.x <= 0.75){
float4 rgb= InputA.Sample(def_sampler, uv);
uv.x += 0.25;
float4 rgb2= InputA.Sample(def_sampler, uv);
rgb.a = rgb2.b;
return rgb;
}else{
return float4(0,0,0,0);
}
}
technique Draw
{
pass
{
vertex_shader = VSDefault(vtx);
pixel_shader = PSTemplate(vtx);
}
}