-
Notifications
You must be signed in to change notification settings - Fork 1
/
C_Mark.dctl
76 lines (62 loc) · 1.57 KB
/
C_Mark.dctl
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
/*
C_Mark
This DCTL works together with C_Analyze, it places information on top line and the bottom left corner of the video.
C_Analyze describes the changes made between the C_Mark and the C_Analyze nodes.
Version 005
*/
__CONSTANT__ int LEVEL = 12;
__DEVICE__ inline float h2r(float v1, float v2, float h)
{
if (h < 0)
h += 1;
if (h > 1)
h -= 1;
if (6 * h < 1)
return v1 + (v2 - v1) * 6 * h;
if (2 * h < 1)
return v2;
if (3 * h < 2)
return v1 + (v2 - v1) * (2 / 3.0f - h) * 6;
return v1;
}
__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, __TEXTURE__ p_TexR, __TEXTURE__ p_TexG, __TEXTURE__ p_TexB)
{
struct hsl {
float h;
float s;
float l;
};
const int segment = LEVEL / 4;
float3 p;
hsl g;
if (p_Y >= p_Height - 1 && p_X < LEVEL*LEVEL*LEVEL)
{
// Generate HSL model
g.h = _fmod(p_X, LEVEL)/ LEVEL;
g.l = _fmod(p_X/segment/LEVEL, LEVEL) / LEVEL;
g.s = _fmod(p_X/(LEVEL*LEVEL), LEVEL) / LEVEL;
// Limit the range
g.l = g.l*0.6 + 0.2;
g.s = g.s*0.7 + 0.15;
if (g.s == 0)
p.x = p.y = p.z = g.l;
else
{
float v2 = g.l < 0.5 ? g.l*(1 + g.s) : (g.l + g.s) - (g.s*g.l);
float v1 = 2 * g.l - v2;
p.x = h2r(v1, v2, g.h + 1 / 3.0f);
p.y = h2r(v1, v2, g.h);
p.z = h2r(v1, v2, g.h - 1 / 3.0f);
}
return p;
}
if (p_Y == 0)
{
p.x = p.y = p.z = (float)p_X / p_Width;
return p;
}
return make_float3(
_tex2D(p_TexR, p_X, p_Y),
_tex2D(p_TexG, p_X, p_Y),
_tex2D(p_TexB, p_X, p_Y));
}