[vertex] layout(location=0) in highp vec4 vertex_attrib; void main() { gl_Position = vertex_attrib; } [fragment] uniform highp sampler2D source_exposure; //texunit:0 #ifdef EXPOSURE_BEGIN uniform highp ivec2 source_render_size; uniform highp ivec2 target_size; #endif #ifdef EXPOSURE_END uniform highp sampler2D prev_exposure; //texunit:1 uniform highp float exposure_adjust; uniform highp float min_luminance; uniform highp float max_luminance; #endif layout(location = 0) out highp float exposure; void main() { #ifdef EXPOSURE_BEGIN ivec2 src_pos = ivec2(gl_FragCoord.xy)*source_render_size/target_size; #if 1 //more precise and expensive, but less jittery ivec2 next_pos = ivec2(gl_FragCoord.xy+ivec2(1))*source_render_size/target_size; next_pos = max(next_pos,src_pos+ivec2(1)); //so it at least reads one pixel highp vec3 source_color=vec3(0.0); for(int i=src_pos.x;i