__DEVICE__ float apply_contrast(float in, float contrast, float pivot)
{
float out;
if (in <= pivot) {
out = _powf((in / pivot), contrast) * pivot;
}
else {
in = 1 - in;
pivot = 1 - pivot;
out = _powf((in / pivot), contrast) * pivot;
out = 1 - out;
}
return out;
}
DEFINE_UI_PARAMS(contrast, Contrast, DCTLUI_SLIDER_FLOAT, 1.0, 0.0, 2.0, 0.1)
DEFINE_UI_PARAMS(pivot, Pivot, DCTLUI_SLIDER_FLOAT, .435, 0.0, 1.0, 0.1)
__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p_R, float p_G, float p_B)
{
float3 in = {p_R, p_G, p_B};
float3 out;
out.x = apply_contrast(in.x, contrast, pivot);
out.y = apply_contrast(in.y, contrast, pivot);
out.z = apply_contrast(in.z, contrast, pivot);
return out;
}