23 #include "COM_SMAAAreaTexture.h"
54 #define SMAA_AREATEX_SIZE 80
55 #define SMAA_AREATEX_MAX_DISTANCE 20
56 #define SMAA_AREATEX_MAX_DISTANCE_DIAG 20
57 #define SMAA_MAX_SEARCH_STEPS 362
58 #define SMAA_MAX_SEARCH_STEPS_DIAG 19
66 color[0] = color[1] = color[2] = color[3] = 0.0;
70 reader->
read(color,
x,
y,
nullptr);
76 float iy =
floorf(yoffset);
77 float fy = yoffset - iy;
80 float color00[4], color01[4];
82 sample(reader,
x + 0,
y + 0, color00);
83 sample(reader,
x + 0,
y + 1, color01);
85 color[0] =
interpf(color01[0], color00[0], fy);
86 color[1] =
interpf(color01[1], color00[1], fy);
87 color[2] =
interpf(color01[2], color00[2], fy);
88 color[3] =
interpf(color01[3], color00[3], fy);
94 float ix =
floorf(xoffset);
95 float fx = xoffset - ix;
98 float color00[4], color10[4];
100 sample(reader,
x + 0,
y + 0, color00);
101 sample(reader,
x + 1,
y + 0, color10);
103 color[0] =
interpf(color10[0], color00[0], fx);
104 color[1] =
interpf(color10[1], color00[1], fx);
105 color[2] =
interpf(color10[2], color00[2], fx);
106 color[3] =
interpf(color10[3], color00[3], fx);
123 static void area(
int d1,
int d2,
int e1,
int e2,
float weights[2])
130 float fx =
x - ix, fy =
y - iy;
131 int X = (int)ix,
Y = (
int)iy;
139 interpf(weights11[0], weights01[0], fx),
interpf(weights10[0], weights00[0], fx), fy);
141 interpf(weights11[1], weights01[1], fx),
interpf(weights10[1], weights00[1], fx), fy);
148 static void area_diag(
int d1,
int d2,
int e1,
int e2,
float weights[2])
220 float Dleft =
fabsf(
L - Lleft);
221 float Dtop =
fabsf(
L - Ltop);
239 float Dright =
fabsf(
L - Lright);
240 float Dbottom =
fabsf(
L - Lbottom);
256 float Dleftleft =
fabsf(Lleft - Lleftleft);
257 float Dlefttop =
fabsf(Lleft - Llefttop);
258 float Dleftbottom =
fabsf(Lleft - Lleftbottom);
261 maxDelta =
fmaxf(maxDelta,
fmaxf(Dleftleft,
fmaxf(Dlefttop, Dleftbottom)));
276 float Dtoptop =
fabsf(Ltop - Ltoptop);
277 float Dtopleft =
fabsf(Ltop - Llefttop);
278 float Dtopright =
fabsf(Ltop - Ltopright);
281 maxDelta =
fmaxf(maxDelta,
fmaxf(Dtoptop,
fmaxf(Dtopleft, Dtopright)));
299 this->m_imageReader =
nullptr;
300 this->m_corner_rounding = 25;
316 m_corner_rounding =
static_cast<int>(
scalenorm(0, 100, rounding));
324 float edges[4],
c[4];
330 if (edges[1] > 0.0f) {
333 calculateDiagWeights(
x,
y, edges,
output);
342 int left = searchXLeft(
x,
y);
343 int right = searchXRight(
x,
y);
370 if (m_corner_rounding) {
376 if (edges[0] > 0.0f) {
378 if (isVerticalSearchUnneeded(
x,
y)) {
383 int top = searchYUp(
x,
y);
410 if (m_corner_rounding) {
418 this->m_imageReader =
nullptr;
442 int SMAABlendingWeightCalculationOperation::searchDiag1(
int x,
int y,
int dir,
bool *found)
458 return (dir < 0) ?
x :
x - dir;
465 int SMAABlendingWeightCalculationOperation::searchDiag2(
int x,
int y,
int dir,
bool *found)
482 return (dir > 0) ?
x :
x - dir;
492 void SMAABlendingWeightCalculationOperation::calculateDiagWeights(
int x,
494 const float edges[2],
498 bool d1_found, d2_found;
508 if (edges[0] > 0.0f) {
509 d1 =
x - searchDiag1(
x,
y, -1, &d1_found);
515 d2 = searchDiag1(
x,
y, 1, &d2_found) -
x;
553 d1 =
x - searchDiag2(
x,
y, -1, &d1_found);
556 d2 = searchDiag2(
x,
y, 1, &d2_found) -
x;
601 bool SMAABlendingWeightCalculationOperation::isVerticalSearchUnneeded(
int x,
int y)
614 d1 =
x - searchDiag2(
x - 1,
y, -1, &found);
619 d2 = searchDiag2(
x - 1,
y, 1, &found) -
x;
621 return (d1 + d2 > 2);
627 int SMAABlendingWeightCalculationOperation::searchXLeft(
int x,
int y)
650 int SMAABlendingWeightCalculationOperation::searchXRight(
int x,
int y)
671 int SMAABlendingWeightCalculationOperation::searchYUp(
int x,
int y)
694 int SMAABlendingWeightCalculationOperation::searchYDown(
int x,
int y)
718 void SMAABlendingWeightCalculationOperation::detectHorizontalCornerPattern(
719 float weights[2],
int left,
int right,
int y,
int d1,
int d2)
721 float factor[2] = {1.0f, 1.0f};
722 float rounding = m_corner_rounding / 100.0f;
726 rounding *= (d1 == d2) ? 0.5f : 1.0f;
731 factor[0] -= rounding *
e[0];
733 factor[1] -= rounding *
e[0];
738 factor[0] -= rounding *
e[0];
740 factor[1] -= rounding *
e[0];
743 weights[0] *=
CLAMPIS(factor[0], 0.0f, 1.0f);
744 weights[1] *=
CLAMPIS(factor[1], 0.0f, 1.0f);
747 void SMAABlendingWeightCalculationOperation::detectVerticalCornerPattern(
748 float weights[2],
int x,
int top,
int bottom,
int d1,
int d2)
750 float factor[2] = {1.0f, 1.0f};
751 float rounding = m_corner_rounding / 100.0f;
755 rounding *= (d1 == d2) ? 0.5f : 1.0f;
760 factor[0] -= rounding *
e[1];
762 factor[1] -= rounding *
e[1];
767 factor[0] -= rounding *
e[1];
769 factor[1] -= rounding *
e[1];
772 weights[0] *=
CLAMPIS(factor[0], 0.0f, 1.0f);
773 weights[1] *=
CLAMPIS(factor[1], 0.0f, 1.0f);
786 this->m_image1Reader =
nullptr;
787 this->m_image2Reader =
nullptr;
823 void (*samplefunc)(
SocketReader * reader,
int x,
int y,
float xoffset,
float color[4]);
824 float offset1, offset2, weight1, weight2, color1[4], color2[4];
842 samplefunc(m_image1Reader,
x,
y, offset1, color1);
843 samplefunc(m_image1Reader,
x,
y, offset2, color2);
851 this->m_image1Reader =
nullptr;
852 this->m_image2Reader =
nullptr;
typedef float(TangentPoint)[2]
MINLINE float interpf(float a, float b, float t)
MINLINE void mul_v4_v4fl(float r[3], const float a[4], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void zero_v4(float r[4])
MINLINE void zero_v2(float r[2])
MINLINE bool is_zero_v2(const float a[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f)
#define SMAA_AREATEX_MAX_DISTANCE
#define SMAA_AREATEX_MAX_DISTANCE_DIAG
#define SMAA_AREATEX_SIZE
#define SMAA_MAX_SEARCH_STEPS
#define SMAA_MAX_SEARCH_STEPS_DIAG
_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 GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble right
_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
_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 GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble top
_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 GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble bottom
BLI_INLINE float IMB_colormanagement_get_luminance(const float rgb[3])
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
NodeOperation contains calculation logic.
virtual void * initializeTileData(rcti *)
unsigned int getHeight() const
void addInputSocket(DataType datatype, ResizeMode resize_mode=ResizeMode::Center)
NodeOperation * getInputOperation(unsigned int inputSocketindex)
void read(float result[4], int x, int y, void *chunkData)
void addOutputSocket(DataType datatype)
unsigned int getWidth() const
SocketReader * getInputSocketReader(unsigned int inputSocketindex)
virtual bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) override
void * initializeTileData(rcti *rect) override
void executePixel(float output[4], int x, int y, void *data) override
void deinitExecution() override
void initExecution() override
SMAABlendingWeightCalculationOperation()
void setCornerRounding(float rounding)
SocketReader * m_imageReader
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) override
void setThreshold(float threshold)
void deinitExecution() override
SocketReader * m_valueReader
void initExecution() override
virtual void executePixel(float output[4], int x, int y, void *data) override
void setLocalContrastAdaptationFactor(float factor)
SMAAEdgeDetectionOperation()
void initExecution() override
SMAANeighborhoodBlendingOperation()
void deinitExecution() override
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) override
void * initializeTileData(rcti *rect) override
void executePixel(float output[4], int x, int y, void *data) override
MINLINE float scalenorm(float a, float b, float x)
static void area(int d1, int d2, int e1, int e2, float weights[2])
static const float * areatex_sample_internal(const float *areatex, int x, int y)
static void sample_bilinear_horizontal(SocketReader *reader, int x, int y, float xoffset, float color[4])
static void sample(SocketReader *reader, int x, int y, float color[4])
static void sample_bilinear_vertical(SocketReader *reader, int x, int y, float yoffset, float color[4])
static void area_diag(int d1, int d2, int e1, int e2, float weights[2])