| 1 | // GLSL 1.20 twin of translucent.wgsl: the frame, blended in linear light, premultiplied |
| 2 | // again in sRGB for a window server that composites that way. |
| 3 | #ifdef VERTEX |
| 4 | attribute vec2 position; |
| 5 | |
| 6 | void main() { |
| 7 | gl_Position = vec4(position, 0.0, 1.0); |
| 8 | } |
| 9 | #else |
| 10 | uniform sampler2D frame; |
| 11 | uniform vec2 size; |
| 12 | |
| 13 | vec3 encode(vec3 linear) { |
| 14 | return mix(1.055 * pow(linear, vec3(1.0 / 2.4)) - 0.055, linear * 12.92, |
| 15 | vec3(lessThanEqual(linear, vec3(0.0031308)))); |
| 16 | } |
| 17 | |
| 18 | void main() { |
| 19 | vec4 pixel = texture2D(frame, gl_FragCoord.xy / size); |
| 20 | gl_FragColor = pixel.a == 0.0 ? vec4(0.0) : vec4(encode(pixel.rgb / pixel.a) * pixel.a, pixel.a); |
| 21 | } |
| 22 | #endif |