Fix sprite lighting, HDR from focus_pos.

This commit is contained in:
Joshua Yanovski 2020-04-27 18:45:57 +02:00
parent 0594238004
commit d83b4ae69b
3 changed files with 13 additions and 13 deletions

View File

@ -129,15 +129,15 @@ float lights_at(vec3 wpos, vec3 wnorm, vec3 cam_to_frag, vec3 k_a, vec3 k_d, vec
directed_light += is_direct ? direct_light * square_factor : vec3(0.0); directed_light += is_direct ? direct_light * square_factor : vec3(0.0);
ambient_light += is_direct ? vec3(0.0) : direct_light * LIGHT_AMBIENCE; ambient_light += is_direct ? vec3(0.0) : direct_light * LIGHT_AMBIENCE;
vec3 cam_light_diff = light_pos - cam_pos.xyz; vec3 cam_light_diff = light_pos - focus_pos.xyz;
float cam_distance_2 = dot(cam_light_diff, cam_light_diff);// + 0.0001; float cam_distance_2 = dot(cam_light_diff, cam_light_diff);// + 0.0001;
float cam_strength = 1.0 / (/*4.0 * *//*PI * *//*1.0 + */cam_distance_2); float cam_strength = 1.0 / (/*4.0 * *//*PI * *//*1.0 + */cam_distance_2);
vec3 cam_pos_diff = cam_to_frag.xyz - wpos; // vec3 cam_pos_diff = cam_to_frag.xyz - wpos;
float pos_distance_2 = dot(cam_pos_diff, cam_pos_diff);// + 0.0001; // float pos_distance_2 = dot(cam_pos_diff, cam_pos_diff);// + 0.0001;
float cam_distance = sqrt(cam_distance_2); // float cam_distance = sqrt(cam_distance_2);
float distance = sqrt(distance_2); // float distance = sqrt(distance_2);
float both_strength = cam_distance_2 == 0.0 ? distance_2 == 0.0 ? 0.0 : strength/* * strength*//*1.0*/ : distance_2 == 0.0 ? cam_strength/* * cam_strength*//*1.0*/ : float both_strength = cam_distance_2 == 0.0 ? distance_2 == 0.0 ? 0.0 : strength/* * strength*//*1.0*/ : distance_2 == 0.0 ? cam_strength/* * cam_strength*//*1.0*/ :
// 1.0 / (cam_distance * distance); // 1.0 / (cam_distance * distance);
// sqrt(cam_strength * strength); // sqrt(cam_strength * strength);

View File

@ -6,7 +6,7 @@ in vec3 f_pos;
flat in vec3 f_norm; flat in vec3 f_norm;
in vec3 f_col; in vec3 f_col;
in float f_ao; in float f_ao;
in float f_light; // in float f_light;
out vec4 tgt_color; out vec4 tgt_color;
@ -57,7 +57,7 @@ void main() {
float point_shadow = shadow_at(f_pos, f_norm); float point_shadow = shadow_at(f_pos, f_norm);
// To account for prior saturation. // To account for prior saturation.
float vert_light = pow(f_light, 1.5); // float vert_light = pow(f_light, 1.5);
// vec3 light_frac = light_reflection_factor(f_norm/*vec3(0, 0, 1.0)*/, view_dir, vec3(0, 0, -1.0), vec3(1.0), vec3(R_s), alpha); // vec3 light_frac = light_reflection_factor(f_norm/*vec3(0, 0, 1.0)*/, view_dir, vec3(0, 0, -1.0), vec3(1.0), vec3(R_s), alpha);
/* light_frac += light_reflection_factor(f_norm, view_dir, vec3(1.0, 0, 0.0), vec3(1.0), vec3(1.0), 2.0); /* light_frac += light_reflection_factor(f_norm, view_dir, vec3(1.0, 0, 0.0), vec3(1.0), vec3(1.0), 2.0);
light_frac += light_reflection_factor(f_norm, view_dir, vec3(-1.0, 0, 0.0), vec3(1.0), vec3(1.0), 2.0); light_frac += light_reflection_factor(f_norm, view_dir, vec3(-1.0, 0, 0.0), vec3(1.0), vec3(1.0), 2.0);
@ -72,9 +72,9 @@ void main() {
// vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz); // vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz);
float max_light = 0.0; float max_light = 0.0;
max_light += get_sun_diffuse2(f_norm, /*time_of_day.x, */sun_dir, moon_dir, /*cam_to_frag*/view_dir, k_a/* * (shade_frac * 0.5 + light_frac * 0.5)*/, k_d, k_s, alpha, emitted_light, reflected_light); max_light += get_sun_diffuse2(f_norm, /*time_of_day.x, */sun_dir, moon_dir, /*cam_to_frag*/view_dir, k_a/* * (shade_frac * 0.5 + light_frac * 0.5)*/, k_d, k_s, alpha, emitted_light, reflected_light);
reflected_light *= vert_light * point_shadow * shade_frac; reflected_light *= /*vert_light * */point_shadow * shade_frac;
emitted_light *= vert_light * point_shadow * max(shade_frac, MIN_SHADOW); emitted_light *= /*vert_light * */point_shadow * max(shade_frac, MIN_SHADOW);
max_light *= vert_light * point_shadow * shade_frac; max_light *= /*vert_light * */point_shadow * shade_frac;
// get_sun_diffuse(f_norm, time_of_day.x, light, diffuse_light, ambient_light, 1.0); // get_sun_diffuse(f_norm, time_of_day.x, light, diffuse_light, ambient_light, 1.0);
// float point_shadow = shadow_at(f_pos, f_norm); // float point_shadow = shadow_at(f_pos, f_norm);
// diffuse_light *= f_light * point_shadow; // diffuse_light *= f_light * point_shadow;
@ -83,7 +83,7 @@ void main() {
// diffuse_light += point_light; // diffuse_light += point_light;
// reflected_light += point_light; // reflected_light += point_light;
max_light += lights_at(f_pos, f_norm, cam_to_frag, k_a, k_d, k_s, alpha, emitted_light, reflected_light); max_light += lights_at(f_pos, f_norm, view_dir, k_a, k_d, k_s, alpha, emitted_light, reflected_light);
/* vec3 point_light = light_at(f_pos, f_norm); /* vec3 point_light = light_at(f_pos, f_norm);
emitted_light += point_light; emitted_light += point_light;
reflected_light += point_light; */ reflected_light += point_light; */

View File

@ -17,7 +17,7 @@ out vec3 f_pos;
flat out vec3 f_norm; flat out vec3 f_norm;
out vec3 f_col; out vec3 f_col;
out float f_ao; out float f_ao;
out float f_light; // out float f_light;
const float SCALE = 1.0 / 11.0; const float SCALE = 1.0 / 11.0;
@ -53,7 +53,7 @@ void main() {
f_col *= 4.0; f_col *= 4.0;
} }
f_light = 1.0; // f_light = 1.0;
gl_Position = gl_Position =
all_mat * all_mat *