Skip to content

Commit 6cc04d7

Browse files
committed
bevy_pbr2: Improvements to comments
1 parent 58ba7be commit 6cc04d7

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

pipelined/bevy_pbr2/src/render/mesh_view_bind_group.wgsl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct View {
1111
};
1212

1313
struct PointLight {
14-
// NOTE: .z.z .z.w .w.z .w.w
14+
// NOTE: [2][2] [2][3] [3][2] [3][3]
1515
projection_lr: vec4<f32>;
1616
color_inverse_square_range: vec4<f32>;
1717
position_radius: vec4<f32>;
@@ -40,10 +40,12 @@ struct Lights {
4040
// NOTE: this array size must be kept in sync with the constants defined bevy_pbr2/src/render/light.rs
4141
directional_lights: array<DirectionalLight, 1u>;
4242
ambient_color: vec4<f32>;
43-
cluster_dimensions: vec4<u32>; // x/y/z dimensions
44-
cluster_factors: vec4<f32>; // xy are vec2<f32>(cluster_dimensions.xy) / vec2<f32>(view.width, view.height)
45-
// z is cluster_dimensions.z / log(far / near)
46-
// w is cluster_dimensions.z * log(near) / log(far / near)
43+
// x/y/z dimensions
44+
cluster_dimensions: vec4<u32>;
45+
// xy are vec2<f32>(cluster_dimensions.xy) / vec2<f32>(view.width, view.height)
46+
// z is cluster_dimensions.z / log(far / near)
47+
// w is cluster_dimensions.z * log(near) / log(far / near)
48+
cluster_factors: vec4<f32>;
4749
n_directional_lights: u32;
4850
};
4951

@@ -54,13 +56,15 @@ struct PointLights {
5456

5557
[[block]]
5658
struct ClusterLightIndexLists {
57-
data: array<vec4<u32>, 1024u>; // each u32 contains 4 u8 indices into the PointLights array
59+
// each u32 contains 4 u8 indices into the PointLights array
60+
data: array<vec4<u32>, 1024u>;
5861
};
5962

6063
[[block]]
6164
struct ClusterOffsetsAndCounts {
62-
data: array<vec4<u32>, 1024u>; // each u32 contains a 24-bit index into ClusterLightIndexLists in the high 24 bits
63-
// and an 8-bit count of the number of lights in the low 8 bits
65+
// each u32 contains a 24-bit index into ClusterLightIndexLists in the high 24 bits
66+
// and an 8-bit count of the number of lights in the low 8 bits
67+
data: array<vec4<u32>, 1024u>;
6468
};
6569

6670
[[group(0), binding(0)]]

pipelined/bevy_pbr2/src/render/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ pub fn queue_meshes(
279279
draw_function: draw_opaque_pbr,
280280
pipeline: pipeline_id,
281281
// NOTE: Front-to-back ordering for opaque with ascending sort means near should have the
282-
// lowest sort key and getting further away should increase. As we have
283-
// -z in front of the camera, values in view space decrease away from the
284-
// camera. Flipping the sign of mesh_z results in the correct front-to-back ordering
282+
// lowest sort key and getting further away should increase. As we have
283+
// -z in front of the camera, values in view space decrease away from the
284+
// camera. Flipping the sign of mesh_z results in the correct front-to-back ordering
285285
distance: -mesh_z,
286286
});
287287
}
@@ -291,9 +291,9 @@ pub fn queue_meshes(
291291
draw_function: draw_alpha_mask_pbr,
292292
pipeline: pipeline_id,
293293
// NOTE: Front-to-back ordering for alpha mask with ascending sort means near should have the
294-
// lowest sort key and getting further away should increase. As we have
295-
// -z in front of the camera, values in view space decrease away from the
296-
// camera. Flipping the sign of mesh_z results in the correct front-to-back ordering
294+
// lowest sort key and getting further away should increase. As we have
295+
// -z in front of the camera, values in view space decrease away from the
296+
// camera. Flipping the sign of mesh_z results in the correct front-to-back ordering
297297
distance: -mesh_z,
298298
});
299299
}
@@ -303,9 +303,9 @@ pub fn queue_meshes(
303303
draw_function: draw_transparent_pbr,
304304
pipeline: pipeline_id,
305305
// NOTE: Back-to-front ordering for transparent with ascending sort means far should have the
306-
// lowest sort key and getting closer should increase. As we have
307-
// -z in front of the camera, the largest distance is -far with values increasing toward the
308-
// camera. As such we can just use mesh_z as the distance
306+
// lowest sort key and getting closer should increase. As we have
307+
// -z in front of the camera, the largest distance is -far with values increasing toward the
308+
// camera. As such we can just use mesh_z as the distance
309309
distance: mesh_z,
310310
});
311311
}

0 commit comments

Comments
 (0)