Address MR 2482 comments.

- Change lava density to 3x water density.
- Use `ServerEvent::Buff` instead of modifying the buff component directly.
- Revert commented-out changes to fluid shaders.
This commit is contained in:
Avi Weinstock 2021-06-20 11:32:05 -04:00
parent f1a1160b80
commit 0f9181cbcb
6 changed files with 15 additions and 46 deletions

View File

@ -37,8 +37,6 @@ layout(location = 1) flat in uint f_pos_norm;
// ShadowLocals shadowMats[/*MAX_LAYER_FACES*/192];
// };
//#define LAVA
layout(std140, set = 2, binding = 0)
uniform u_locals {
vec3 model_offs;
@ -80,11 +78,7 @@ void main() {
// vec3 view_dir = normalize(-vec3(vert_pos4)/* / vert_pos4.w*/);
vec3 view_dir = -cam_to_frag;
// vec3 surf_color = /*srgb_to_linear*/(vec3(0.4, 0.7, 2.0));
#ifdef LAVA
vec3 water_color = (1.0 - MU_LAVA);
#else
/*const */vec3 water_color = (1.0 - MU_WATER) * MU_SCATTER;//srgb_to_linear(vec3(0.2, 0.5, 1.0));
#endif
// /*const */vec3 water_color = srgb_to_linear(vec3(0.0, 0.25, 0.5));
/* vec3 sun_dir = get_sun_dir(time_of_day.x);
@ -124,11 +118,7 @@ void main() {
// Water is transparent so both normals are valid.
vec3 cam_norm = faceforward(f_norm, f_norm, cam_to_frag);
#ifdef LAVA
vec3 mu = MU_LAVA;
#else
vec3 mu = MU_WATER;
#endif
// NOTE: Default intersection point is camera position, meaning if we fail to intersect we assume the whole camera is in water.
vec3 cam_attenuation = vec3(1.0);//compute_attenuation_point(f_pos, -view_dir, mu, fluid_alt, cam_pos.xyz);
@ -187,14 +177,7 @@ void main() {
// float reflected_light_point = /*length*/(diffuse_light_point.r) + f_light * point_shadow;
// reflected_light += k_d * (diffuse_light_point + f_light * point_shadow * shade_frac) + specular_light_point;
#ifdef LAVA
float opacity = 0.9;
emitted_light = vec3(0.1, 0, 0);
#else
float opacity = 0.2;
#endif
float passthrough = clamp(dot(cam_norm, -cam_to_frag) * 1.0 - opacity, 0, 1);
float passthrough = clamp(dot(cam_norm, -cam_to_frag) * 1.0 - 0.2, 0, 1);
float min_refl = min(emitted_light.r, min(emitted_light.g, emitted_light.b));
vec3 surf_color = illuminate(max_light, view_dir, water_color * /* fog_color * */emitted_light, /*surf_color * */water_color * reflected_light);

View File

@ -88,8 +88,6 @@ float wave_height(vec3 pos) {
return pow(abs(height), 0.5) * sign(height) * 15.0;
}
//#define LAVA
void main() {
// First 3 normals are negative, next 3 are positive
vec3 normals[6] = vec3[](vec3(-1,0,0), vec3(1,0,0), vec3(0,-1,0), vec3(0,1,0), vec3(0,0,-1), vec3(0,0,1));
@ -150,12 +148,7 @@ void main() {
vec3 norm = vec3(0, 0, 1) * nmap.z + b_norm * nmap.x + c_norm * nmap.y;
// vec3 norm = f_norm;
#ifdef LAVA
vec3 water_color = (1.0 - MU_LAVA);
#else
vec3 water_color = (1.0 - MU_WATER) * MU_SCATTER;
#endif
#if (SHADOW_MODE == SHADOW_MODE_CHEAP || SHADOW_MODE == SHADOW_MODE_MAP || FLUID_MODE == FLUID_MODE_SHINY)
float f_alt = alt_at(f_pos.xy);
#elif (SHADOW_MODE == SHADOW_MODE_NONE || FLUID_MODE == FLUID_MODE_CHEAP)
@ -237,12 +230,7 @@ void main() {
// vec3 water_color_direct = exp(-MU_WATER);//exp(-MU_WATER);//vec3(1.0);
// vec3 water_color_direct = exp(-water_attenuation * (water_depth_to_light + water_depth_to_camera));
// vec3 water_color_ambient = exp(-water_attenuation * (water_depth_to_vertical + water_depth_to_camera));
#ifdef LAVA
vec3 mu = MU_LAVA;
#else
vec3 mu = MU_WATER;
#endif
// NOTE: Default intersection point is camera position, meaning if we fail to intersect we assume the whole camera is in water.
vec3 cam_attenuation = compute_attenuation_point(f_pos, -view_dir, mu, fluid_alt, cam_pos.xyz);
// float water_depth_to_vertical = max(/*f_alt - f_pos.z*/f_light, 0.0);
@ -302,13 +290,7 @@ void main() {
// reflected_light += point_light;
// vec3 surf_color = srgb_to_linear(vec3(0.2, 0.5, 1.0)) * light * diffuse_light * ambient_light;
const float REFLECTANCE = 0.5;
#ifdef LAVA
//vec3 surf_color = illuminate(max_light, view_dir, water_color * emitted_light, reflect_color * REFLECTANCE + water_color * reflected_light);
vec3 surf_color = vec3(1, 0.25, 0);
#else
vec3 surf_color = illuminate(max_light, view_dir, water_color * emitted_light/* * log(1.0 - MU_WATER)*/, /*cam_attenuation * *//*water_color * */reflect_color * REFLECTANCE + water_color * reflected_light/* * log(1.0 - MU_WATER)*/);
#endif
//vec3 surf_color = illuminate(max_light, view_dir, water_color * emitted_light/* * log(1.0 - MU_WATER)*/, /*cam_attenuation * *//*water_color * */reflect_color * REFLECTANCE + water_color * reflected_light/* * log(1.0 - MU_WATER)*/);
// passthrough = pow(passthrough, 1.0 / (1.0 + water_depth_to_camera));
/* surf_color = cam_attenuation.g < 0.5 ?

View File

@ -2,9 +2,7 @@
#define SRGB_GLSL
// Linear RGB, attenuation coefficients for water at roughly R, G, B wavelengths.
// See https://en.wikipedia.org/wiki/Electromagnetic_absorption_by_water
const vec3 MU_WATER = vec3(0.6, 0.04, 0.01);
const vec3 MU_LAVA = vec3(0.1, 0.75, 1.0);
// // NOTE: Automatic in v4.0
// float

View File

@ -2,7 +2,7 @@
use super::body::{object, Body};
use super::{Density, Ori, Vel};
use crate::{
consts::{AIR_DENSITY, WATER_DENSITY},
consts::{AIR_DENSITY, LAVA_DENSITY, WATER_DENSITY},
util::{Dir, Plane, Projection},
};
use serde::{Deserialize, Serialize};
@ -55,7 +55,7 @@ impl Fluid {
Self::Liquid {
kind: LiquidKind::Lava,
..
} => Density(WATER_DENSITY),
} => Density(LAVA_DENSITY),
}
}

View File

@ -13,6 +13,9 @@ pub const FRIC_GROUND: f32 = 0.15;
// kg/m³
pub const AIR_DENSITY: f32 = 1.225;
pub const WATER_DENSITY: f32 = 999.1026;
// LAVA_DENSITY is unsourced, estimated as "roughly three times higher" than
// water
pub const LAVA_DENSITY: f32 = 3000.0;
pub const IRON_DENSITY: f32 = 7870.0;
// pub const HUMAN_DENSITY: f32 = 1010.0; // real value
pub const HUMAN_DENSITY: f32 = 990.0; // value we use to make humanoids gently float

View File

@ -65,12 +65,15 @@ impl<'a> System<'a> for Sys {
})
) && !buff_comp.contains(BuffKind::Burning)
{
buff_comp.insert(Buff::new(
BuffKind::Burning,
BuffData::new(200.0, None),
vec![BuffCategory::Natural],
BuffSource::World,
));
server_emitter.emit(ServerEvent::Buff {
entity,
buff_change: BuffChange::Add(Buff::new(
BuffKind::Burning,
BuffData::new(200.0, None),
vec![BuffCategory::Natural],
BuffSource::World,
)),
});
}
let (buff_comp_kinds, buff_comp_buffs): (