Added HDR

This commit is contained in:
Joshua Barretto 2020-11-16 13:50:33 +00:00
parent 49df604de0
commit 1d031538f9
4 changed files with 16 additions and 8 deletions

View File

@ -167,7 +167,7 @@ vec3 get_cloud_color(vec3 surf_color, vec3 dir, vec3 origin, const float time_of
// Add the directed light light scattered into the camera by the clouds
get_sun_color() * sun_scatter * sun_access * scatter_factor * get_sun_brightness() +
// Really we should multiple by just moon_brightness here but this just looks better given that we lack HDR
get_moon_color() * moon_scatter * moon_access * scatter_factor * get_moon_brightness() * 3.0 +
get_moon_color() * moon_scatter * moon_access * scatter_factor * get_moon_brightness() * 4.0 +
// Global illumination (uniform scatter from the sky)
sky_color * sun_access * scatter_factor * get_sun_brightness() +
sky_color * moon_access * scatter_factor * get_moon_brightness();

View File

@ -17,13 +17,13 @@ const vec3 SKY_DAY_TOP = vec3(0.1, 0.5, 0.9);
const vec3 SKY_DAY_MID = vec3(0.02, 0.28, 0.8);
const vec3 SKY_DAY_BOT = vec3(0.1, 0.2, 0.3);
const vec3 DAY_LIGHT = vec3(1.9, 1.75, 0.9);//vec3(1.5, 1.4, 1.0);
const vec3 SUN_HALO_DAY = vec3(0.35, 0.35, 0.0);
const vec3 SUN_HALO_DAY = vec3(0.35, 0.35, 0.0) * 10;
const vec3 SKY_DUSK_TOP = vec3(0.06, 0.1, 0.20);
const vec3 SKY_DUSK_MID = vec3(0.35, 0.1, 0.15);
const vec3 SKY_DUSK_BOT = vec3(0.0, 0.1, 0.23);
const vec3 DUSK_LIGHT = vec3(9.0, 1.5, 0.15);
const vec3 SUN_HALO_DUSK = vec3(1.2, 0.25, 0.0);
const vec3 SUN_HALO_DUSK = vec3(1.2, 0.025, 0.0) * 10;
const vec3 SKY_NIGHT_TOP = vec3(0.001, 0.001, 0.0025);
const vec3 SKY_NIGHT_MID = vec3(0.001, 0.005, 0.02);
@ -417,7 +417,7 @@ vec3 get_sky_color(vec3 dir, float time_of_day, vec3 origin, vec3 f_pos, float q
}
// Sun
const vec3 SUN_SURF_COLOR = vec3(1.5, 0.9, 0.35) * 200.0;
const vec3 SUN_SURF_COLOR = vec3(1.5, 0.9, 0.35) * 5000.0;
vec3 sun_halo_color = mix(
SUN_HALO_DUSK,
@ -425,7 +425,7 @@ vec3 get_sky_color(vec3 dir, float time_of_day, vec3 origin, vec3 f_pos, float q
max(-sun_dir.z, 0.0)
);
vec3 sun_halo = pow(max(dot(dir, -sun_dir) + 0.1, 0.0), 8.0) * sun_halo_color;
vec3 sun_halo = sun_halo_color * 0.000025 / pow(0.51 - dot(dir, -sun_dir) * 0.5, 3.0);
vec3 sun_surf = vec3(0);
if (with_features) {
sun_surf = pow(max(dot(dir, -sun_dir) - 0.001, 0.0), 5000.0) * SUN_SURF_COLOR * SUN_COLOR_FACTOR; // Hack to prevent sun vanishing too early
@ -433,10 +433,11 @@ vec3 get_sky_color(vec3 dir, float time_of_day, vec3 origin, vec3 f_pos, float q
vec3 sun_light = sun_halo + sun_surf;
// Moon
const vec3 MOON_SURF_COLOR = vec3(0.7, 1.0, 1.5) * 500.0;
const vec3 MOON_SURF_COLOR = vec3(0.7, 1.0, 1.5) * 5000.0;
const vec3 MOON_HALO_COLOR = vec3(0.015, 0.015, 0.05);
vec3 moon_halo = pow(max(dot(dir, -moon_dir) + 0.1, 0.0), 8.0) * MOON_HALO_COLOR;
vec3 moon_halo_color = MOON_HALO_COLOR;
vec3 moon_halo = moon_halo_color * 0.001 / pow(0.51 - dot(dir, -moon_dir) * 0.5, 2.0);//pow(max(dot(dir, -moon_dir) + 0.1, 0.0), 8.0) * MOON_HALO_COLOR;
vec3 moon_surf = vec3(0);
if (with_features) {
moon_surf = pow(max(dot(dir, -moon_dir) - 0.001, 0.0), 5000.0) * MOON_SURF_COLOR; // Hack to prevent moon vanishing too early

View File

@ -204,6 +204,13 @@ void main() {
vec4 aa_color = aa_apply(src_color, uv * screen_res.xy, screen_res.xy);
// Tonemapping
float exposure = 1.0;
float tone_gamma = 1.0;
aa_color.rgb = vec3(1.0) - exp(-aa_color.rgb * exposure);
// gamma correction
aa_color.rgb = pow(aa_color.rgb, vec3(1.0 / tone_gamma));
/*
// Apply clouds to `aa_color`
#if (CLOUD_MODE != CLOUD_MODE_NONE)

View File

@ -33,7 +33,7 @@ use tracing::{error, warn};
use vek::*;
/// Represents the format of the pre-processed color target.
pub type TgtColorFmt = gfx::format::Srgba8;
pub type TgtColorFmt = gfx::format::Rgba16F;
/// Represents the format of the pre-processed depth and stencil target.
pub type TgtDepthStencilFmt = gfx::format::Depth;