compositor - EWA filter was blurring too much by default, this caused the displace node to blur the image when no displacement was applied, making images fuzzy, the original C code has an interpolation option.

Added this option back and use for displace and UV composite nodes.
This commit is contained in:
2012-08-16 10:13:04 +00:00
parent 121fd266b0
commit add9aea573
7 changed files with 15 additions and 12 deletions

View File

@@ -259,7 +259,10 @@ float clipuv(float x, float limit)
return x;
}
void MemoryBuffer::readEWA(float result[4], float fx, float fy, float dx, float dy)
/**
* \note \a sampler at the moment is either 'COM_PS_NEAREST' or not, other values won't matter.
*/
void MemoryBuffer::readEWA(float result[4], float fx, float fy, float dx, float dy, PixelSampler sampler)
{
const int width = this->getWidth(), height = this->getHeight();
@@ -280,7 +283,7 @@ void MemoryBuffer::readEWA(float result[4], float fx, float fy, float dx, float
// Use a different radius based on interpolation switch, just enough to anti-alias when interpolation is off,
// and slightly larger to make result a bit smoother than bilinear interpolation when interpolation is on
// (minimum values: const float rmin = intpol ? 1.f : 0.5f;)
const float rmin = 1.5625f / ff2;
const float rmin = ((sampler != COM_PS_NEAREST) ? 1.5625f : 0.765625f) / ff2;
imp2radangle(A, B, C, F, &a, &b, &th, &ecc);
if ((b2 = b * b) < rmin) {
if ((a2 = a * a) < rmin) {

View File

@@ -202,7 +202,7 @@ public:
void readEWA(float result[4], float fx, float fy, float dx, float dy);
void readEWA(float result[4], float fx, float fy, float dx, float dy, PixelSampler sampler);
/**
* @brief is this MemoryBuffer a temporarily buffer (based on an area, not on a chunk)

View File

@@ -88,7 +88,7 @@ protected:
* @param dy
* @param inputBuffers chunks that can be read by their ReadBufferOperation.
*/
virtual void executePixel(float output[4], float x, float y, float dx, float dy) {}
virtual void executePixel(float output[4], float x, float y, float dx, float dy, PixelSampler sampler) {}
public:
inline void read(float *result, float x, float y, PixelSampler sampler) {
@@ -97,8 +97,8 @@ public:
inline void read(float *result, int x, int y, void *chunkData) {
executePixel(result, x, y, chunkData);
}
inline void read(float *result, float x, float y, float dx, float dy) {
executePixel(result, x, y, dx, dy);
inline void read(float *result, float x, float y, float dx, float dy, PixelSampler sampler) {
executePixel(result, x, y, dx, dy, sampler);
}
virtual void *initializeTileData(rcti *rect) { return 0; }

View File

@@ -95,8 +95,8 @@ void DisplaceOperation::executePixel(float output[4], int x, int y, void *data)
dxt = signf(dxt) * maxf(fabsf(dxt), DISPLACE_EPSILON) / this->getWidth();
dyt = signf(dyt) * maxf(fabsf(dyt), DISPLACE_EPSILON) / this->getHeight();
/* EWA filtering */
this->m_inputColorProgram->read(output, u, v, dxt, dyt);
/* EWA filtering (without nearest it gets blurry with NO distortion) */
this->m_inputColorProgram->read(output, u, v, dxt, dyt, COM_PS_NEAREST);
}
void DisplaceOperation::deinitExecution()

View File

@@ -107,7 +107,7 @@ void MapUVOperation::executePixel(float output[4], float x, float y, PixelSample
u = inputUV[0] * this->m_inputColorProgram->getWidth();
v = inputUV[1] * this->m_inputColorProgram->getHeight();
this->m_inputColorProgram->read(output, u, v, dx, dy);
this->m_inputColorProgram->read(output, u, v, dx, dy, COM_PS_NEAREST);
/* "premul" */
if (alpha < 1.0f) {

View File

@@ -59,9 +59,9 @@ void ReadBufferOperation::executePixel(float output[4], float x, float y, PixelS
}
}
void ReadBufferOperation::executePixel(float output[4], float x, float y, float dx, float dy)
void ReadBufferOperation::executePixel(float output[4], float x, float y, float dx, float dy, PixelSampler sampler)
{
m_buffer->readEWA(output, x, y, dx, dy);
m_buffer->readEWA(output, x, y, dx, dy, sampler);
}
bool ReadBufferOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)

View File

@@ -40,7 +40,7 @@ public:
void *initializeTileData(rcti *rect);
void executePixel(float output[4], float x, float y, PixelSampler sampler);
void executePixel(float output[4], float x, float y, float dx, float dy);
void executePixel(float output[4], float x, float y, float dx, float dy, PixelSampler sampler);
const bool isReadBufferOperation() const { return true; }
void setOffset(unsigned int offset) { this->m_offset = offset; }
unsigned int getOffset() { return this->m_offset; }