summaryrefslogtreecommitdiff
path: root/client/src/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/shaders')
-rw-r--r--client/src/shaders/fragment_pbr.wgsl10
-rw-r--r--client/src/shaders/vertex_world.wgsl8
-rw-r--r--client/src/shaders/vertex_world_skin.wgsl17
3 files changed, 21 insertions, 14 deletions
diff --git a/client/src/shaders/fragment_pbr.wgsl b/client/src/shaders/fragment_pbr.wgsl
index 60d7737..c8fb857 100644
--- a/client/src/shaders/fragment_pbr.wgsl
+++ b/client/src/shaders/fragment_pbr.wgsl
@@ -42,14 +42,14 @@ fn main(vo: VertexOut) -> @location(0) vec4<f32> {
let tangent_basis = mat3x3(vo.tangent, cross(vo.tangent, vo.normal), vo.normal);
let normal = tangent_basis * (t_normal.rgb * 2. - 1.);
- let light = vec3(0., 0., 0.);
- let view = normalize(-vo.position);
+ let light = vec3(0.64, 0.64, 0.64);
+ // let view = normalize(-vo.position);
let ambient = 0.1;
- let diffuse = saturate(dot(light, normal)) * 0.7;
- let specular = pow(saturate(dot(reflect(-light, normal), view)), 2.);
+ let diffuse = saturate(dot(light, normal));
+ // let specular = pow(saturate(dot(reflect(-light, normal), view)), 2.);
- let lighting = ambient + diffuse + specular;
+ let lighting = ambient + diffuse;
let color = t_albedo.rgb * lighting;
// let color = vec3(dot(normal, view) * 0.5 + 0.5) ;
diff --git a/client/src/shaders/vertex_world.wgsl b/client/src/shaders/vertex_world.wgsl
index e185289..4f342fd 100644
--- a/client/src/shaders/vertex_world.wgsl
+++ b/client/src/shaders/vertex_world.wgsl
@@ -29,7 +29,7 @@ struct VertexOut {
struct PushConst {
modelviewproject: mat4x4<f32>,
- modelview: mat4x4<f32>,
+ model: mat4x4<f32>,
}
var<push_constant> pc: PushConst;
@@ -39,10 +39,10 @@ fn main(vi: VertexIn) -> VertexOut {
let clip = pc.modelviewproject * vec4(vi.position, 1.);
let vo = VertexOut(
clip,
- normalize((pc.modelview * vec4(vi.normal, 0.)).xyz),
- normalize((pc.modelview * vec4(vi.tangent, 0.)).xyz),
+ normalize((pc.model * vec4(vi.normal, 0.)).xyz),
+ normalize((pc.model * vec4(vi.tangent, 0.)).xyz),
vi.texcoord,
- (pc.modelview * vec4(vi.position, 1.)).xyz,
+ (pc.model * vec4(vi.position, 1.)).xyz,
);
return vo;
}
diff --git a/client/src/shaders/vertex_world_skin.wgsl b/client/src/shaders/vertex_world_skin.wgsl
index 633f06b..6e2b308 100644
--- a/client/src/shaders/vertex_world_skin.wgsl
+++ b/client/src/shaders/vertex_world_skin.wgsl
@@ -31,7 +31,7 @@ struct VertexOut {
struct PushConst {
modelviewproject: mat4x4<f32>,
- modelview: mat4x4<f32>,
+ model: mat4x4<f32>,
}
@group(3) @binding(0) var<uniform> joints: array<mat4x4<f32>, 128>;
@@ -39,13 +39,20 @@ var<push_constant> pc: PushConst;
@vertex
fn main(vi: VertexIn) -> VertexOut {
- let clip = pc.modelview * vec4(vi.position, 1.);
+ let pos_in = vec4(vi.position, 1.);
+ let j0 = vi.joint_weight.x * (joints[vi.joint_index.x] * pos_in);
+ let j1 = vi.joint_weight.y * (joints[vi.joint_index.y] * pos_in);
+ let j2 = vi.joint_weight.z * (joints[vi.joint_index.z] * pos_in);
+ let j3 = vi.joint_weight.w * (joints[vi.joint_index.w] * pos_in);
+ let position = j0 + j1 + j2 + j3;
+
+ let clip = pc.modelviewproject * position;
let vo = VertexOut(
clip,
- normalize((pc.modelview * vec4(vi.normal, 0.)).xyz),
- normalize((pc.modelview * vec4(vi.tangent, 0.)).xyz),
+ normalize((pc.model * vec4(vi.normal, 0.)).xyz),
+ normalize((pc.model * vec4(vi.tangent, 0.)).xyz),
vi.texcoord,
- (pc.modelview * vec4(vi.position, 1.)).xyz,
+ (pc.model * vec4(vi.position, 1.)).xyz,
);
return vo;
}