mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Update wgpu, cleanup a bit of commented shader code, improve sprite LOD selection code
This commit is contained in:
parent
8db11cce37
commit
2b8eaae572
42
Cargo.lock
generated
42
Cargo.lock
generated
@ -1879,7 +1879,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-auxil"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx.git?rev=e305dcca3557923a6a8810162d8dd09cb45a43a6#e305dcca3557923a6a8810162d8dd09cb45a43a6"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=27a1dae3796d33d23812f2bb8c7e3b5aea18b521#27a1dae3796d33d23812f2bb8c7e3b5aea18b521"
|
||||
dependencies = [
|
||||
"fxhash",
|
||||
"gfx-hal",
|
||||
@ -1889,7 +1889,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-backend-dx11"
|
||||
version = "0.8.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx.git?rev=e305dcca3557923a6a8810162d8dd09cb45a43a6#e305dcca3557923a6a8810162d8dd09cb45a43a6"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=27a1dae3796d33d23812f2bb8c7e3b5aea18b521#27a1dae3796d33d23812f2bb8c7e3b5aea18b521"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bitflags",
|
||||
@ -1910,7 +1910,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-backend-dx12"
|
||||
version = "0.8.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx.git?rev=e305dcca3557923a6a8810162d8dd09cb45a43a6#e305dcca3557923a6a8810162d8dd09cb45a43a6"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=27a1dae3796d33d23812f2bb8c7e3b5aea18b521#27a1dae3796d33d23812f2bb8c7e3b5aea18b521"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bit-set",
|
||||
@ -1931,7 +1931,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-backend-empty"
|
||||
version = "0.8.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx.git?rev=e305dcca3557923a6a8810162d8dd09cb45a43a6#e305dcca3557923a6a8810162d8dd09cb45a43a6"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=27a1dae3796d33d23812f2bb8c7e3b5aea18b521#27a1dae3796d33d23812f2bb8c7e3b5aea18b521"
|
||||
dependencies = [
|
||||
"gfx-hal",
|
||||
"log",
|
||||
@ -1941,7 +1941,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-backend-gl"
|
||||
version = "0.8.1"
|
||||
source = "git+https://github.com/gfx-rs/gfx.git?rev=e305dcca3557923a6a8810162d8dd09cb45a43a6#e305dcca3557923a6a8810162d8dd09cb45a43a6"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=27a1dae3796d33d23812f2bb8c7e3b5aea18b521#27a1dae3796d33d23812f2bb8c7e3b5aea18b521"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bitflags",
|
||||
@ -1962,7 +1962,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-backend-metal"
|
||||
version = "0.8.1"
|
||||
source = "git+https://github.com/gfx-rs/gfx.git?rev=e305dcca3557923a6a8810162d8dd09cb45a43a6#e305dcca3557923a6a8810162d8dd09cb45a43a6"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=27a1dae3796d33d23812f2bb8c7e3b5aea18b521#27a1dae3796d33d23812f2bb8c7e3b5aea18b521"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bitflags",
|
||||
@ -1986,7 +1986,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-backend-vulkan"
|
||||
version = "0.8.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx.git?rev=e305dcca3557923a6a8810162d8dd09cb45a43a6#e305dcca3557923a6a8810162d8dd09cb45a43a6"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=27a1dae3796d33d23812f2bb8c7e3b5aea18b521#27a1dae3796d33d23812f2bb8c7e3b5aea18b521"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"ash",
|
||||
@ -2008,7 +2008,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "gfx-hal"
|
||||
version = "0.8.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx.git?rev=e305dcca3557923a6a8810162d8dd09cb45a43a6#e305dcca3557923a6a8810162d8dd09cb45a43a6"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=27a1dae3796d33d23812f2bb8c7e3b5aea18b521#27a1dae3796d33d23812f2bb8c7e3b5aea18b521"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"naga",
|
||||
@ -3056,7 +3056,7 @@ checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238"
|
||||
[[package]]
|
||||
name = "naga"
|
||||
version = "0.4.0"
|
||||
source = "git+https://github.com/gfx-rs/naga.git?rev=3a0f0144112ff621dd7f731bf455adf6cab19164#3a0f0144112ff621dd7f731bf455adf6cab19164"
|
||||
source = "git+https://github.com/gfx-rs/naga?tag=gfx-25#057d03ad86f18e3bb3866b20901d8d4e892dd3d6"
|
||||
dependencies = [
|
||||
"bit-set",
|
||||
"bitflags",
|
||||
@ -3065,6 +3065,7 @@ dependencies = [
|
||||
"log",
|
||||
"num-traits",
|
||||
"petgraph 0.5.1",
|
||||
"rose_tree",
|
||||
"spirv_headers",
|
||||
"thiserror",
|
||||
]
|
||||
@ -4163,7 +4164,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "range-alloc"
|
||||
version = "0.1.2"
|
||||
source = "git+https://github.com/gfx-rs/gfx.git?rev=e305dcca3557923a6a8810162d8dd09cb45a43a6#e305dcca3557923a6a8810162d8dd09cb45a43a6"
|
||||
source = "git+https://github.com/gfx-rs/gfx?rev=27a1dae3796d33d23812f2bb8c7e3b5aea18b521#27a1dae3796d33d23812f2bb8c7e3b5aea18b521"
|
||||
|
||||
[[package]]
|
||||
name = "raw-window-handle"
|
||||
@ -4384,6 +4385,15 @@ version = "0.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84348444bd7ad45729d0c49a4240d7cdc11c9d512c06c5ad1835c1ad4acda6db"
|
||||
|
||||
[[package]]
|
||||
name = "rose_tree"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "284de9dae38774e2813aaabd7e947b4a6fe9b8c58c2309f754a487cdd50de1c2"
|
||||
dependencies = [
|
||||
"petgraph 0.5.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rusqlite"
|
||||
version = "0.24.2"
|
||||
@ -6634,8 +6644,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wgpu"
|
||||
version = "0.8.1"
|
||||
source = "git+https://github.com/gfx-rs/wgpu-rs.git?rev=2b0149e5bd36fc70c1687afd4b196fd902c85e77#2b0149e5bd36fc70c1687afd4b196fd902c85e77"
|
||||
version = "0.8.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu-rs.git?rev=7486bdad64bb5d17b709ecccb41e063469efff88#7486bdad64bb5d17b709ecccb41e063469efff88"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"js-sys",
|
||||
@ -6654,9 +6664,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wgpu-core"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d56c368fc0e6f3927c711d2b55a51ad4321218efc0239c4acf69e456ab70399"
|
||||
version = "0.8.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=53eab747a32414232be45d47cae8a43a369395d0#53eab747a32414232be45d47cae8a43a369395d0"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bitflags",
|
||||
@ -6696,8 +6705,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "wgpu-types"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa248d90c8e6832269b8955bf800e8241f942c25e18a235b7752226804d21556"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=53eab747a32414232be45d47cae8a43a369395d0#53eab747a32414232be45d47cae8a43a369395d0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"serde",
|
||||
|
23
Cargo.toml
23
Cargo.toml
@ -114,19 +114,18 @@ nativeBuildInputs = ["pkg-config"]
|
||||
winit = { git = "https://gitlab.com/veloren/winit.git", branch = "macos-test-spiffed" }
|
||||
vek = { git = "https://gitlab.com/veloren/vek.git", branch = "fix_intrinsics2" }
|
||||
# patch wgpu so we can use wgpu-profiler crate
|
||||
# also points to 0.8 branch so we can use/and patch 0.8 naga/gfx (since a new tag isn't out yet)
|
||||
wgpu = { git = "https://github.com/gfx-rs/wgpu-rs.git", rev = "2b0149e5bd36fc70c1687afd4b196fd902c85e77" }
|
||||
wgpu = { git = "https://github.com/gfx-rs/wgpu-rs.git", rev = "7486bdad64bb5d17b709ecccb41e063469efff88" }
|
||||
|
||||
# use the latest fixes in naga (remove when updates trickle down to wgpu-rs)
|
||||
naga = { git = "https://github.com/gfx-rs/naga.git", rev = "3a0f0144112ff621dd7f731bf455adf6cab19164" }
|
||||
# use the latest fixes in gfx (remove when updates trickle down to wgpu-rs)
|
||||
gfx-hal = { git = "https://github.com/gfx-rs/gfx.git", rev = "e305dcca3557923a6a8810162d8dd09cb45a43a6" }
|
||||
gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx.git", rev = "e305dcca3557923a6a8810162d8dd09cb45a43a6" }
|
||||
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx.git", rev = "e305dcca3557923a6a8810162d8dd09cb45a43a6" }
|
||||
gfx-backend-gl = { git = "https://github.com/gfx-rs/gfx.git", rev = "e305dcca3557923a6a8810162d8dd09cb45a43a6" }
|
||||
gfx-backend-dx12 = { git = "https://github.com/gfx-rs/gfx.git", rev = "e305dcca3557923a6a8810162d8dd09cb45a43a6" }
|
||||
gfx-backend-dx11 = { git = "https://github.com/gfx-rs/gfx.git", rev = "e305dcca3557923a6a8810162d8dd09cb45a43a6" }
|
||||
gfx-backend-metal = { git = "https://github.com/gfx-rs/gfx.git", rev = "e305dcca3557923a6a8810162d8dd09cb45a43a6" }
|
||||
# # use the latest fixes in naga (remove when updates trickle down to wgpu-rs)
|
||||
# naga = { git = "https://github.com/gfx-rs/naga.git", rev = "3a0f0144112ff621dd7f731bf455adf6cab19164" }
|
||||
# # use the latest fixes in gfx (remove when updates trickle down to wgpu-rs)
|
||||
# gfx-hal = { git = "https://github.com/gfx-rs/gfx.git", rev = "e305dcca3557923a6a8810162d8dd09cb45a43a6" }
|
||||
# gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx.git", rev = "e305dcca3557923a6a8810162d8dd09cb45a43a6" }
|
||||
# gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx.git", rev = "e305dcca3557923a6a8810162d8dd09cb45a43a6" }
|
||||
# gfx-backend-gl = { git = "https://github.com/gfx-rs/gfx.git", rev = "e305dcca3557923a6a8810162d8dd09cb45a43a6" }
|
||||
# gfx-backend-dx12 = { git = "https://github.com/gfx-rs/gfx.git", rev = "e305dcca3557923a6a8810162d8dd09cb45a43a6" }
|
||||
# gfx-backend-dx11 = { git = "https://github.com/gfx-rs/gfx.git", rev = "e305dcca3557923a6a8810162d8dd09cb45a43a6" }
|
||||
# gfx-backend-metal = { git = "https://github.com/gfx-rs/gfx.git", rev = "e305dcca3557923a6a8810162d8dd09cb45a43a6" }
|
||||
|
||||
# # Uncomment this to use a local fork of wgpu (for testing purposes)
|
||||
# [patch.'https://github.com/gfx-rs/wgpu']
|
||||
|
@ -205,41 +205,6 @@ float ShadowCalculationDirected(in vec3 fragPos)//in vec4 /*light_pos[2]*/sun_po
|
||||
// orig_pos.y = n: warp_pos.y = 2*(1-f/n)*n/(f-n) + 1 = 2*(n-f)/(f-n) + 1 = 2 * -1 + 1 = -1, sun_pos.y = (-1 - -1) / 2 = 0
|
||||
// orig_pos.y = f: warp_pos.y = 2*(1-f/f)*n/(f-n) + 1 = 2*(1-1)*n/(f-n) + 1 = 2 * 0 * n/(f-n) + 1 = 1, sun_pos.y = (1 - -1) / 2 = 1
|
||||
//
|
||||
// 2*(1-64/(1/((0-1)*63/2-1/64)))*1/63+1
|
||||
//
|
||||
// 2*(1-f/x)*n/(f-n) + 1 = 0
|
||||
// 2*(1-f/x)*n/(f-n) = -1
|
||||
//
|
||||
// (1-f/x) = -(f-n)/(2*n)
|
||||
// 1 + (f-n)/(2*n) = f/x
|
||||
// x = f/(1 + 0.5 * (f-n)/n)
|
||||
// = 2*f/(1 + f/n)
|
||||
// = 2*f*n/(f + n)
|
||||
// = 2/(1/n + 1/f)
|
||||
//
|
||||
// 2/(1/(64/1) + 1/64) = 64 (but has n = f = 64)
|
||||
// 2/(1/(64/3) + 1/64) = 32
|
||||
// 2/(1/(64/7) + 1/64) = 16
|
||||
// 2/(1/(64/15) + 1/64) = 8
|
||||
// 2/(1/(64/31) + 1/64) = 4
|
||||
// 2/(1/(64/63) + 1/64) = 2
|
||||
// 2/(1/(64/127) + 1/64) = 1 (but has f < n)
|
||||
//
|
||||
// 2*(1-64/(64/127))*64/127/(64-64/127)+1
|
||||
//
|
||||
// (with normed n)
|
||||
// = 2/(1/n + 1/(1+n))
|
||||
// = 2*n*(1+n)/(1+2n)
|
||||
// = 1/((1 +2n)/(2n(1+n)))
|
||||
// = 1/(1/(2n(1+n)) + 1/(1+n))
|
||||
// = (1 + n)/(1 + 0.5/n)
|
||||
// 2*64*1/(64+1)
|
||||
//
|
||||
// 2*(1-64/(64/(1 + 0.5 * 63/1)))*1/63+1
|
||||
//
|
||||
// sun_pos.xy = sun_pos.w - sun_pos.xy;
|
||||
// sun_pos.xy = sun_pos.xy * 0.5 + 0.5;
|
||||
// sun_pos.z -= sun_pos.w * bias;
|
||||
float visibility = textureProj(sampler2DShadow(t_directed_shadow_maps, s_directed_shadow_maps), sun_pos);
|
||||
/* float visibilityLeft = textureProj(t_directed_shadow_maps, sun_shadow.texture_mat * vec4(fragPos + vec3(0.0, -diskRadius, 0.0), 1.0));
|
||||
float visibilityRight = textureProj(t_directed_shadow_maps, sun_shadow.texture_mat * vec4(fragPos + vec3(0.0, diskRadius, 0.0), 1.0)); */
|
||||
|
@ -45,7 +45,7 @@ i18n = {package = "veloren-i18n", path = "i18n"}
|
||||
|
||||
# Graphics
|
||||
winit = {version = "0.24.0", features = ["serde"]}
|
||||
wgpu = { version = "0.8.1", features = ["trace"] }
|
||||
wgpu = { version = "=0.8.0", features = ["trace"] }
|
||||
wgpu-profiler = { git = "https://github.com/Imberflur/wgpu-profiler", tag = "wgpu-0.8" }
|
||||
bytemuck = { version="1.4", features=["derive"] }
|
||||
shaderc = "0.6.2"
|
||||
|
@ -294,7 +294,8 @@ fn create_shader_module(
|
||||
Ok(device.create_shader_module(&wgpu::ShaderModuleDescriptor {
|
||||
label: Some(&label),
|
||||
source: wgpu::ShaderSource::SpirV(Cow::Borrowed(spv.as_binary())),
|
||||
flags: wgpu::ShaderFlags::empty(), // TODO: renable wgpu::ShaderFlags::VALIDATION,
|
||||
flags: wgpu::ShaderFlags::empty(),
|
||||
// TODO: renable // flags: wgpu::ShaderFlags::VALIDATION,
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -1480,7 +1480,6 @@ impl<V: RectRasterableVol> Terrain<V> {
|
||||
// TODO: move to separate functions
|
||||
span!(guard, "Terrain sprites");
|
||||
let chunk_size = V::RECT_SIZE.map(|e| e as f32);
|
||||
let chunk_mag = (chunk_size * (f32::consts::SQRT_2 * 0.5)).magnitude_squared();
|
||||
|
||||
let sprite_low_detail_distance = sprite_render_distance * 0.75;
|
||||
let sprite_mid_detail_distance = sprite_render_distance * 0.5;
|
||||
@ -1499,31 +1498,15 @@ impl<V: RectRasterableVol> Terrain<V> {
|
||||
|
||||
let chunk_center = pos.map2(chunk_size, |e, sz| (e as f32 + 0.5) * sz);
|
||||
let focus_dist_sqrd = Vec2::from(focus_pos).distance_squared(chunk_center);
|
||||
let dist_sqrd =
|
||||
Vec2::from(cam_pos)
|
||||
.distance_squared(chunk_center)
|
||||
.min(Vec2::from(cam_pos).distance_squared(chunk_center - chunk_size * 0.5))
|
||||
.min(Vec2::from(cam_pos).distance_squared(
|
||||
chunk_center - chunk_size.x * 0.5 + chunk_size.y * 0.5,
|
||||
))
|
||||
.min(
|
||||
Vec2::from(cam_pos).distance_squared(chunk_center + chunk_size.x * 0.5),
|
||||
)
|
||||
.min(Vec2::from(cam_pos).distance_squared(
|
||||
chunk_center + chunk_size.x * 0.5 - chunk_size.y * 0.5,
|
||||
));
|
||||
let dist_sqrd = Aabr {
|
||||
min: chunk_center - chunk_size * 0.5,
|
||||
max: chunk_center + chunk_size * 0.5,
|
||||
}
|
||||
.projected_point(cam_pos.xy())
|
||||
.distance_squared(cam_pos.xy());
|
||||
|
||||
if focus_dist_sqrd < sprite_render_distance.powi(2) {
|
||||
// TODO: do we really need this configurement by wind-sway, if not remove
|
||||
// commented code, if so store the max wind sway of sprites in each chunk
|
||||
let lod_level = /*let SpriteData { model, locals, .. } = if kind
|
||||
.0
|
||||
.elim_case_pure(&self.sprite_config.0)
|
||||
.as_ref()
|
||||
.map(|config| config.wind_sway >= 0.4)
|
||||
.unwrap_or(false)
|
||||
&&*/ if dist_sqrd <= chunk_mag
|
||||
|| dist_sqrd < sprite_high_detail_distance.powi(2)
|
||||
{
|
||||
let lod_level = if dist_sqrd < sprite_high_detail_distance.powi(2) {
|
||||
0
|
||||
} else if dist_sqrd < sprite_hid_detail_distance.powi(2) {
|
||||
1
|
||||
|
Loading…
Reference in New Issue
Block a user