-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pipelined separate shadow vertex shader (#2727)
# Objective - Avoid unnecessary work in the vertex shader of the numerous shadow passes - Have the natural order of bind groups in the pbr shader: view, material, mesh ## Solution - Separate out the vertex stage of pbr.wgsl into depth.wgsl - Remove the unnecessary calculation of uv and normal, as well as removing the unnecessary vertex inputs and outputs - Use the depth.wgsl for shadow passes - Reorder the bind groups in pbr.wgsl and PbrShaders to be 0 - view, 1 - material, 2 - mesh in decreasing order of rebind frequency
- Loading branch information
Showing
4 changed files
with
68 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[[block]] | ||
struct View { | ||
view_proj: mat4x4<f32>; | ||
world_position: vec3<f32>; | ||
}; | ||
[[group(0), binding(0)]] | ||
var view: View; | ||
|
||
|
||
[[block]] | ||
struct Mesh { | ||
transform: mat4x4<f32>; | ||
}; | ||
[[group(1), binding(0)]] | ||
var mesh: Mesh; | ||
|
||
struct Vertex { | ||
[[location(0)]] position: vec3<f32>; | ||
}; | ||
|
||
struct VertexOutput { | ||
[[builtin(position)]] clip_position: vec4<f32>; | ||
}; | ||
|
||
[[stage(vertex)]] | ||
fn vertex(vertex: Vertex) -> VertexOutput { | ||
var out: VertexOutput; | ||
out.clip_position = view.view_proj * mesh.transform * vec4<f32>(vertex.position, 1.0); | ||
return out; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters