From 43a4aaf8e6f0ccbd9ef63c44861206024f71590b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 27 Aug 2015 19:43:33 +0200 Subject: Compositor: Reduce number of divisions in EWA filtering --- source/blender/compositor/intern/COM_MemoryBuffer.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source/blender/compositor/intern') diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp index 162e08a95a6..7ee5e2f7c57 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp +++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp @@ -204,14 +204,15 @@ static void read_ewa_pixel_sampled(void *userdata, int x, int y, float result[4] void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivatives[2][2]) { BLI_assert(this->m_datatype == COM_DT_COLOR); - int width = this->getWidth(), height = this->getHeight(); + float inv_width = 1.0f / (float)this->getWidth(), + inv_height = 1.0f / (float)this->getHeight(); /* TODO(sergey): Render pipeline uses normalized coordinates and derivatives, * but compositor uses pixel space. For now let's just divide the values and * switch compositor to normalized space for EWA later. */ - float uv_normal[2] = {uv[0] / width, uv[1] / height}; - float du_normal[2] = {derivatives[0][0] / width, derivatives[0][1] / height}; - float dv_normal[2] = {derivatives[1][0] / width, derivatives[1][1] / height}; + float uv_normal[2] = {uv[0] * inv_width, uv[1] * inv_height}; + float du_normal[2] = {derivatives[0][0] * inv_width, derivatives[0][1] * inv_height}; + float dv_normal[2] = {derivatives[1][0] * inv_width, derivatives[1][1] * inv_height}; BLI_ewa_filter(this->getWidth(), this->getHeight(), false, -- cgit v1.2.3