negative_bloom

This commit is contained in:
2023-05-11 02:12:05 +02:00
parent 0abb860185
commit 1722f61250
5 changed files with 68 additions and 16 deletions

View File

@@ -29,14 +29,20 @@ void setup_bloom(
const auto bloom_internal_format = GL_RGB565; // prolly fine. NOPE its not. it causes green pixely halos
const auto bloom_format_type = GL_UNSIGNED_BYTE;
#else
//const auto bloom_internal_format = GL_RGBA16F;
const auto bloom_internal_format = GL_R11F_G11F_B10F;
const auto bloom_format_type = GL_FLOAT;
const auto bloom_format_type = GL_RGBA;
const auto bloom_internal_format = GL_RGBA16F;
//const auto bloom_internal_format = GL_R11F_G11F_B10F;
const auto bloom_data_type = GL_FLOAT;
//const auto bloom_format_type = GL_RGBA_INTEGER;
//const auto bloom_internal_format = GL_RGBA16I;
//const auto bloom_data_type = GL_SHORT;
#endif
#else
//const auto bloom_internal_format = GL_RGB16F;
const auto bloom_internal_format = GL_R11F_G11F_B10F;
const auto bloom_format_type = GL_FLOAT;
const auto bloom_format_type = GL_RGB;
const auto bloom_internal_format = GL_RGB16F; // opengl silently upgrades to RGBA
//const auto bloom_internal_format = GL_R11F_G11F_B10F; // no sign
const auto bloom_data_type = GL_FLOAT;
#endif
{ // bloom in (bloom extraction)
@@ -44,7 +50,7 @@ void setup_bloom(
"bloom_in",
bloom_internal_format,
w * bloom_in_scale, h * bloom_in_scale,
GL_RGB, bloom_format_type
bloom_format_type, bloom_data_type
);
{ // filter
rm_t.get("bloom_in"_hs)->bind(0);
@@ -72,7 +78,7 @@ void setup_bloom(
tex_out_id,
bloom_internal_format,
w * bloom_in_scale * glm::pow(bloom_phase_scale, i), h * bloom_in_scale * glm::pow(bloom_phase_scale, i),
GL_RGB, bloom_format_type
bloom_format_type, bloom_data_type
);
{ // filter
rm_t.get(tex_out_id)->bind(0);
@@ -89,7 +95,7 @@ void setup_bloom(
tex_tmp_id,
bloom_internal_format,
w * bloom_in_scale * glm::pow(bloom_phase_scale, i), h * bloom_in_scale * glm::pow(bloom_phase_scale, i),
GL_RGB, bloom_format_type
bloom_format_type, bloom_data_type
);
{ // filter
rm_t.get(tex_tmp_id)->bind(0);

View File

@@ -106,7 +106,15 @@ void main() {
vec3 color = texture(color_tex, _uv).rgb;
// TODO: expose threshold
_out_color = max(vec3(0.0), color - vec3(1.0));
//_out_color = max(vec3(0.0), color - vec3(1.0));
//_out_color = mix(
//color, // < 0.0
//max(vec3(0.0), color - vec3(1.0)), // > 0.0
//step(vec3(0.0), color)
//);
_out_color = max(min(color, vec3(0.0)), color - vec3(1.0));
})")
}

View File

@@ -141,7 +141,7 @@ void main() {
vec3 color = texture(color_tex, _uv).rgb;
vec3 bloom = texture(bloom_tex, _uv).rgb;
vec3 comp = color + bloom * vec3(bloom_factor);
vec3 comp = max(vec3(0.0), color + bloom * vec3(bloom_factor));
#if 0
const vec3 tint = vec3(1.5, 0.8, 1.1);