pub const UPSAMPLE_FRAG: &str = "// upsample.frag \u{2014} combine one level of the bloom pyramid with the next up.\r\n//\r\n// The tent filter from the standard dual-filtering blur. A plain bilinear\r\n// upsample of a sixteenth-size image leaves visible square structure once it\r\n// is added back at full size; nine taps in a 3x3 tent removes it for the cost\r\n// of eight extra samples on a very small texture.\r\n#version 330 core\r\n\r\nin vec2 f_uv;\r\nuniform sampler2D u_lower; // the smaller, blurrier level\r\nuniform sampler2D u_higher; // the level being written back into\r\nuniform float u_radius;\r\nuniform float u_strength;\r\n\r\nout vec4 o_color;\r\n\r\nvoid main() {\r\n vec2 t = (1.0 / vec2(textureSize(u_lower, 0))) * u_radius;\r\n\r\n vec3 c = texture(u_lower, f_uv + vec2(-t.x, t.y)).rgb\r\n + texture(u_lower, f_uv + vec2( 0.0, t.y)).rgb * 2.0\r\n + texture(u_lower, f_uv + vec2( t.x, t.y)).rgb\r\n + texture(u_lower, f_uv + vec2(-t.x, 0.0)).rgb * 2.0\r\n + texture(u_lower, f_uv).rgb * 4.0\r\n + texture(u_lower, f_uv + vec2( t.x, 0.0)).rgb * 2.0\r\n + texture(u_lower, f_uv + vec2(-t.x, -t.y)).rgb\r\n + texture(u_lower, f_uv + vec2( 0.0, -t.y)).rgb * 2.0\r\n + texture(u_lower, f_uv + vec2( t.x, -t.y)).rgb;\r\n c /= 16.0;\r\n\r\n // Added rather than mixed: each level of the pyramid is a different scale\r\n // of the same light, and light adds.\r\n o_color = vec4(texture(u_higher, f_uv).rgb + c * u_strength, 1.0);\r\n}\r\n";Expand description
Combines one level of the bloom pyramid with the next one up.