mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Random terrain sprite orientations
This commit is contained in:
parent
75e1ee3cd7
commit
0fcb3a174d
@ -36,7 +36,7 @@ void main() {
|
|||||||
0.0
|
0.0
|
||||||
) * sin(v_pos.z * 0.03) * 0.5;
|
) * sin(v_pos.z * 0.03) * 0.5;
|
||||||
|
|
||||||
f_norm = v_norm;
|
f_norm = (inst_mat * vec4(v_norm, 0)).xyz;
|
||||||
|
|
||||||
f_col = v_col * inst_col;
|
f_col = v_col * inst_col;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use crossbeam::channel;
|
|||||||
use dot_vox::DotVoxData;
|
use dot_vox::DotVoxData;
|
||||||
use frustum_query::frustum::Frustum;
|
use frustum_query::frustum::Frustum;
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use std::{i32, ops::Mul, time::Duration};
|
use std::{f32, i32, ops::Mul, time::Duration};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
struct TerrainChunk {
|
struct TerrainChunk {
|
||||||
@ -88,15 +88,22 @@ fn mesh_worker(
|
|||||||
let kind = volume.get(wpos).unwrap_or(&Block::empty()).kind();
|
let kind = volume.get(wpos).unwrap_or(&Block::empty()).kind();
|
||||||
|
|
||||||
if let Some(cfg) = sprite_config_for(kind) {
|
if let Some(cfg) = sprite_config_for(kind) {
|
||||||
instances.entry(kind).or_insert_with(|| Vec::new()).push(
|
let seed = x * 3 + y * 7 + z * 13 + x * y;
|
||||||
SpriteInstance::new(
|
|
||||||
Mat4::identity().translated_3d(
|
let instance = SpriteInstance::new(
|
||||||
|
Mat4::identity()
|
||||||
|
.rotated_z(f32::consts::PI * 0.5 * (seed % 4) as f32)
|
||||||
|
.translated_3d(
|
||||||
wpos.map(|e| e as f32) + Vec3::new(0.5, 0.5, 0.0),
|
wpos.map(|e| e as f32) + Vec3::new(0.5, 0.5, 0.0),
|
||||||
),
|
),
|
||||||
Rgb::broadcast(1.0),
|
Rgb::broadcast(1.0),
|
||||||
cfg.wind_sway,
|
cfg.wind_sway,
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
instances
|
||||||
|
.entry(kind)
|
||||||
|
.or_insert_with(|| Vec::new())
|
||||||
|
.push(instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user