Fixed interaction between bloom and point glow

This commit is contained in:
Joshua Barretto 2022-01-20 22:30:05 +00:00
parent 5a7cd39625
commit c2644d8e71
4 changed files with 18 additions and 16 deletions

View File

@ -70,9 +70,7 @@ void main() {
#if (CLOUD_MODE != CLOUD_MODE_NONE)
color.rgb = get_cloud_color(color.rgb, dir, cam_pos.xyz, time_of_day.x, dist, 1.0);
#else
#ifdef BLOOM_FACTOR
color.rgb = apply_point_glow(cam_pos.xyz + focus_off.xyz, dir, dist, color.rgb, BLOOM_FACTOR);
#endif
color.rgb = apply_point_glow(cam_pos.xyz + focus_off.xyz, dir, dist, color.rgb, BLOOM_FACTOR);
#endif
tgt_color = vec4(color.rgb, 1);

View File

@ -265,9 +265,7 @@ vec3 get_cloud_color(vec3 surf_color, vec3 dir, vec3 origin, const float time_of
}
// Apply point glow
#ifdef BLOOM_FACTOR
surf_color = apply_point_glow(origin, dir, max_dist, surf_color, BLOOM_FACTOR);
#endif
surf_color = apply_point_glow(origin, dir, max_dist, surf_color);
return surf_color;
}

View File

@ -318,9 +318,13 @@ vec3 lod_norm(vec2 f_pos/*vec3 pos*/) {
#ifdef EXPERIMENTAL_PROCEDURALLODDETAIL
vec2 wpos = f_pos + focus_off.xy;
norm.xy += vec2(
textureLod(sampler2D(t_noise, s_noise), wpos / 200, 0).x - 0.5,
textureLod(sampler2D(t_noise, s_noise), wpos / 200 + 0.5, 0).x - 0.5
) * 0.35;
textureLod(sampler2D(t_noise, s_noise), wpos / 250, 0).x - 0.5,
textureLod(sampler2D(t_noise, s_noise), wpos / 250 + 0.5, 0).x - 0.5
) * 0.25 / pow(norm.z + 0.1, 3);
norm.xy += vec2(
textureLod(sampler2D(t_noise, s_noise), wpos / 100, 0).x - 0.5,
textureLod(sampler2D(t_noise, s_noise), wpos / 100 + 0.5, 0).x - 0.5
) * 0.15 / pow(norm.z + 0.1, 3);
norm = normalize(norm);
#endif
@ -356,7 +360,10 @@ vec3 lod_col(vec2 pos) {
vec2 shift = vec2(
textureLod(sampler2D(t_noise, s_noise), wpos / 200, 0).x - 0.5,
textureLod(sampler2D(t_noise, s_noise), wpos / 200 + 0.5, 0).x - 0.5
) * 64;
) * 64 + vec2(
textureLod(sampler2D(t_noise, s_noise), wpos / 50, 0).x - 0.5,
textureLod(sampler2D(t_noise, s_noise), wpos / 50 + 0.5, 0).x - 0.5
) * 48;
pos += shift;
wpos += shift;
#endif
@ -365,10 +372,10 @@ vec3 lod_col(vec2 pos) {
#ifdef EXPERIMENTAL_PROCEDURALLODDETAIL
col *= pow(vec3(
textureLod(sampler2D(t_noise, s_noise), wpos / 40, 0).x,
textureLod(sampler2D(t_noise, s_noise), wpos / 50 + 0.5, 0).x,
textureLod(sampler2D(t_noise, s_noise), wpos / 45 + 0.75, 0).x
), vec3(0.5));
textureLod(sampler2D(t_noise, s_noise), wpos / 40, 0).x - 0.5,
textureLod(sampler2D(t_noise, s_noise), wpos / 50 + 0.5, 0).x - 0.5,
textureLod(sampler2D(t_noise, s_noise), wpos / 45 + 0.75, 0).x - 0.5
) + 1.0, vec3(0.5));
#endif
return col;

View File

@ -1,7 +1,7 @@
#ifndef POINT_GLOW_GLSL
#define POINT_GLOW_GLSL
vec3 apply_point_glow(vec3 wpos, vec3 dir, float max_dist, vec3 color, const float factor) {
vec3 apply_point_glow(vec3 wpos, vec3 dir, float max_dist, vec3 color) {
#ifndef POINT_GLOW_FACTOR
return color;
#else
@ -36,7 +36,6 @@ vec3 apply_point_glow(vec3 wpos, vec3 dir, float max_dist, vec3 color, const flo
color += light_color
* 0.05
// Constant, *should* const fold
* pow(factor, 0.65)
* POINT_GLOW_FACTOR;
}
#endif