gpu_tonemapper: Adjust sample points to maintain linearity
Adjust texture sample points to maintain linearity throughout the
sample range
CRs-Fixed: 1110654
Change-Id: I2c198c9f330a0b6001d2eda28c0355f2c9ecbde4
diff --git a/gpu_tonemapper/Tonemapper.cpp b/gpu_tonemapper/Tonemapper.cpp
index ec74b80..38b4fe2 100644
--- a/gpu_tonemapper/Tonemapper.cpp
+++ b/gpu_tonemapper/Tonemapper.cpp
@@ -33,6 +33,12 @@
lutXformTexture = 0;
programID = 0;
eglImageWrapper = new EGLImageWrapper();
+
+ lutXformScaleOffset[0] = 1.0f;
+ lutXformScaleOffset[1] = 0.0f;
+
+ tonemapScaleOffset[0] = 1.0f;
+ tonemapScaleOffset[1] = 0.0f;
}
//-----------------------------------------------------------------------------
@@ -72,9 +78,17 @@
// load the 3d lut
tonemapper->tonemapTexture = engine_load3DTexture(colorMap, colorMapSize, 0);
+ tonemapper->tonemapScaleOffset[0] = ((float)(colorMapSize-1))/((float)(colorMapSize));
+ tonemapper->tonemapScaleOffset[1] = 1.0f/(2.0f*colorMapSize);
+
// load the non-uniform xform
tonemapper->lutXformTexture = engine_load1DTexture(lutXform, lutXformSize, 0);
bool bUseXform = (tonemapper->lutXformTexture != 0) && (lutXformSize != 0);
+ if( bUseXform )
+ {
+ tonemapper->lutXformScaleOffset[0] = ((float)(lutXformSize-1))/((float)(lutXformSize));
+ tonemapper->lutXformScaleOffset[1] = 1.0f/(2.0f*lutXformSize);
+ }
// create the program
const char *fragmentShaders[3];
@@ -115,6 +129,13 @@
// bind the program
engine_setProgram(programID);
+ engine_setData2f(3, tonemapScaleOffset);
+ bool bUseXform = (lutXformTexture != 0);
+ if( bUseXform )
+ {
+ engine_setData2f(4, lutXformScaleOffset);
+ }
+
// set destination
engine_setDestination(dst_buffer->getFramebuffer(), 0, 0, dst_buffer->getWidth(),
dst_buffer->getHeight());