Permalink
Browse files

Merge branch 'filmic'

* filmic:
  factorize presets and check them against L. Viatour samples
  update global saturation in presets
  remove the git typo
  bump the version number
  add a global saturation parameter + optimize SSE2 code (×2 speed-up)
  improve labels
  optimizations
  • Loading branch information...
TurboGit committed Dec 29, 2018
2 parents d32e1f1 + a582504 commit fe7a2f997dc19763bb043f59aa2e29203bb15270
Showing with 300 additions and 216 deletions.
  1. +13 −5 data/kernels/filmic.cl
  2. +287 −211 src/iop/filmic.c
@@ -22,23 +22,31 @@ kernel void
filmic (read_only image2d_t in, write_only image2d_t out, int width, int height,
const float dynamic_range, const float shadows_range, const float grey,
read_only image2d_t table, read_only image2d_t diff,
const float contrast, const float power, const int preserve_color)
const float contrast, const float power, const int preserve_color,
const float saturation)
{
const unsigned int x = get_global_id(0);
const unsigned int y = get_global_id(1);

if(x >= width || y >= height) return;

float4 i = read_imagef(in, sampleri, (int2)(x, y));
float4 o = Lab_to_XYZ(i);
o = XYZ_to_prophotorgb(o);
const float4 xyz = Lab_to_XYZ(i);
float4 o = XYZ_to_prophotorgb(xyz);

const float noise = pow(2.0f, -16.0f);
const float4 noise4 = noise;
const float4 dynamic4 = dynamic_range;
const float4 shadows4 = shadows_range;
float derivative, luma;

// Global desaturation
if (saturation != 1.0f)
{
const float4 lum = xyz.y;
o = lum + (float4)saturation * (o - lum);
}

if (preserve_color)
{

@@ -49,7 +57,7 @@ filmic (read_only image2d_t in, write_only image2d_t out, int width, int height,
// Log profile
maxRGB = maxRGB / grey;
maxRGB = (maxRGB < noise) ? noise : maxRGB;
maxRGB = (log2(maxRGB) - shadows_range) / dynamic_range;
maxRGB = (native_log2(maxRGB) - shadows_range) / dynamic_range;
maxRGB = clamp(maxRGB, 0.0f, 1.0f);

const float index = maxRGB;
@@ -69,7 +77,7 @@ filmic (read_only image2d_t in, write_only image2d_t out, int width, int height,
// Log profile
o = o / grey;
o = (o < noise) ? noise : o;
o = (log2(o) - shadows4) / dynamic4;
o = (native_log2(o) - shadows4) / dynamic4;
o = clamp(o, (float4)0.0f, (float4)1.0f);

const float index = prophotorgb_to_XYZ(o).y;
Oops, something went wrong.

0 comments on commit fe7a2f9

Please sign in to comment.