mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Move alpha values calculation
This commit is contained in:
parent
8a684973b4
commit
69c3480fce
@ -71,6 +71,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Made the hotbar link to items by item definition id and component composition instead of specific inventory slots.
|
||||
- Made loot boxes drop items instead of doing nothing in order to loot forcing
|
||||
- Refactored agent code file structure
|
||||
- Changed the way light strength is rendered by moving processing from shader code (GPU) to CPU code
|
||||
|
||||
### Removed
|
||||
|
||||
|
@ -84,8 +84,7 @@ vec3 light_at(vec3 wpos, vec3 wnorm) {
|
||||
|
||||
float strength = attenuation_strength(difference);
|
||||
|
||||
// Multiply the vec3 only once
|
||||
vec3 color = srgb_to_linear(L.light_col.rgb) * (strength * L.light_col.a);
|
||||
vec3 color = srgb_to_linear(L.light_col.rgb);
|
||||
|
||||
light += color * (max(0, max(dot(normalize(difference), wnorm), 0.15)) + LIGHT_AMBIANCE);
|
||||
}
|
||||
@ -194,12 +193,12 @@ float lights_at(vec3 wpos, vec3 wnorm, vec3 /*cam_to_frag*/view_dir, vec3 mu, ve
|
||||
is_direct = true;
|
||||
#endif
|
||||
vec3 lrf = light_reflection_factor(/*direct_norm_dir*/wnorm, /*cam_to_frag*/view_dir, direct_light_dir, k_d, k_s, alpha, voxel_norm, voxel_lighting);
|
||||
vec3 direct_light = PI * color * strength * square_factor * lrf;
|
||||
vec3 direct_light = PI * color * square_factor * lrf;
|
||||
/* 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 * square_factor : vec3(0.0);
|
||||
// Non-physically emulate ambient light nearby
|
||||
float ambiance = (dot(-wnorm, direct_light_dir) * 0.5 + 0.5) * strength * square_factor;
|
||||
float ambiance = (dot(-wnorm, direct_light_dir) * 0.5 + 0.5) * square_factor;
|
||||
#ifdef FIGURE_SHADER
|
||||
// Non-physical hack. Subtle, but allows lanterns to glow nicely
|
||||
// TODO: Make lanterns use glowing cells instead
|
||||
|
@ -30,7 +30,7 @@ vec3 apply_point_glow(vec3 wpos, vec3 dir, float max_dist, vec3 color) {
|
||||
|
||||
float strength = pow(attenuation_strength_real(difference), spread);
|
||||
|
||||
vec3 light_color = srgb_to_linear(L.light_col.rgb) * strength * L.light_col.a;
|
||||
vec3 light_color = srgb_to_linear(L.light_col.rgb) * L.light_col.a;
|
||||
|
||||
const float LIGHT_AMBIANCE = 0.025;
|
||||
color += light_color
|
||||
|
@ -204,7 +204,8 @@ impl Light {
|
||||
pub fn new(pos: Vec3<f32>, col: Rgb<f32>, strength: f32) -> Self {
|
||||
Self {
|
||||
pos: Vec4::from(pos).into_array(),
|
||||
col: Rgba::new(col.r, col.g, col.b, strength).into_array(),
|
||||
col: (Rgba::new(strength * col.r, strength * col.g, strength * col.b, 0.0) * strength)
|
||||
.into_array(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ impl Debug {
|
||||
if let Some(model) = renderer.create_model(&shape.mesh()) {
|
||||
let locals = renderer.create_debug_bound_locals(&[DebugLocals {
|
||||
pos: [0.0; 4],
|
||||
color: [1.0, 0.0, 0.0, 1.0],
|
||||
color: [1.0 * 1.0, 0.0, 0.0, 0.0],
|
||||
ori: [0.0, 0.0, 0.0, 1.0],
|
||||
}]);
|
||||
self.models.insert(id, (model, locals));
|
||||
@ -202,7 +202,7 @@ impl Debug {
|
||||
let lc = srgba_to_linear(color.into());
|
||||
let new_locals = [DebugLocals {
|
||||
pos,
|
||||
color: [lc.r, lc.g, lc.b, lc.a],
|
||||
color: [lc.a * lc.r, lc.a * lc.g, lc.a * lc.b, 0.0],
|
||||
ori,
|
||||
}];
|
||||
renderer.update_consts(locals, &new_locals);
|
||||
|
@ -1188,11 +1188,11 @@ impl Scene {
|
||||
});
|
||||
let hb_pos = [pos.0.x, pos.0.y, pos.0.z + *z_min, 0.0];
|
||||
let color = if group == Some(&comp::group::ENEMY) {
|
||||
[1.0, 0.0, 0.0, 0.5]
|
||||
[0.5 * 1.0, 0.0, 0.0, 0.0]
|
||||
} else if group == Some(&comp::group::NPC) {
|
||||
[0.0, 0.0, 1.0, 0.5]
|
||||
[0.0, 0.0, 1.0 * 0.5, 0.0]
|
||||
} else {
|
||||
[0.0, 1.0, 0.0, 0.5]
|
||||
[0.0, 1.0 * 0.5, 0.0, 0.0]
|
||||
};
|
||||
let ori = ori.to_quat();
|
||||
let hb_ori = [ori.x, ori.y, ori.z, ori.w];
|
||||
|
Loading…
Reference in New Issue
Block a user