36 output[0] /= ((dr == 0.0f) ? 1.0f : dr);
37 output[1] /= ((dg == 0.0f) ? 1.0f : dg);
38 output[2] /= ((db == 0.0f) ? 1.0f : db);
39 const float igm = avg->
igm;
52 const float m = (ntm->
m > 0.0f) ? ntm->
m : (0.3f + 0.7f *
powf(avg->
auto_key, 1.4f));
53 const float ic = 1.0f - ntm->
c, ia = 1.0f - ntm->
a;
59 float I_g = avg->
cav[0] + ic * (avg->
lav - avg->
cav[0]);
60 float I_a = I_l + ia * (I_g - I_l);
63 I_g = avg->
cav[1] + ic * (avg->
lav - avg->
cav[1]);
64 I_a = I_l + ia * (I_g - I_l);
67 I_g = avg->
cav[2] + ic * (avg->
lav - avg->
cav[2]);
68 I_a = I_l + ia * (I_g - I_l);
106 int p =
tile->get_width() *
tile->get_height();
108 float avl, maxl = -1e10f, minl = 1e10f;
109 const float sc = 1.0f / p;
111 float cav[4] = {0.0f, 0.0f, 0.0f, 0.0f};
117 maxl = (
L > maxl) ?
L : maxl;
118 minl = (
L < minl) ?
L : minl;
121 data->lav = Lav * sc;
123 maxl =
log((
double)maxl + 1
e-5);
124 minl =
log((
double)minl + 1
e-5);
126 data->auto_key = (maxl > minl) ? ((maxl - avl) / (maxl - minl)) : 1.0f;
127 float al =
exp((
double)avl);
161 for (
const float *elem :
input->get_buffer_area(
area)) {
185 join.
sum += chunk.sum;
186 add_v3_v3(join.color_sum, chunk.color_sum);
187 join.log_sum += chunk.log_sum;
188 join.max =
MAX2(join.max, chunk.max);
189 join.min =
MIN2(join.min, chunk.min);
190 join.num_pixels += chunk.num_pixels;
196 const float max_log =
log((
double)lum.
max + 1
e-5);
197 const float min_log =
log((
double)lum.
min + 1
e-5);
199 avg->auto_key = (max_log > min_log) ? ((max_log - avg_log) / (max_log - min_log)) : 1.0f;
200 const float al =
exp((
double)avg_log);
201 avg->al = (al == 0.0f) ? 0.0f : (
data_->
key / al);
212 const float igm = avg->
igm;
217 float dr = it.out[0] +
offset;
218 float dg = it.out[1] +
offset;
219 float db = it.out[2] +
offset;
220 it.out[0] /= ((dr == 0.0f) ? 1.0f : dr);
221 it.out[1] /= ((dg == 0.0f) ? 1.0f : dg);
222 it.out[2] /= ((db == 0.0f) ? 1.0f : db);
224 it.out[0] =
powf(
MAX2(it.out[0], 0.0f), igm);
225 it.out[1] =
powf(
MAX2(it.out[1], 0.0f), igm);
226 it.out[2] =
powf(
MAX2(it.out[2], 0.0f), igm);
238 const float m = (ntm->
m > 0.0f) ? ntm->
m : (0.3f + 0.7f *
powf(avg->
auto_key, 1.4f));
239 const float ic = 1.0f - ntm->
c;
240 const float ia = 1.0f - ntm->
a;
244 float I_l = it.out[0] + ic * (
L - it.out[0]);
245 float I_g = avg->
cav[0] + ic * (avg->
lav - avg->
cav[0]);
246 float I_a = I_l + ia * (I_g - I_l);
247 it.out[0] /= (it.out[0] +
powf(f * I_a, m));
248 I_l = it.out[1] + ic * (
L - it.out[1]);
249 I_g = avg->
cav[1] + ic * (avg->
lav - avg->
cav[1]);
250 I_a = I_l + ia * (I_g - I_l);
251 it.out[1] /= (it.out[1] +
powf(f * I_a, m));
252 I_l = it.out[2] + ic * (
L - it.out[2]);
253 I_g = avg->
cav[2] + ic * (avg->
lav - avg->
cav[2]);
254 I_a = I_l + ia * (I_g - I_l);
255 it.out[2] /= (it.out[2] +
powf(f * I_a, m));
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
BLI_INLINE float IMB_colormanagement_get_luminance(const float rgb[3])
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
void execute_work(const rcti &work_rect, std::function< void(const rcti &split_rect)> work_func)
a MemoryBuffer contains access to the data of a chunk
NodeOperation contains calculation logic.
unsigned int get_height() const
void add_output_socket(DataType datatype)
SocketReader * get_input_socket_reader(unsigned int index)
unsigned int get_width() const
NodeOperationFlags flags_
const rcti & get_canvas() const
NodeOperation * get_input_operation(int index)
ExecutionSystem * exec_system_
void read(float result[4], int x, int y, void *chunk_data)
virtual bool determine_depending_area_of_interest(rcti *input, ReadBufferOperation *read_operation, rcti *output)
void add_input_socket(DataType datatype, ResizeMode resize_mode=ResizeMode::Center)
virtual void * initialize_tile_data(rcti *)
void update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
void execute_pixel(float output[4], int x, int y, void *data) override
void deinit_execution() override
NodeTonemap * data_
settings of the Tonemap
void execute_pixel(float output[4], int x, int y, void *data) override
void update_memory_buffer_started(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
void deinitialize_tile_data(rcti *rect, void *data) override
AvgLogLum * cached_instance_
temporarily cache of the execution storage
bool determine_depending_area_of_interest(rcti *input, ReadBufferOperation *read_operation, rcti *output) override
void init_execution() override
SocketReader * image_reader_
Cached reference to the reader.
void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override
Get input operation area being read by this operation on rendering given output area.
virtual void update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
void * initialize_tile_data(rcti *rect) override
ccl_global float * buffer
ccl_global KernelShaderEvalInput ccl_global float * output
ccl_global const KernelWorkTile * tile
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
ccl_global KernelShaderEvalInput * input
ccl_device_inline float3 exp(float3 v)
ccl_device_inline float3 log(float3 v)
static void area(int d1, int d2, int e1, int e2, float weights[2])
typename BuffersIteratorBuilder< T >::Iterator BuffersIterator
struct blender::compositor::AvgLogLum AvgLogLum
temporarily storage during execution of Tone-map
static Luminance calc_area_luminance(const MemoryBuffer *input, const rcti &area)
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
static bNodeSocketTemplate inputs[]
temporarily storage during execution of Tone-map