-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Merged by Bors] - use const Vec2 in lights cluster and bounding box when possible #4602
[Merged by Bors] - use const Vec2 in lights cluster and bounding box when possible #4602
Conversation
@@ -485,8 +487,7 @@ fn ndc_position_to_cluster( | |||
view_z: f32, | |||
) -> UVec3 { | |||
let cluster_dimensions_f32 = cluster_dimensions.as_vec3(); | |||
let frag_coord = | |||
(ndc_p.xy() * Vec2::new(0.5, -0.5) + Vec2::splat(0.5)).clamp(Vec2::ZERO, Vec2::ONE); | |||
let frag_coord = (ndc_p.xy() * VEC2_HALF_NEGATIVE_Y + VEC2_HALF).clamp(Vec2::ZERO, Vec2::ONE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay named constants 🎉
crates/bevy_pbr/src/light.rs
Outdated
) | ||
} | ||
|
||
const NDC_MIN: Vec3 = const_vec3!([-1.0, -1.0, f32::MIN]); | ||
const NDC_MAX: Vec3 = const_vec3!([1.0, 1.0, f32::MAX]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a misnomer. ndc min/max depth values are 0.0 and 1.0 as anything outside will be clipped. I’ll have a closer look what this bit of code is doing to see whether the values should be changed or whether there’s a more accurate name that can be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reordered the code to not need to clamp on a Vec3, but do it on the Vec2. The clamp on z was meaningless anyway as it was between f32::MIN
and f32::MAX
. This seem to be even a tad bit faster to execute 🎉
Removing the clamping is nice, good eye. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can merge this when you've dealt with the conflicts.
3bfdfbb
to
bb4e130
Compare
bors r+ |
# Objective - noticed a few Vec3 and Vec2 that could be const ## Solution - Declared them as const - It seems to make a tiny improvement in example `many_light`, but given that the change is not complex at all it could still be worth it
…engine#4602) - noticed a few Vec3 and Vec2 that could be const - Declared them as const - It seems to make a tiny improvement in example `many_light`, but given that the change is not complex at all it could still be worth it
…engine#4602) - noticed a few Vec3 and Vec2 that could be const - Declared them as const - It seems to make a tiny improvement in example `many_light`, but given that the change is not complex at all it could still be worth it
…engine#4602) # Objective - noticed a few Vec3 and Vec2 that could be const ## Solution - Declared them as const - It seems to make a tiny improvement in example `many_light`, but given that the change is not complex at all it could still be worth it
…engine#4602) # Objective - noticed a few Vec3 and Vec2 that could be const ## Solution - Declared them as const - It seems to make a tiny improvement in example `many_light`, but given that the change is not complex at all it could still be worth it
Objective
Solution
many_light
, but given that the change is not complex at all it could still be worth it