-
Notifications
You must be signed in to change notification settings - Fork 1
/
C_Channel_Viewer.dctl
37 lines (31 loc) · 1.01 KB
/
C_Channel_Viewer.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
/*
Channel Viewer
Version 001
*/
__CONSTANT__ int LAB = 1; // Use 0 for RGB and 1 for LAB
__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, __TEXTURE__ p_TexR, __TEXTURE__ p_TexG, __TEXTURE__ p_TexB)
{
const int offx = p_X >= p_Width / 2 ? p_Width / 2 : 0;
const int offy = p_Y >= p_Height / 2 ? p_Height / 2 : 0;
const float offset = LAB == 1 ? 0.5f : 0.0f;
if (!offx && !offy)
return make_float3(
_tex2D(p_TexR, 2*(p_X - offx) + 1, 2*(p_Y - offy) + 1),
_tex2D(p_TexG, 2*(p_X - offx) + 1, 2*(p_Y - offy) + 1),
_tex2D(p_TexB, 2*(p_X - offx) + 1, 2*(p_Y - offy) + 1));
if (offx && !offy)
return make_float3(
_tex2D(p_TexR, 2*(p_X - offx) + 1, 2*(p_Y - offy) + 1),
offset,
offset);
if (!offx && offy)
return make_float3(
offset,
_tex2D(p_TexG, 2*(p_X - offx) + 1, 2*(p_Y - offy) + 1),
offset);
if (offx && offy)
return make_float3(
offset,
offset,
_tex2D(p_TexB, 2*(p_X - offx) + 1, 2*(p_Y - offy) + 1));
}