mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Centralised particle offset, variable chunk range, better smoke offsets
This commit is contained in:
parent
0a3f0db26d
commit
c759c8120f
@ -104,7 +104,7 @@ void main() {
|
||||
attr = Attr(
|
||||
linear_motion(
|
||||
vec3(0.0, 0.0, 0.0),
|
||||
vec3(rand2 * 0.1, rand3 * 0.1, 1.0 + rand4 * 0.1)// + vec3(sin(lifetime), sin(lifetime + 1.5), sin(lifetime * 4) * 0.25)
|
||||
vec3(rand2 * 0.02, rand3 * 0.02, 1.0 + rand4 * 0.1)// + vec3(sin(lifetime), sin(lifetime + 1.5), sin(lifetime * 4) * 0.25)
|
||||
),
|
||||
linear_scale(0.5),
|
||||
vec4(1, 1, 1, 0.3),
|
||||
@ -212,7 +212,7 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
f_pos = (inst_pos - focus_off.xyz) + (v_pos * attr.scale * SCALE * attr.rot + attr.offs);
|
||||
f_pos = (inst_pos - 0.5 - focus_off.xyz) + (v_pos * attr.scale * SCALE * attr.rot + attr.offs);
|
||||
|
||||
// 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));
|
||||
|
@ -1019,12 +1019,12 @@ impl Scene {
|
||||
);
|
||||
self.lod.render(renderer, global);
|
||||
|
||||
// Render particle effects.
|
||||
self.particle_mgr.render(renderer, scene_data, global, lod);
|
||||
|
||||
// Render the skybox.
|
||||
renderer.render_skybox(&self.skybox.model, global, &self.skybox.locals, lod);
|
||||
|
||||
// Render particle effects.
|
||||
self.particle_mgr.render(renderer, scene_data, global, lod);
|
||||
|
||||
self.terrain.render_translucent(
|
||||
renderer,
|
||||
global,
|
||||
|
@ -157,7 +157,7 @@ impl ParticleMgr {
|
||||
Duration::from_secs(10),
|
||||
time,
|
||||
ParticleMode::CampfireSmoke,
|
||||
pos.0,
|
||||
pos.0.map(|e| e + thread_rng().gen_range(-0.5, 0.5)),
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -272,18 +272,18 @@ impl ParticleMgr {
|
||||
});
|
||||
|
||||
type BoiFn<'a> = fn(&'a BlocksOfInterest) -> &'a [Vec3<i32>];
|
||||
let particles: &[(BoiFn, _, _, _)] = &[
|
||||
(|boi| &boi.leaves, 0.002, 30.0, ParticleMode::Leaf),
|
||||
(|boi| &boi.embers, 20.0, 0.25, ParticleMode::CampfireFire),
|
||||
(|boi| &boi.embers, 6.0, 30.0, ParticleMode::CampfireSmoke),
|
||||
// blocks, chunk range, emission density, lifetime, particle mode
|
||||
let particles: &[(BoiFn, usize, f32, f32, ParticleMode)] = &[
|
||||
(|boi| &boi.leaves, 4, 0.001, 30.0, ParticleMode::Leaf),
|
||||
(|boi| &boi.embers, 2, 20.0, 0.25, ParticleMode::CampfireFire),
|
||||
(|boi| &boi.embers, 8, 6.0, 30.0, ParticleMode::CampfireSmoke),
|
||||
];
|
||||
|
||||
const RANGE: usize = 4;
|
||||
for offset in Spiral2d::new().take((RANGE * 2 + 1).pow(2)) {
|
||||
let chunk_pos = player_chunk + offset;
|
||||
for (get_blocks, range, rate, dur, mode) in particles.iter() {
|
||||
for offset in Spiral2d::new().take((*range * 2 + 1).pow(2)) {
|
||||
let chunk_pos = player_chunk + offset;
|
||||
|
||||
terrain.get(chunk_pos).map(|chunk_data| {
|
||||
for (get_blocks, rate, dur, mode) in particles.iter() {
|
||||
terrain.get(chunk_pos).map(|chunk_data| {
|
||||
let blocks = get_blocks(&chunk_data.blocks_of_interest);
|
||||
|
||||
let avg_particles = dt * blocks.len() as f32 * *rate;
|
||||
@ -302,8 +302,8 @@ impl ParticleMgr {
|
||||
block_pos.map(|e: i32| e as f32 + thread_rng().gen::<f32>()),
|
||||
));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user