This repository has been archived by the owner on Dec 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBottomizer.hlsl
47 lines (39 loc) · 1.82 KB
/
Bottomizer.hlsl
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
/*
_______ _____ __ __ ____ __
/ ____(_)___ ___ ____ ___ ____ _ / ___// /_ ____ _____/ /__ _____ / __ \____ ______/ /__
/ / / / __ \/ _ \/ __ `__ \/ __ `/ \__ \/ __ \/ __ `/ __ / _ \/ ___/ / /_/ / __ `/ ___/ //_/
/ /___/ / / / / __/ / / / / / /_/ / ___/ / / / / /_/ / /_/ / __/ / / ____/ /_/ / /__/ ,<
\____/_/_/ /_/\___/_/ /_/ /_/\__,_/ /____/_/ /_/\__,_/\__,_/\___/_/ /_/ \__,_/\___/_/|_|
http://en.sbence.hu/ Shader: Move wide content to the bottom of the frame
*/
// Configuration ---------------------------------------------------------------
const static float v = 5 / 256.0; // Target darkness (peak noise level)
// -----------------------------------------------------------------------------
sampler s0;
float4 p0 : register(c0);
#define width (p0[0])
#define height (p0[1])
float cp(float w, float h) { // Check a point if it's below target darnkess
float3 p = tex2D(s0, float2(w, h)).rgb;
return p.r < v && p.g < v && p.b < v;
}
float checkLayer(float t) {
return cp(0, t) && cp(0.2, t) && cp(0.4, t) && cp(0.6, t) && cp(0.8, t) && cp(1, t);
}
float ratioTest(float container, float ratio) {
float h = 0.05 + container / ratio;
return ratio > container ? checkLayer((1 + h) * 0.5) && checkLayer((1 - h) * 0.5) : 0;
}
float2 ratioOffset(float container, float ratio) {
return float2(0, (container / ratio + 1) * 0.5 - 1);
}
float4 main(float2 tex : TEXCOORD0) : COLOR {
float container = width / height;
tex +=
ratioTest(container, 2.34) ? ratioOffset(container, 2.34) :
ratioTest(container, 2.2) ? ratioOffset(container, 2.2) :
ratioTest(container, 2) ? ratioOffset(container, 2) :
ratioTest(container, 1.85) ? ratioOffset(container, 1.85) :
float2(0, 0);
return tex2D(s0, tex).rgbb;
}