mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Animated chunk loading
This commit is contained in:
parent
2165e79971
commit
46fdc87014
@ -11,6 +11,7 @@ in float f_light;
|
||||
layout (std140)
|
||||
uniform u_locals {
|
||||
vec3 model_offs;
|
||||
float load_time;
|
||||
};
|
||||
|
||||
out vec4 tgt_color;
|
||||
|
@ -8,6 +8,7 @@ in uint v_col_light;
|
||||
layout (std140)
|
||||
uniform u_locals {
|
||||
vec3 model_offs;
|
||||
float load_time;
|
||||
};
|
||||
|
||||
out vec3 f_pos;
|
||||
|
@ -10,6 +10,7 @@ in float f_light;
|
||||
layout (std140)
|
||||
uniform u_locals {
|
||||
vec3 model_offs;
|
||||
float load_time;
|
||||
};
|
||||
|
||||
out vec4 tgt_color;
|
||||
|
@ -9,6 +9,7 @@ in uint v_col_light;
|
||||
layout (std140)
|
||||
uniform u_locals {
|
||||
vec3 model_offs;
|
||||
float load_time;
|
||||
};
|
||||
|
||||
out vec3 f_pos;
|
||||
@ -26,6 +27,8 @@ void main() {
|
||||
float((v_pos_norm >> 16) & 0x1FFFu)
|
||||
) + model_offs;
|
||||
|
||||
f_pos.z *= min(1.0001 - 0.02 / pow(tick.x - load_time, 10.0), 1.0);
|
||||
|
||||
// TODO: last 3 bits in v_pos_norm should be a number between 0 and 5, rather than 0-2 and a direction.
|
||||
uint norm_axis = (v_pos_norm >> 30) & 0x3u;
|
||||
|
||||
|
@ -23,6 +23,7 @@ gfx_defines! {
|
||||
|
||||
constant Locals {
|
||||
model_offs: [f32; 3] = "model_offs",
|
||||
load_time: f32 = "load_time",
|
||||
}
|
||||
|
||||
pipeline pipe {
|
||||
@ -66,6 +67,7 @@ impl Locals {
|
||||
pub fn default() -> Self {
|
||||
Self {
|
||||
model_offs: [0.0; 3],
|
||||
load_time: 0.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ use vek::*;
|
||||
|
||||
struct TerrainChunk {
|
||||
// GPU data
|
||||
load_time: f32,
|
||||
opaque_model: Model<TerrainPipeline>,
|
||||
fluid_model: Model<FluidPipeline>,
|
||||
sprite_instances: HashMap<(BlockKind, usize), Instances<SpriteInstance>>,
|
||||
@ -613,6 +614,7 @@ impl<V: RectRasterableVol> Terrain<V> {
|
||||
proj_mat: Mat4<f32>,
|
||||
) {
|
||||
let current_tick = client.get_tick();
|
||||
let current_time = client.state().get_time();
|
||||
|
||||
// Add any recently created or changed chunks to the list of chunks to be meshed.
|
||||
for (modified, pos) in client
|
||||
@ -796,9 +798,15 @@ impl<V: RectRasterableVol> Terrain<V> {
|
||||
// It's the mesh we want, insert the newly finished model into the terrain model
|
||||
// data structure (convert the mesh to a model first of course).
|
||||
Some(todo) if response.started_tick <= todo.started_tick => {
|
||||
let load_time = self
|
||||
.chunks
|
||||
.get(&response.pos)
|
||||
.map(|chunk| chunk.load_time)
|
||||
.unwrap_or(current_time as f32);
|
||||
self.chunks.insert(
|
||||
response.pos,
|
||||
TerrainChunk {
|
||||
load_time,
|
||||
opaque_model: renderer
|
||||
.create_model(&response.opaque_mesh)
|
||||
.expect("Failed to upload chunk mesh to the GPU!"),
|
||||
@ -825,6 +833,7 @@ impl<V: RectRasterableVol> Terrain<V> {
|
||||
}),
|
||||
)
|
||||
.into_array(),
|
||||
load_time,
|
||||
}])
|
||||
.expect("Failed to upload chunk locals to the GPU!"),
|
||||
visible: false,
|
||||
|
Loading…
Reference in New Issue
Block a user