File: brightness-threshold.effect

package info (click to toggle)
obs-retro-effects 1.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,984 kB
  • sloc: ansic: 7,150; sh: 153; makefile: 27; cpp: 16
file content (44 lines) | stat: -rw-r--r-- 820 bytes parent folder | download | duplicates (2)
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
uniform float4x4 ViewProj;
uniform texture2d image;
uniform float threshold;
uniform float3 levels;

float RGBToLum(float3 color)
{
	return 0.299 * color.r + 0.587 * color.g + 0.114 * color.b;
}

sampler_state textureSampler{
    Filter = Linear;
    AddressU = Clamp;
    AddressV = Clamp;
};

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 mainImage(VertData v_in) : TARGET
{
	float4 color = image.Sample(textureSampler, v_in.uv);
	//float lum = RGBToLum(color.rgb);
	float lum = dot(color.rgb, levels);
	return lum > threshold ? color : float4(0.0, 0.0, 0.0, color.a);
}

technique Draw
{
	pass
	{
		vertex_shader = mainTransform(v_in);
		pixel_shader = mainImage(v_in);
	}
}