Blender  V3.3
COM_GammaOperation.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. */
3 
4 #include "COM_GammaOperation.h"
5 
6 namespace blender::compositor {
7 
9 {
13  input_program_ = nullptr;
14  input_gamma_program_ = nullptr;
15  flags_.can_be_constant = true;
16 }
18 {
19  input_program_ = this->get_input_socket_reader(0);
20  input_gamma_program_ = this->get_input_socket_reader(1);
21 }
22 
24 {
25  float input_value[4];
26  float input_gamma[4];
27 
28  input_program_->read_sampled(input_value, x, y, sampler);
29  input_gamma_program_->read_sampled(input_gamma, x, y, sampler);
30  const float gamma = input_gamma[0];
31  /* check for negative to avoid nan's */
32  output[0] = input_value[0] > 0.0f ? powf(input_value[0], gamma) : input_value[0];
33  output[1] = input_value[1] > 0.0f ? powf(input_value[1], gamma) : input_value[1];
34  output[2] = input_value[2] > 0.0f ? powf(input_value[2], gamma) : input_value[2];
35 
36  output[3] = input_value[3];
37 }
38 
40 {
41  for (; p.out < p.row_end; p.next()) {
42  const float *in_value = p.ins[0];
43  const float *in_gamma = p.ins[1];
44  const float gamma = in_gamma[0];
45  /* Check for negative to avoid nan's. */
46  p.out[0] = in_value[0] > 0.0f ? powf(in_value[0], gamma) : in_value[0];
47  p.out[1] = in_value[1] > 0.0f ? powf(in_value[1], gamma) : in_value[1];
48  p.out[2] = in_value[2] > 0.0f ? powf(in_value[2], gamma) : in_value[2];
49  p.out[3] = in_value[3];
50  }
51 }
52 
54 {
55  input_program_ = nullptr;
56  input_gamma_program_ = nullptr;
57 }
58 
59 } // namespace blender::compositor
_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
void update_memory_buffer_row(PixelCursor &p) override
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override
void add_output_socket(DataType datatype)
SocketReader * get_input_socket_reader(unsigned int index)
void read_sampled(float result[4], float x, float y, PixelSampler sampler)
void add_input_socket(DataType datatype, ResizeMode resize_mode=ResizeMode::Center)
#define powf(x, y)
Definition: cuda/compat.h:103
depth_tx sampler(1, ImageType::FLOAT_2D, "combined_tx") .sampler(2
ccl_global KernelShaderEvalInput ccl_global float * output