Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminBrienen committed Nov 17, 2024
1 parent 6ca2d51 commit 88e2af8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_dev_tools/src/fps_overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use bevy_utils::default;
/// [`GlobalZIndex`] used to render the fps overlay.
///
/// We use a number slightly under `i32::MAX` so that you can render on top of it if you really need to.
pub const FPS_OVERLAY_ZINDEX: i32 = i32::MAX - 32;
pub const FPS_OVERLAY_Z_INDEX: i32 = i32::MAX - 32;

/// A plugin that adds an FPS overlay to the Bevy application.
///
Expand Down Expand Up @@ -94,7 +94,7 @@ fn setup(mut commands: Commands, overlay_config: Res<FpsOverlayConfig>) {
..default()
},
// Render overlay on top of everything
GlobalZIndex(FPS_OVERLAY_ZINDEX),
GlobalZIndex(FPS_OVERLAY_Z_INDEX),
))
.with_children(|p| {
p.spawn((
Expand Down
14 changes: 7 additions & 7 deletions crates/bevy_ecs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1516,10 +1516,10 @@ mod tests {

#[test]
fn insert_overwrite_drop() {
let (drop_ck1, dropped1) = DropCk::new_pair();
let (drop_ck2, dropped2) = DropCk::new_pair();
let (dropck1, dropped1) = DropCk::new_pair();
let (dropck2, dropped2) = DropCk::new_pair();
let mut world = World::default();
world.spawn(drop_ck1).insert(drop_ck2);
world.spawn(dropck1).insert(dropck2);
assert_eq!(dropped1.load(Ordering::Relaxed), 1);
assert_eq!(dropped2.load(Ordering::Relaxed), 0);
drop(world);
Expand All @@ -1529,13 +1529,13 @@ mod tests {

#[test]
fn insert_overwrite_drop_sparse() {
let (drop_ck1, dropped1) = DropCk::new_pair();
let (drop_ck2, dropped2) = DropCk::new_pair();
let (dropck1, dropped1) = DropCk::new_pair();
let (dropck2, dropped2) = DropCk::new_pair();
let mut world = World::default();

world
.spawn(DropCkSparse(drop_ck1))
.insert(DropCkSparse(drop_ck2));
.spawn(DropCkSparse(dropck1))
.insert(DropCkSparse(dropck2));
assert_eq!(dropped1.load(Ordering::Relaxed), 1);
assert_eq!(dropped2.load(Ordering::Relaxed), 0);
drop(world);
Expand Down
16 changes: 8 additions & 8 deletions crates/bevy_ecs/src/system/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2309,12 +2309,12 @@ mod tests {
let mut world = World::default();

let mut command_queue = CommandQueue::default();
let (dense_drop_ck, dense_is_dropped) = DropCk::new_pair();
let (sparse_drop_ck, sparse_is_dropped) = DropCk::new_pair();
let sparse_drop_ck = SparseDropCk(sparse_drop_ck);
let (dense_dropck, dense_is_dropped) = DropCk::new_pair();
let (sparse_dropck, sparse_is_dropped) = DropCk::new_pair();
let sparse_dropck = SparseDropCk(sparse_dropck);

let entity = Commands::new(&mut command_queue, &world)
.spawn((W(1u32), W(2u64), dense_drop_ck, sparse_drop_ck))
.spawn((W(1u32), W(2u64), dense_dropck, sparse_dropck))
.id();
command_queue.apply(&mut world);
let results_before = world
Expand Down Expand Up @@ -2355,12 +2355,12 @@ mod tests {
let mut world = World::default();

let mut command_queue = CommandQueue::default();
let (dense_drop_ck, dense_is_dropped) = DropCk::new_pair();
let (sparse_drop_ck, sparse_is_dropped) = DropCk::new_pair();
let sparse_drop_ck = SparseDropCk(sparse_drop_ck);
let (dense_dropck, dense_is_dropped) = DropCk::new_pair();
let (sparse_dropck, sparse_is_dropped) = DropCk::new_pair();
let sparse_dropck = SparseDropCk(sparse_dropck);

let entity = Commands::new(&mut command_queue, &world)
.spawn((W(1u32), W(2u64), dense_drop_ck, sparse_drop_ck))
.spawn((W(1u32), W(2u64), dense_dropck, sparse_dropck))
.id();
command_queue.apply(&mut world);
let results_before = world
Expand Down
32 changes: 16 additions & 16 deletions crates/bevy_pbr/src/render/pbr_functions.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ fn apply_pbr_lighting(
let specular_occlusion = in.specular_occlusion;

// Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886"
let N_dot_V = max(dot(in.N, in.V), 0.0001);
let NdotV = max(dot(in.N, in.V), 0.0001);
let R = reflect(-in.V, in.N);

#ifdef STANDARD_MATERIAL_CLEARCOAT
Expand All @@ -327,7 +327,7 @@ fn apply_pbr_lighting(
let clearcoat_perceptual_roughness = in.material.clearcoat_perceptual_roughness;
let clearcoat_roughness = lighting::perceptualRoughnessToRoughness(clearcoat_perceptual_roughness);
let clearcoat_N = in.clearcoat_N;
let clearcoat_N_dot_V = max(dot(clearcoat_N, in.V), 0.0001);
let clearcoat_NdotV = max(dot(clearcoat_N, in.V), 0.0001);
let clearcoat_R = reflect(-in.V, clearcoat_N);
#endif // STANDARD_MATERIAL_CLEARCOAT

Expand All @@ -345,7 +345,7 @@ fn apply_pbr_lighting(
let diffuse_transmissive_lobe_world_position = in.world_position - vec4<f32>(in.world_normal, 0.0) * thickness;

let F0 = calculate_F0(output_color.rgb, metallic, reflectance);
let F_ab = lighting::F_AB(perceptual_roughness, N_dot_V);
let F_ab = lighting::F_AB(perceptual_roughness, NdotV);

var direct_light: vec3<f32> = vec3<f32>(0.0);

Expand All @@ -354,7 +354,7 @@ fn apply_pbr_lighting(

// Pack all the values into a structure.
var lighting_input: lighting::LightingInput;
lighting_input.layers[LAYER_BASE].N_dot_V = N_dot_V;
lighting_input.layers[LAYER_BASE].NdotV = NdotV;
lighting_input.layers[LAYER_BASE].N = in.N;
lighting_input.layers[LAYER_BASE].R = R;
lighting_input.layers[LAYER_BASE].perceptual_roughness = perceptual_roughness;
Expand All @@ -365,7 +365,7 @@ fn apply_pbr_lighting(
lighting_input.F0_ = F0;
lighting_input.F_ab = F_ab;
#ifdef STANDARD_MATERIAL_CLEARCOAT
lighting_input.layers[LAYER_CLEARCOAT].N_dot_V = clearcoat_N_dot_V;
lighting_input.layers[LAYER_CLEARCOAT].NdotV = clearcoat_NdotV;
lighting_input.layers[LAYER_CLEARCOAT].N = clearcoat_N;
lighting_input.layers[LAYER_CLEARCOAT].R = clearcoat_R;
lighting_input.layers[LAYER_CLEARCOAT].perceptual_roughness = clearcoat_perceptual_roughness;
Expand All @@ -381,7 +381,7 @@ fn apply_pbr_lighting(
// And do the same for transmissive if we need to.
#ifdef STANDARD_MATERIAL_DIFFUSE_TRANSMISSION
var transmissive_lighting_input: lighting::LightingInput;
transmissive_lighting_input.layers[LAYER_BASE].N_dot_V = 1.0;
transmissive_lighting_input.layers[LAYER_BASE].NdotV = 1.0;
transmissive_lighting_input.layers[LAYER_BASE].N = -in.N;
transmissive_lighting_input.layers[LAYER_BASE].R = vec3(0.0);
transmissive_lighting_input.layers[LAYER_BASE].perceptual_roughness = 1.0;
Expand All @@ -392,7 +392,7 @@ fn apply_pbr_lighting(
transmissive_lighting_input.F0_ = vec3(0.0);
transmissive_lighting_input.F_ab = vec2(0.1);
#ifdef STANDARD_MATERIAL_CLEARCOAT
transmissive_lighting_input.layers[LAYER_CLEARCOAT].N_dot_V = 0.0;
transmissive_lighting_input.layers[LAYER_CLEARCOAT].NdotV = 0.0;
transmissive_lighting_input.layers[LAYER_CLEARCOAT].N = vec3(0.0);
transmissive_lighting_input.layers[LAYER_CLEARCOAT].R = vec3(0.0);
transmissive_lighting_input.layers[LAYER_CLEARCOAT].perceptual_roughness = 0.0;
Expand Down Expand Up @@ -433,7 +433,7 @@ fn apply_pbr_lighting(
// values for a fully diffuse transmitted light contribution approximation:
//
// roughness = 1.0;
// N_dot_V = 1.0;
// NdotV = 1.0;
// R = vec3<f32>(0.0) // doesn't really matter
// F_ab = vec2<f32>(0.1)
// F0 = vec3<f32>(0.0)
Expand Down Expand Up @@ -474,7 +474,7 @@ fn apply_pbr_lighting(
// values for a fully diffuse transmitted light contribution approximation:
//
// roughness = 1.0;
// N_dot_V = 1.0;
// NdotV = 1.0;
// R = vec3<f32>(0.0) // doesn't really matter
// F_ab = vec2<f32>(0.1)
// F0 = vec3<f32>(0.0)
Expand Down Expand Up @@ -524,7 +524,7 @@ fn apply_pbr_lighting(
// values for a fully diffuse transmitted light contribution approximation:
//
// roughness = 1.0;
// N_dot_V = 1.0;
// NdotV = 1.0;
// R = vec3<f32>(0.0) // doesn't really matter
// F_ab = vec2<f32>(0.1)
// F0 = vec3<f32>(0.0)
Expand All @@ -546,7 +546,7 @@ fn apply_pbr_lighting(
// values for a fully diffuse transmitted light contribution approximation:
//
// perceptual_roughness = 1.0;
// N_dot_V = 1.0;
// NdotV = 1.0;
// F0 = vec3<f32>(0.0)
// diffuse_occlusion = vec3<f32>(1.0)
transmitted_light += ambient::ambient_light(diffuse_transmissive_lobe_world_position, -in.N, -in.V, 1.0, diffuse_transmissive_color, vec3<f32>(0.0), 1.0, vec3<f32>(1.0));
Expand Down Expand Up @@ -619,7 +619,7 @@ fn apply_pbr_lighting(
#endif // ENVIRONMENT_MAP

// Ambient light (indirect)
indirect_light += ambient::ambient_light(in.world_position, in.N, in.V, N_dot_V, diffuse_color, F0, perceptual_roughness, diffuse_occlusion);
indirect_light += ambient::ambient_light(in.world_position, in.N, in.V, NdotV, diffuse_color, F0, perceptual_roughness, diffuse_occlusion);

// we'll use the specular component of the transmitted environment
// light in the call to `specular_transmissive_light()` below
Expand All @@ -633,7 +633,7 @@ fn apply_pbr_lighting(
// approximation:
//
// diffuse_color = vec3<f32>(1.0) // later we use `diffuse_transmissive_color` and `specular_transmissive_color`
// N_dot_V = 1.0;
// NdotV = 1.0;
// R = T // see definition below
// F0 = vec3<f32>(1.0)
// diffuse_occlusion = 1.0
Expand All @@ -648,7 +648,7 @@ fn apply_pbr_lighting(

var transmissive_environment_light_input: lighting::LightingInput;
transmissive_environment_light_input.diffuse_color = vec3(1.0);
transmissive_environment_light_input.layers[LAYER_BASE].N_dot_V = 1.0;
transmissive_environment_light_input.layers[LAYER_BASE].NdotV = 1.0;
transmissive_environment_light_input.P = in.world_position.xyz;
transmissive_environment_light_input.layers[LAYER_BASE].N = -in.N;
transmissive_environment_light_input.V = in.V;
Expand All @@ -660,7 +660,7 @@ fn apply_pbr_lighting(
#ifdef STANDARD_MATERIAL_CLEARCOAT
// No clearcoat.
transmissive_environment_light_input.clearcoat_strength = 0.0;
transmissive_environment_light_input.layers[LAYER_CLEARCOAT].N_dot_V = 0.0;
transmissive_environment_light_input.layers[LAYER_CLEARCOAT].NdotV = 0.0;
transmissive_environment_light_input.layers[LAYER_CLEARCOAT].N = in.N;
transmissive_environment_light_input.layers[LAYER_CLEARCOAT].R = vec3(0.0);
transmissive_environment_light_input.layers[LAYER_CLEARCOAT].perceptual_roughness = 0.0;
Expand Down Expand Up @@ -688,7 +688,7 @@ fn apply_pbr_lighting(
//
// <https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md#emission>
#ifdef STANDARD_MATERIAL_CLEARCOAT
emissive_light = emissive_light * (0.04 + (1.0 - 0.04) * pow(1.0 - clearcoat_N_dot_V, 5.0));
emissive_light = emissive_light * (0.04 + (1.0 - 0.04) * pow(1.0 - clearcoat_NdotV, 5.0));
#endif

emissive_light = emissive_light * mix(1.0, view_bindings::view.exposure, emissive.a);
Expand Down

0 comments on commit 88e2af8

Please sign in to comment.