Align meaning of 'exposure' variable across different stages
Put 'exposure' variable behind ENABLE_AUTO_EXPOSURE
centroid varying vec2 varTexCoord;
#endif
centroid varying vec2 varTexCoord;
#endif
+#ifdef ENABLE_AUTO_EXPOSURE
+varying float exposure; // linear exposure factor, see vertex shader
+#endif
// translate to linear colorspace (approximate)
color = pow(color, vec3(2.2));
// translate to linear colorspace (approximate)
color = pow(color, vec3(2.2));
- color *= pow(2., exposure) * exposureParams.compensationFactor * bloomStrength;
+ color *= exposureParams.compensationFactor * bloomStrength;
+
+#ifdef ENABLE_AUTO_EXPOSURE
+ color *= exposure;
+#endif
+
gl_FragColor = vec4(color, 1.0); // force full alpha to avoid holes in the image.
}
gl_FragColor = vec4(color, 1.0); // force full alpha to avoid holes in the image.
}
+#ifdef ENABLE_AUTO_EXPOSURE
#define exposureMap texture1
uniform sampler2D exposureMap;
#define exposureMap texture1
uniform sampler2D exposureMap;
+varying float exposure;
+#endif
+
#ifdef GL_ES
varying mediump vec2 varTexCoord;
#else
centroid varying vec2 varTexCoord;
#endif
#ifdef GL_ES
varying mediump vec2 varTexCoord;
#else
centroid varying vec2 varTexCoord;
#endif
+#ifdef ENABLE_AUTO_EXPOSURE
+ // value in the texture is on a logarithtmic scale
exposure = texture2D(exposureMap, vec2(0.5)).r;
exposure = texture2D(exposureMap, vec2(0.5)).r;
+ exposure = pow(2., exposure);
+#endif
varTexCoord.st = inTexCoord0.st;
gl_Position = inVertexPosition;
varTexCoord.st = inTexCoord0.st;
gl_Position = inVertexPosition;
centroid varying vec2 varTexCoord;
#endif
centroid varying vec2 varTexCoord;
#endif
+#ifdef ENABLE_AUTO_EXPOSURE
+varying float exposure; // linear exposure factor, see vertex shader
+#endif
if (uv.x > 0.5 || uv.y > 0.5)
#endif
{
if (uv.x > 0.5 || uv.y > 0.5)
#endif
{
- color.rgb *= exposure * exposureParams.compensationFactor;
+ color.rgb *= exposureParams.compensationFactor;
+#ifdef ENABLE_AUTO_EXPOSURE
+ color.rgb *= exposure;
+#endif
+#ifdef ENABLE_AUTO_EXPOSURE
#define exposureMap texture2
uniform sampler2D exposureMap;
#define exposureMap texture2
uniform sampler2D exposureMap;
+varying float exposure;
+#endif
+
#ifdef GL_ES
varying mediump vec2 varTexCoord;
#else
centroid varying vec2 varTexCoord;
#endif
#ifdef GL_ES
varying mediump vec2 varTexCoord;
#else
centroid varying vec2 varTexCoord;
#endif
-varying float exposure;
-
void main(void)
{
#ifdef ENABLE_AUTO_EXPOSURE
void main(void)
{
#ifdef ENABLE_AUTO_EXPOSURE
+ // value in the texture is on a logarithtmic scale
exposure = texture2D(exposureMap, vec2(0.5)).r;
exposure = pow(2., exposure);
exposure = texture2D(exposureMap, vec2(0.5)).r;
exposure = pow(2., exposure);
#endif
varTexCoord.st = inTexCoord0.st;
#endif
varTexCoord.st = inTexCoord0.st;