Static light flickering

This commit is contained in:
Joshua Barretto 2021-03-04 11:02:40 +00:00
parent 427e0af73c
commit d4ce69df99
5 changed files with 12 additions and 3 deletions

View File

@ -184,7 +184,7 @@ void main() {
float ao = f_ao * sqrt(f_ao);//0.25 + f_ao * 0.75; ///*pow(f_ao, 0.5)*/f_ao * 0.85 + 0.15;
vec3 glow = pow(pow(model_glow.w, 2.0) * (max(dot(f_norm, normalize(model_glow.xyz)) * 0.5 + 0.5, 0.0) * 1.0 + max(1.0 - length(model_glow.xyz), 0.0)), 1) * 4 * GLOW_COLOR;
vec3 glow = pow(pow(model_glow.w, 2.0) * (max(dot(f_norm, normalize(model_glow.xyz)) * 0.5 + 0.5, 0.0) * 1.0 + max(1.0 - length(model_glow.xyz), 0.0)), 1) * 4 * glow_light(f_pos);
emitted_light += glow;
reflected_light *= ao;

View File

@ -26,6 +26,11 @@ float hash_fast(uvec3 q)
return float(n) * (1.0/float(0xffffffffU));
}
// 2D, but using shifted 2D textures
float noise_2d(vec2 pos) {
return texture(t_noise, pos).x;
}
// 3D, but using shifted 2D textures
float noise_3d(vec3 pos) {
pos.z *= 15.0;

View File

@ -47,6 +47,10 @@ const float PERSISTENT_AMBIANCE = 1.0 / 32.0;// 1.0 / 80; // 1.0 / 512; // 0.001
// Allowed to be > 1 due to HDR
const vec3 GLOW_COLOR = vec3(3.0, 0.9, 0.05);
vec3 glow_light(vec3 pos) {
return GLOW_COLOR * (1.0 + (noise_3d(vec3(pos.xy * 0.005, tick.x * 0.5)) - 0.5) * 1.0);
}
//vec3 get_sun_dir(float time_of_day) {
// const float TIME_FACTOR = (PI * 2.0) / (3600.0 * 24.0);
//

View File

@ -174,7 +174,7 @@ void main() {
reflected_light += point_light; */
// float ao = /*pow(f_ao, 0.5)*/f_ao * 0.85 + 0.15;
vec3 glow = pow(f_inst_light.y, 3) * 4 * GLOW_COLOR;
vec3 glow = pow(f_inst_light.y, 3) * 4 * glow_light(f_pos);
emitted_light += glow;
float ao = f_ao;

View File

@ -266,7 +266,7 @@ void main() {
max_light *= f_light;
// TODO: Apply AO after this
vec3 glow = GLOW_COLOR * (pow(f_glow, 6) * 5 + pow(f_glow, 1.5) * 2);
vec3 glow = glow_light(f_pos) * (pow(f_glow, 6) * 5 + pow(f_glow, 1.5) * 2);
reflected_light += glow;
max_light += lights_at(f_pos, f_norm, view_dir, mu, cam_attenuation, fluid_alt, k_a, k_d, k_s, alpha, f_norm, 1.0, emitted_light, reflected_light);