summaryrefslogtreecommitdiff
path: root/client/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-01-28 15:25:50 +0100
committermetamuffin <metamuffin@disroot.org>2025-01-28 15:25:50 +0100
commit58e3531cd2316e9c73b01221d68834592ad6a2ff (patch)
tree081b774c8d611d96d88b8589b92490dcc987f89a /client/src
parent3331150162e34471bf0294bdb61a1a748cb94ee5 (diff)
downloadweareserver-58e3531cd2316e9c73b01221d68834592ad6a2ff.tar
weareserver-58e3531cd2316e9c73b01221d68834592ad6a2ff.tar.bz2
weareserver-58e3531cd2316e9c73b01221d68834592ad6a2ff.tar.zst
Little endian, tangent space handedness,
Diffstat (limited to 'client/src')
-rw-r--r--client/src/render/shaders/fragment_pbr.wgsl7
-rw-r--r--client/src/render/shaders/vertex_world.wgsl10
-rw-r--r--client/src/render/shaders/vertex_world_skin.wgsl10
3 files changed, 16 insertions, 11 deletions
diff --git a/client/src/render/shaders/fragment_pbr.wgsl b/client/src/render/shaders/fragment_pbr.wgsl
index c8fb857..80d3802 100644
--- a/client/src/render/shaders/fragment_pbr.wgsl
+++ b/client/src/render/shaders/fragment_pbr.wgsl
@@ -17,8 +17,9 @@ struct VertexOut {
@builtin(position) clip: vec4<f32>,
@location(0) normal: vec3<f32>,
@location(1) tangent: vec3<f32>,
- @location(2) texcoord: vec2<f32>,
- @location(3) position: vec3<f32>,
+ @location(2) tangent_binormal_sign: f32,
+ @location(3) texcoord: vec2<f32>,
+ @location(4) position: vec3<f32>,
}
struct Material {
@@ -39,7 +40,7 @@ fn main(vo: VertexOut) -> @location(0) vec4<f32> {
let t_albedo = textureSample(tex_albedo, tex_albedo_sampler, vo.texcoord);
let t_normal = textureSample(tex_normal, tex_normal_sampler, vo.texcoord);
- let tangent_basis = mat3x3(vo.tangent, cross(vo.tangent, vo.normal), vo.normal);
+ let tangent_basis = mat3x3(vo.tangent, vo.tangent_binormal_sign * cross(vo.tangent, vo.normal), vo.normal);
let normal = tangent_basis * (t_normal.rgb * 2. - 1.);
let light = vec3(0.64, 0.64, 0.64);
diff --git a/client/src/render/shaders/vertex_world.wgsl b/client/src/render/shaders/vertex_world.wgsl
index 4f342fd..3cce989 100644
--- a/client/src/render/shaders/vertex_world.wgsl
+++ b/client/src/render/shaders/vertex_world.wgsl
@@ -16,15 +16,16 @@
struct VertexIn {
@location(0) position: vec3<f32>,
@location(1) normal: vec3<f32>,
- @location(2) tangent: vec3<f32>, // TODO maybe compress this
+ @location(2) tangent: vec4<f32>, // TODO maybe compress this
@location(3) texcoord: vec2<f32>,
}
struct VertexOut {
@builtin(position) clip: vec4<f32>,
@location(0) normal: vec3<f32>,
@location(1) tangent: vec3<f32>,
- @location(2) texcoord: vec2<f32>,
- @location(3) position: vec3<f32>,
+ @location(2) tangent_binormal_sign: f32,
+ @location(3) texcoord: vec2<f32>,
+ @location(4) position: vec3<f32>,
}
struct PushConst {
@@ -40,7 +41,8 @@ fn main(vi: VertexIn) -> VertexOut {
let vo = VertexOut(
clip,
normalize((pc.model * vec4(vi.normal, 0.)).xyz),
- normalize((pc.model * vec4(vi.tangent, 0.)).xyz),
+ normalize((pc.model * vec4(vi.tangent.xyz, 0.)).xyz),
+ vi.tangent.w,
vi.texcoord,
(pc.model * vec4(vi.position, 1.)).xyz,
);
diff --git a/client/src/render/shaders/vertex_world_skin.wgsl b/client/src/render/shaders/vertex_world_skin.wgsl
index 6e2b308..2188cf4 100644
--- a/client/src/render/shaders/vertex_world_skin.wgsl
+++ b/client/src/render/shaders/vertex_world_skin.wgsl
@@ -16,7 +16,7 @@
struct VertexIn {
@location(0) position: vec3<f32>,
@location(1) normal: vec3<f32>,
- @location(2) tangent: vec3<f32>, // TODO maybe compress this
+ @location(2) tangent: vec4<f32>, // TODO maybe compress this
@location(3) texcoord: vec2<f32>,
@location(4) joint_index: vec4<u32>,
@location(5) joint_weight: vec4<f32>,
@@ -25,8 +25,9 @@ struct VertexOut {
@builtin(position) clip: vec4<f32>,
@location(0) normal: vec3<f32>,
@location(1) tangent: vec3<f32>,
- @location(2) texcoord: vec2<f32>,
- @location(3) position: vec3<f32>,
+ @location(2) tangent_binormal_sign: f32,
+ @location(3) texcoord: vec2<f32>,
+ @location(4) position: vec3<f32>,
}
struct PushConst {
@@ -50,7 +51,8 @@ fn main(vi: VertexIn) -> VertexOut {
let vo = VertexOut(
clip,
normalize((pc.model * vec4(vi.normal, 0.)).xyz),
- normalize((pc.model * vec4(vi.tangent, 0.)).xyz),
+ normalize((pc.model * vec4(vi.tangent.xyz, 0.)).xyz),
+ vi.tangent.w,
vi.texcoord,
(pc.model * vec4(vi.position, 1.)).xyz,
);