File: fill_stroke_source.effect

package info (click to toggle)
obs-stroke-glow-shadow 1.5.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,376 kB
  • sloc: ansic: 3,316; sh: 153; makefile: 27; cpp: 16
file content (95 lines) | stat: -rw-r--r-- 2,295 bytes parent folder | download
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
88
89
90
91
92
93
94
95
#define EPS 0.000000000001

uniform float4x4 ViewProj;
uniform texture2d image;
uniform texture2d stroke_mask;
uniform texture2d stroke_fill_source;
uniform float4 stroke_fill_color;
uniform float fill_behind = 0.0;

sampler_state textureSampler{
    Filter = Linear;
    AddressU = Clamp;
    AddressV = Clamp;
    MinLOD = 0;
    MaxLOD = 0;
};

struct VertData
{
	float4 pos : POSITION;
	float2 uv : TEXCOORD0;
};

VertData mainTransform(VertData v_in)
{
	v_in.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj);
	return v_in;
}

float4 mainImageFilterColor(VertData v_in) : TARGET
{
	float4 col = image.Sample(textureSampler, v_in.uv);
	float mask_alpha = (stroke_mask.Sample(textureSampler, v_in.uv)).a - fill_behind * col.a;
	return float4(stroke_fill_color.rgb, stroke_fill_color.a * mask_alpha);
}

float4 mainImageFilterSource(VertData v_in) : TARGET
{
	float4 col = image.Sample(textureSampler, v_in.uv);
	float mask_alpha = (stroke_mask.Sample(textureSampler, v_in.uv)).a - fill_behind * col.a;
	float4 fill_col = stroke_fill_source.Sample(textureSampler, v_in.uv);
	return float4(fill_col.rgb, fill_col.a * mask_alpha);
}

float4 mainImageFilterColorInner(VertData v_in) : TARGET
{
	float4 col = image.Sample(textureSampler, v_in.uv);
	float mask_alpha = (stroke_mask.Sample(textureSampler, v_in.uv)).a * col.a;
	return float4(stroke_fill_color.rgb, stroke_fill_color.a * mask_alpha);
}

float4 mainImageFilterSourceInner(VertData v_in) : TARGET
{
	float4 col = image.Sample(textureSampler, v_in.uv);
	float4 fill_col = stroke_fill_source.Sample(textureSampler, v_in.uv);
	float mask_alpha = (stroke_mask.Sample(textureSampler, v_in.uv)).a * col.a;
	//return stroke_mask.Sample(textureSampler, v_in.uv);
	return float4(fill_col.rgb, fill_col.a * mask_alpha);
}

technique FilterColorOuter
{
	pass
	{
		vertex_shader = mainTransform(v_in);
		pixel_shader = mainImageFilterColor(v_in);
	}
}

technique FilterSourceOuter
{
	pass
	{
		vertex_shader = mainTransform(v_in);
		pixel_shader = mainImageFilterSource(v_in);
	}
}

technique FilterColorInner
{
	pass
	{
		vertex_shader = mainTransform(v_in);
		pixel_shader = mainImageFilterColorInner(v_in);
	}
}

technique FilterSourceInner
{
	pass
	{
		vertex_shader = mainTransform(v_in);
		pixel_shader = mainImageFilterSourceInner(v_in);
	}
}