mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'zesterer/lighting-fixes' into 'master'
Numerous minor lighting fixes See merge request veloren/veloren!376
This commit is contained in:
commit
afc4d06a51
@ -643,10 +643,10 @@ fn handle_lantern(server: &mut Server, entity: EcsEntity, args: String, action:
|
||||
.write_storage::<comp::LightEmitter>()
|
||||
.get_mut(entity)
|
||||
{
|
||||
light.strength = s.max(0.1);
|
||||
light.strength = s.max(0.1).min(20.0);
|
||||
server.clients.notify(
|
||||
entity,
|
||||
ServerMsg::chat(String::from("You played with flame strength.")),
|
||||
ServerMsg::chat(String::from("You played with the lantern intensity.")),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@ -657,7 +657,7 @@ fn handle_lantern(server: &mut Server, entity: EcsEntity, args: String, action:
|
||||
.remove(entity);
|
||||
server.clients.notify(
|
||||
entity,
|
||||
ServerMsg::chat(String::from("You put out the lantern.")),
|
||||
ServerMsg::chat(String::from("You snuff out your lantern.")),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@ -668,15 +668,15 @@ fn handle_lantern(server: &mut Server, entity: EcsEntity, args: String, action:
|
||||
.insert(
|
||||
entity,
|
||||
comp::LightEmitter {
|
||||
offset: Vec3::new(1.0, 0.2, 0.8),
|
||||
col: Rgb::new(0.824, 0.365, 0.196),
|
||||
strength: if let Some(s) = opt_s { s.max(0.0) } else { 2.0 },
|
||||
offset: Vec3::new(0.5, 0.2, 0.8),
|
||||
col: Rgb::new(1.0, 0.75, 0.3),
|
||||
strength: if let Some(s) = opt_s { s.max(0.0) } else { 6.0 },
|
||||
},
|
||||
);
|
||||
|
||||
server.clients.notify(
|
||||
entity,
|
||||
ServerMsg::chat(String::from("You lighted your lantern.")),
|
||||
ServerMsg::chat(String::from("You light your lantern.")),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ void main() {
|
||||
vec4(f_norm, 0.0)
|
||||
).xyz;
|
||||
|
||||
vec3 light = get_sun_diffuse(world_norm, time_of_day.x) + light_at(f_pos, f_norm);
|
||||
vec3 light = get_sun_diffuse(world_norm, time_of_day.x) + light_at(f_pos, world_norm);
|
||||
vec3 surf_color = model_col.rgb * f_col * 2.0 * light;
|
||||
|
||||
float fog_level = fog(f_pos.xy, focus_pos.xy);
|
||||
|
@ -13,21 +13,22 @@ float attenuation_strength(vec3 rpos) {
|
||||
}
|
||||
|
||||
vec3 light_at(vec3 wpos, vec3 wnorm) {
|
||||
const float LIGHT_AMBIENCE = 0.1;
|
||||
const float LIGHT_AMBIENCE = 0.025;
|
||||
|
||||
vec3 light = vec3(0);
|
||||
for (uint i = 0u; i < light_count.x; i ++) {
|
||||
vec3 light_pos = lights[i].light_pos.xyz;
|
||||
float strength = attenuation_strength(wpos - light_pos);
|
||||
|
||||
if (strength < 0.001) {
|
||||
vec3 color = strength
|
||||
* lights[i].light_col.rgb
|
||||
* lights[i].light_col.a;
|
||||
|
||||
if (max(max(color.r, color.g), color.b) < 0.002) {
|
||||
continue;
|
||||
}
|
||||
|
||||
light += strength
|
||||
* lights[i].light_col.rgb
|
||||
* lights[i].light_col.a
|
||||
* clamp(dot(normalize(light_pos - wpos), wnorm), LIGHT_AMBIENCE, 1.0);
|
||||
light += color * clamp(dot(normalize(light_pos - wpos), wnorm), LIGHT_AMBIENCE, 1.0);
|
||||
}
|
||||
return light;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ void main() {
|
||||
f_norm = vec3(0.0, 0.0, 1.0) * norm_dir;
|
||||
}
|
||||
|
||||
vec3 light = get_sun_diffuse(f_norm, time_of_day.x) * f_light + light_at(f_pos, f_norm);
|
||||
vec3 light = (get_sun_diffuse(f_norm, time_of_day.x) + light_at(f_pos, f_norm)) * f_light;
|
||||
vec3 surf_color = f_col * light;
|
||||
|
||||
float fog_level = fog(f_pos.xy, focus_pos.xy);
|
||||
|
Loading…
Reference in New Issue
Block a user