Skip to content

Commit

Permalink
LUT: add interpolation for the input blue color. #46
Browse files Browse the repository at this point in the history
  • Loading branch information
wysaid committed Jun 3, 2019
1 parent 62e3139 commit 54e836b
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions library/cge/src/filters/cgeLookupFilter.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* cgeLookupFilter.cpp
*
* Created on: 2016-7-4
Expand All @@ -8,7 +8,7 @@

#include "cgeLookupFilter.h"

static CGEConstString s_fsh = CGE_SHADER_STRING_PRECISION_M
static CGEConstString s_fsh = CGE_SHADER_STRING_PRECISION_H
(
varying vec2 textureCoordinate;
uniform sampler2D inputImageTexture;
Expand All @@ -24,11 +24,22 @@ void main()

float blue = color.b * 63.0;
vec2 coord1;
coord1.y = floor(blue / 8.0);
coord1.y = floor(floor(blue) / 8.0);
coord1.x = floor(blue) - (coord1.y * 8.0);

coord1 = coord1 * stepDis + halfPixel + (stepDis - perPixel) * color.xy;
gl_FragColor.rgb = texture2D(lookupTexture, coord1).rgb;
vec2 coord2;
coord2.y = floor(ceil(blue) / 8.0);
coord2.x = ceil(blue) - (coord2.y * 8.0);

vec2 stepsCalc = halfPixel + (stepDis - perPixel) * color.xy;

coord1 = coord1 * stepDis + stepsCalc;
coord2 = coord2 * stepDis + stepsCalc;

vec3 lutColor1 = texture2D(lookupTexture, coord1).rgb;
vec3 lutColor2 = texture2D(lookupTexture, coord2).rgb;

gl_FragColor.rgb = mix(lutColor1, lutColor2, fract(blue));
gl_FragColor.a = color.a;
}
);
Expand Down Expand Up @@ -63,4 +74,4 @@ namespace CGE
CGEImageFilterInterface::render2Texture(handler, srcTexture, vertexBufferID);
}

}
}

0 comments on commit 54e836b

Please sign in to comment.