mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add photorealistic experimental shader
This commit is contained in:
parent
1924c67033
commit
4253833aaf
@ -198,12 +198,15 @@ float lights_at(vec3 wpos, vec3 wnorm, vec3 /*cam_to_frag*/view_dir, vec3 mu, ve
|
||||
/* is_direct = true; */
|
||||
float computed_shadow = ShadowCalculationPoint(i, -difference, wnorm, wpos/*, light_distance*/);
|
||||
// directed_light += is_direct ? max(computed_shadow, /*LIGHT_AMBIANCE*/0.0) * direct_light : vec3(0.0);
|
||||
// Non-physically emulate ambient light nearby
|
||||
float ambiance = mix(0.05, 0.5, (dot(wnorm, direct_light_dir) + 1.0) * 0.5) * strength;
|
||||
#ifdef FIGURE_SHADER
|
||||
// Non-physical hack. Subtle, but allows lanterns to glow nicely
|
||||
// TODO: Make lanterns use glowing cells instead
|
||||
ambiance += 0.1 / distance_2;
|
||||
float ambiance = 0.0;
|
||||
#ifndef EXPERIMENTAL_PHOTOREALISTIC
|
||||
// Non-physically emulate ambient light nearby
|
||||
ambiance = mix(0.05, 0.5, (dot(wnorm, direct_light_dir) + 1.0) * 0.5) * strength;
|
||||
#ifdef FIGURE_SHADER
|
||||
// Non-physical hack. Subtle, but allows lanterns to glow nicely
|
||||
// TODO: Make lanterns use glowing cells instead
|
||||
ambiance += 0.1 / distance_2;
|
||||
#endif
|
||||
#endif
|
||||
directed_light += (is_direct ? mix(LIGHT_AMBIANCE, 1.0, computed_shadow) * direct_light : vec3(0.0)) + ambiance * color;
|
||||
// directed_light += (is_direct ? 1.0 : LIGHT_AMBIANCE) * max(computed_shadow, /*LIGHT_AMBIANCE*/0.0) * direct_light;// : vec3(0.0);
|
||||
|
@ -46,10 +46,7 @@ const vec3 NIGHT_LIGHT = vec3(5.0, 0.75, 0.2);
|
||||
// Linear RGB, scattering coefficients for atmosphere at roughly R, G, B wavelengths.
|
||||
//
|
||||
// See https://en.wikipedia.org/wiki/Diffuse_sky_radiation
|
||||
//
|
||||
// The most realistic value is `vec3(0.05, 0.10, 0.23)`, but this looks bad in some cases, mostly because we don't
|
||||
// compensate for the dynamic range of the human eye vs the screen.
|
||||
const vec3 MU_SCATTER = vec3(0.15, 0.15, 0.23);
|
||||
const vec3 MU_SCATTER = vec3(0.05, 0.10, 0.23);
|
||||
|
||||
const float SUN_COLOR_FACTOR = 5.0;//6.0;// * 1.5;//1.8;
|
||||
const float MOON_COLOR_FACTOR = 5.0;//6.0;// * 1.5;//1.8;
|
||||
@ -319,11 +316,14 @@ vec3 lightning_at(vec3 wpos) {
|
||||
// cam_attenuation is the total light attenuation due to the substance for beams between the point and the camera.
|
||||
// surface_alt is the altitude of the attenuating surface.
|
||||
float get_sun_diffuse2(DirectionalLight sun_info, DirectionalLight moon_info, vec3 norm, vec3 dir, vec3 wpos, vec3 mu, vec3 cam_attenuation, float surface_alt, vec3 k_a, vec3 k_d, vec3 k_s, float alpha, vec3 voxel_norm, float voxel_lighting, out vec3 emitted_light, out vec3 reflected_light) {
|
||||
const float MIN_SHADOW = 0.15;
|
||||
const vec3 SUN_AMBIANCE = MU_SCATTER;//0.23;/* / 1.8*/;// 0.1 / 3.0;
|
||||
// Boost moon ambiance, because we don't properly compensate for pupil dilation (which should occur *before* HDR,
|
||||
// not in the end user's eye). Also, real nights are too dark to be fun.
|
||||
const vec3 MOON_AMBIANCE = MU_SCATTER * 5;
|
||||
#ifdef EXPERIMENTAL_PHOTOREALISTIC
|
||||
const vec3 MOON_AMBIANCE = MU_SCATTER;
|
||||
#else
|
||||
// Boost moon ambiance, because we don't properly compensate for pupil dilation (which should occur *before* HDR,
|
||||
// not in the end user's eye). Also, real nights are too dark to be fun.
|
||||
const vec3 MOON_AMBIANCE = vec3(0.15, 0.25, 0.23) * 5;
|
||||
#endif
|
||||
|
||||
/* vec3 sun_dir = sun_info.dir;
|
||||
vec3 moon_dir = moon_info.dir; */
|
||||
|
@ -522,4 +522,7 @@ pub enum ExperimentalShader {
|
||||
/// Make the UI uses nearest neighbor filtering for scaling images instead
|
||||
/// of trying to filter based on the coverage of the sampled pixels.
|
||||
UiNearestScaling,
|
||||
/// Prefer using physically-based values for various rendering parameters,
|
||||
/// where possible.
|
||||
Photorealistic,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user