mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added light/glow map sample interpolation for entities
This commit is contained in:
parent
27e7fd0727
commit
d7bbceca2d
@ -181,7 +181,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;
|
||||
|
||||
float glow = model_light.y;
|
||||
float glow = pow(model_light.y, 2);
|
||||
emitted_light += glow;
|
||||
|
||||
reflected_light *= ao;
|
||||
|
@ -174,7 +174,7 @@ void main() {
|
||||
reflected_light += point_light; */
|
||||
|
||||
// float ao = /*pow(f_ao, 0.5)*/f_ao * 0.85 + 0.15;
|
||||
float glow = f_inst_light.y;
|
||||
float glow = pow(f_inst_light.y, 2);
|
||||
emitted_light += glow;
|
||||
|
||||
float ao = f_ao;
|
||||
|
@ -3449,8 +3449,31 @@ impl<S: Skeleton> FigureState<S> {
|
||||
let (light, glow) = terrain
|
||||
.map(|t| {
|
||||
// Sample the location a little above to avoid clipping into terrain
|
||||
let wpos = (Vec3::from(pos.into_array()) + Vec3::unit_z() * 0.5).map(|e: f32| e.floor() as i32);
|
||||
(t.light_at_wpos(wpos), t.glow_at_wpos(wpos))
|
||||
// TODO: Try to make this faster? It might be fine though
|
||||
let wpos = Vec3::from(pos.into_array()) + Vec3::unit_z();
|
||||
|
||||
let wposi = wpos.map(|e: f32| e.floor() as i32);
|
||||
let sample = |off| {
|
||||
Vec2::new(t.light_at_wpos(wposi + off), t.glow_at_wpos(wposi + off))
|
||||
};
|
||||
|
||||
let s_000 = sample(Vec3::new(0, 0, 0));
|
||||
let s_100 = sample(Vec3::new(1, 0, 0));
|
||||
let s_010 = sample(Vec3::new(0, 1, 0));
|
||||
let s_110 = sample(Vec3::new(1, 1, 0));
|
||||
let s_001 = sample(Vec3::new(0, 0, 1));
|
||||
let s_101 = sample(Vec3::new(1, 0, 1));
|
||||
let s_011 = sample(Vec3::new(0, 1, 1));
|
||||
let s_111 = sample(Vec3::new(1, 1, 1));
|
||||
let s_00 = Lerp::lerp(s_000, s_001, wpos.z.fract());
|
||||
let s_10 = Lerp::lerp(s_100, s_101, wpos.z.fract());
|
||||
let s_01 = Lerp::lerp(s_010, s_011, wpos.z.fract());
|
||||
let s_11 = Lerp::lerp(s_110, s_111, wpos.z.fract());
|
||||
let s_0 = Lerp::lerp(s_00, s_01, wpos.y.fract());
|
||||
let s_1 = Lerp::lerp(s_10, s_11, wpos.y.fract());
|
||||
let s = Lerp::lerp(s_10, s_11, wpos.y.fract());
|
||||
|
||||
s.into_tuple()
|
||||
})
|
||||
.unwrap_or((1.0, 0.0));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user