1: #version 300 es
2: #define EXPOSURE_BEGIN
3: precision highp float;
4: precision highp int;
5: precision highp sampler2D;
6: precision highp samplerCube;
7: precision highp sampler2DArray;
8:
9: uniform highp sampler2D source_exposure; //texunit:0
10: /* clang-format on */
11:
12: #ifdef EXPOSURE_BEGIN
13:
14: uniform highp ivec2 source_render_size;
15: uniform highp ivec2 target_size;
16:
17: #endif
18:
19: #ifdef EXPOSURE_END
20:
21: uniform highp sampler2D prev_exposure; //texunit:1
22: uniform highp float exposure_adjust;
23: uniform highp float min_luminance;
24: uniform highp float max_luminance;
25:
26: #endif
27:
28: layout(location = 0) out highp float exposure;
29:
30: void main() {
31:
32: #ifdef EXPOSURE_BEGIN
33:
34: ivec2 src_pos = ivec2(gl_FragCoord.xy) * source_render_size / target_size;
35:
36: #if 1
37: //more precise and expensive, but less jittery
38: ivec2 next_pos = ivec2(gl_FragCoord.xy + ivec2(1)) * source_render_size / target_size;
39: next_pos = max(next_pos, src_pos + ivec2(1)); //so it at least reads one pixel
40: highp vec3 source_color = vec3(0.0);
41: for (int i = src_pos.x; i < next_pos.x; i++) {
42: for (int j = src_pos.y; j < next_pos.y; j++) {
43: source_color += texelFetch(source_exposure, ivec2(i, j), 0).rgb;
44: }
45: }
46:
47: source_color /= float((next_pos.x - src_pos.x) * (next_pos.y - src_pos.y));
48: #else
49: highp vec3 source_color = texelFetch(source_exposure, src_pos, 0).rgb;
50:
51: #endif
52:
53: exposure = max(source_color.r, max(source_color.g, source_color.b));
54:
55: #else
56:
57: ivec2 coord = ivec2(gl_FragCoord.xy);
58: exposure = texelFetch(source_exposure, coord * 3 + ivec2(0, 0), 0).r;
59: exposure += texelFetch(source_exposure, coord * 3 + ivec2(1, 0), 0).r;
60: exposure += texelFetch(source_exposure, coord * 3 + ivec2(2, 0), 0).r;
61: exposure += texelFetch(source_exposure, coord * 3 + ivec2(0, 1), 0).r;
62: exposure += texelFetch(source_exposure, coord * 3 + ivec2(1, 1), 0).r;
63: exposure += texelFetch(source_exposure, coord * 3 + ivec2(2, 1), 0).r;
64: exposure += texelFetch(source_exposure, coord * 3 + ivec2(0, 2), 0).r;
65: exposure += texelFetch(source_exposure, coord * 3 + ivec2(1, 2), 0).r;
66: exposure += texelFetch(source_exposure, coord * 3 + ivec2(2, 2), 0).r;
67: exposure *= (1.0 / 9.0);
68:
69: #ifdef EXPOSURE_END
70:
71: #ifdef EXPOSURE_FORCE_SET
72: //will stay as is
73: #else
74: highp float prev_lum = texelFetch(prev_exposure, ivec2(0, 0), 0).r; //1 pixel previous exposure
75: exposure = clamp(prev_lum + (exposure - prev_lum) * exposure_adjust, min_luminance, max_luminance);
76:
77: #endif //EXPOSURE_FORCE_SET
78:
79: #endif //EXPOSURE_END
80:
81: #endif //EXPOSURE_BEGIN
82: }
83:
**ERROR**: ExposureShaderGLES3: Fragment Program Compilation Failed:
0:38(25): error: could not implicitly convert operands to arithmetic operator
0:38(19): error: cannot construct `ivec2' from a non-numeric data type
0:38(19): error: operands to arithmetic operators must be numeric
0:38(19): error: operands to arithmetic operators must be numeric
0:39(17): warning: `next_pos' used uninitialized
At: drivers/gles3/shader_gles3.cpp:164:_display_error_with_code() - ExposureShaderGLES3: Fragment Program Compilation Failed:
0:38(25): error: could not implicitly convert operands to arithmetic operator
0:38(19): error: cannot construct `ivec2' from a non-numeric data type
0:38(19): error: operands to arithmetic operators must be numeric
0:38(19): error: operands to arithmetic operators must be numeric
0:39(17): warning: `next_pos' used uninitialized
**ERROR**: ExposureShaderGLES3: Fragment Program Compilation Failed:
0:38(25): error: could not implicitly convert operands to arithmetic operator
0:38(19): error: cannot construct `ivec2' from a non-numeric data type
0:38(19): error: operands to arithmetic operators must be numeric
0:38(19): error: operands to arithmetic operators must be numeric
0:39(17): warning: `next_pos' used uninitialized
At: drivers/gles3/shader_gles3.cpp:429:get_current_version() - ExposureShaderGLES3: Fragment Program Compilation Failed:
0:38(25): error: could not implicitly convert operands to arithmetic operator
0:38(19): error: cannot construct `ivec2' from a non-numeric data type
0:38(19): error: operands to arithmetic operators must be numeric
0:38(19): error: operands to arithmetic operators must be numeric
0:39(17): warning: `next_pos' used uninitialized
**ERROR**: Method/Function Failed, returning: __null
At: drivers/gles3/shader_gles3.cpp:437:get_current_version() - Method/Function Failed, returning: __null
**ERROR**: Condition ' !version ' is true. returned: false
At: drivers/gles3/shader_gles3.cpp:123:bind() - Condition ' !version ' is true. returned: false
**ERROR**: Condition ' !version ' is true. returned: -1
At: drivers/gles3/shader_gles3.h:381:_get_uniform() - Condition ' !version ' is true. returned: -1
**ERROR**: Condition ' !version ' is true. returned: -1
At: drivers/gles3/shader_gles3.h:381:_get_uniform() - Condition ' !version ' is true. returned: -1
no savefile detected
fading from menu to meteorite