Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: Use VertexOuput instead of FragmentInput in prepass.wgsl #10009

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 8 additions & 27 deletions crates/bevy_pbr/src/prepass/prepass.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ struct Vertex {
#endif // MORPH_TARGETS
}

struct VertexOutput {
@builtin(position) clip_position: vec4<f32>,
struct PrepassMeshVertexOutput {
@builtin(position) position: vec4<f32>,

#ifdef VERTEX_UVS
@location(0) uv: vec2<f32>,
Expand Down Expand Up @@ -78,8 +78,8 @@ fn morph_vertex(vertex_in: Vertex) -> Vertex {
#endif

@vertex
fn vertex(vertex_no_morph: Vertex) -> VertexOutput {
var out: VertexOutput;
fn vertex(vertex_no_morph: Vertex) -> PrepassMeshVertexOutput {
var out: PrepassMeshVertexOutput;

#ifdef MORPH_TARGETS
var vertex = morph_vertex(vertex_no_morph);
Expand All @@ -95,10 +95,10 @@ fn vertex(vertex_no_morph: Vertex) -> VertexOutput {
var model = bevy_pbr::mesh_functions::get_model_matrix(vertex_no_morph.instance_index);
#endif // SKINNED

out.clip_position = bevy_pbr::mesh_functions::mesh_position_local_to_clip(model, vec4(vertex.position, 1.0));
out.position = bevy_pbr::mesh_functions::mesh_position_local_to_clip(model, vec4(vertex.position, 1.0));
#ifdef DEPTH_CLAMP_ORTHO
out.clip_position_unclamped = out.clip_position;
out.clip_position.z = min(out.clip_position.z, 1.0);
out.clip_position_unclamped = out.position;
out.position.z = min(out.position.z, 1.0);
#endif // DEPTH_CLAMP_ORTHO

#ifdef VERTEX_UVS
Expand Down Expand Up @@ -142,25 +142,6 @@ fn vertex(vertex_no_morph: Vertex) -> VertexOutput {
}

#ifdef PREPASS_FRAGMENT
idobenamram marked this conversation as resolved.
Show resolved Hide resolved
struct FragmentInput {
#ifdef VERTEX_UVS
@location(0) uv: vec2<f32>,
#endif // VERTEX_UVS

#ifdef NORMAL_PREPASS
@location(1) world_normal: vec3<f32>,
#endif // NORMAL_PREPASS

#ifdef MOTION_VECTOR_PREPASS
@location(3) world_position: vec4<f32>,
@location(4) previous_world_position: vec4<f32>,
#endif // MOTION_VECTOR_PREPASS

#ifdef DEPTH_CLAMP_ORTHO
@location(5) clip_position_unclamped: vec4<f32>,
#endif // DEPTH_CLAMP_ORTHO
}
idobenamram marked this conversation as resolved.
Show resolved Hide resolved

struct FragmentOutput {
#ifdef NORMAL_PREPASS
@location(0) normal: vec4<f32>,
Expand All @@ -176,7 +157,7 @@ struct FragmentOutput {
}

@fragment
fn fragment(in: FragmentInput) -> FragmentOutput {
fn fragment(in: PrepassMeshVertexOutput) -> FragmentOutput {
var out: FragmentOutput;

#ifdef NORMAL_PREPASS
Expand Down