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 6e54468 commit f2af285
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ struct CASUniforms {
sharpness: f32,
};

@group(0) @binding(0) var screenTexture: texture_2d<f32>;
@group(0) @binding(1) var textureSampler: sampler;
@group(0) @binding(0) var screen_texture: texture_2d<f32>;
@group(0) @binding(1) var samplr: sampler;
@group(0) @binding(2) var<uniform> uniforms: CASUniforms;

// This is set at the limit of providing unnatural results for sharpening.
Expand Down Expand Up @@ -62,12 +62,12 @@ fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4<f32> {
// b
// d e f
// h
let b = textureSample(screenTexture, textureSampler, in.uv, vec2<i32>(0, -1)).rgb;
let d = textureSample(screenTexture, textureSampler, in.uv, vec2<i32>(-1, 0)).rgb;
let b = textureSample(screen_texture, samplr, in.uv, vec2<i32>(0, -1)).rgb;
let d = textureSample(screen_texture, samplr, in.uv, vec2<i32>(-1, 0)).rgb;
// We need the alpha value of the pixel we're working on for the output
let e = textureSample(screenTexture, textureSampler, in.uv).rgbw;
let f = textureSample(screenTexture, textureSampler, in.uv, vec2<i32>(1, 0)).rgb;
let h = textureSample(screenTexture, textureSampler, in.uv, vec2<i32>(0, 1)).rgb;
let e = textureSample(screen_texture, samplr, in.uv).rgbw;
let f = textureSample(screen_texture, samplr, in.uv, vec2<i32>(1, 0)).rgb;
let h = textureSample(screen_texture, samplr, in.uv, vec2<i32>(0, 1)).rgb;
// Min and max of ring.
let mn4 = min(min(b, d), min(f, h));
let mx4 = max(max(b, d), max(f, h));
Expand Down
34 changes: 17 additions & 17 deletions crates/bevy_core_pipeline/src/fxaa/fxaa.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#import bevy_core_pipeline::fullscreen_vertex_shader::FullscreenVertexOutput

@group(0) @binding(0) var screenTexture: texture_2d<f32>;
@group(0) @binding(1) var textureSampler: sampler;
@group(0) @binding(0) var screen_texture: texture_2d<f32>;
@group(0) @binding(1) var samplr: sampler;

// Trims the algorithm from processing darks.
#ifdef EDGE_THRESH_MIN_LOW
Expand Down Expand Up @@ -74,21 +74,21 @@ fn rgb2luma(rgb: vec3<f32>) -> f32 {
// Performs FXAA post-process anti-aliasing as described in the Nvidia FXAA white paper and the associated shader code.
@fragment
fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4<f32> {
let resolution = vec2<f32>(textureDimensions(screenTexture));
let resolution = vec2<f32>(textureDimensions(screen_texture));
let inverseScreenSize = 1.0 / resolution.xy;
let texCoord = in.position.xy * inverseScreenSize;

let centerSample = textureSampleLevel(screenTexture, textureSampler, texCoord, 0.0);
let centerSample = textureSampleLevel(screen_texture, samplr, texCoord, 0.0);
let colorCenter = centerSample.rgb;

// Luma at the current fragment
let lumaCenter = rgb2luma(colorCenter);

// Luma at the four direct neighbors of the current fragment.
let lumaDown = rgb2luma(textureSampleLevel(screenTexture, textureSampler, texCoord, 0.0, vec2<i32>(0, -1)).rgb);
let lumaUp = rgb2luma(textureSampleLevel(screenTexture, textureSampler, texCoord, 0.0, vec2<i32>(0, 1)).rgb);
let lumaLeft = rgb2luma(textureSampleLevel(screenTexture, textureSampler, texCoord, 0.0, vec2<i32>(-1, 0)).rgb);
let lumaRight = rgb2luma(textureSampleLevel(screenTexture, textureSampler, texCoord, 0.0, vec2<i32>(1, 0)).rgb);
let lumaDown = rgb2luma(textureSampleLevel(screen_texture, samplr, texCoord, 0.0, vec2<i32>(0, -1)).rgb);
let lumaUp = rgb2luma(textureSampleLevel(screen_texture, samplr, texCoord, 0.0, vec2<i32>(0, 1)).rgb);
let lumaLeft = rgb2luma(textureSampleLevel(screen_texture, samplr, texCoord, 0.0, vec2<i32>(-1, 0)).rgb);
let lumaRight = rgb2luma(textureSampleLevel(screen_texture, samplr, texCoord, 0.0, vec2<i32>(1, 0)).rgb);

// Find the maximum and minimum luma around the current fragment.
let lumaMin = min(lumaCenter, min(min(lumaDown, lumaUp), min(lumaLeft, lumaRight)));
Expand All @@ -103,10 +103,10 @@ fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4<f32> {
}

// Query the 4 remaining corners lumas.
let lumaDownLeft = rgb2luma(textureSampleLevel(screenTexture, textureSampler, texCoord, 0.0, vec2<i32>(-1, -1)).rgb);
let lumaUpRight = rgb2luma(textureSampleLevel(screenTexture, textureSampler, texCoord, 0.0, vec2<i32>(1, 1)).rgb);
let lumaUpLeft = rgb2luma(textureSampleLevel(screenTexture, textureSampler, texCoord, 0.0, vec2<i32>(-1, 1)).rgb);
let lumaDownRight = rgb2luma(textureSampleLevel(screenTexture, textureSampler, texCoord, 0.0, vec2<i32>(1, -1)).rgb);
let lumaDownLeft = rgb2luma(textureSampleLevel(screen_texture, samplr, texCoord, 0.0, vec2<i32>(-1, -1)).rgb);
let lumaUpRight = rgb2luma(textureSampleLevel(screen_texture, samplr, texCoord, 0.0, vec2<i32>(1, 1)).rgb);
let lumaUpLeft = rgb2luma(textureSampleLevel(screen_texture, samplr, texCoord, 0.0, vec2<i32>(-1, 1)).rgb);
let lumaDownRight = rgb2luma(textureSampleLevel(screen_texture, samplr, texCoord, 0.0, vec2<i32>(1, -1)).rgb);

// Combine the four edges lumas (using intermediary variables for future computations with the same values).
let lumaDownUp = lumaDown + lumaUp;
Expand Down Expand Up @@ -174,8 +174,8 @@ fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4<f32> {
var uv2 = currentUv + offset; // * QUALITY(0); // (quality 0 is 1.0)

// Read the lumas at both current extremities of the exploration segment, and compute the delta wrt to the local average luma.
var lumaEnd1 = rgb2luma(textureSampleLevel(screenTexture, textureSampler, uv1, 0.0).rgb);
var lumaEnd2 = rgb2luma(textureSampleLevel(screenTexture, textureSampler, uv2, 0.0).rgb);
var lumaEnd1 = rgb2luma(textureSampleLevel(screen_texture, samplr, uv1, 0.0).rgb);
var lumaEnd2 = rgb2luma(textureSampleLevel(screen_texture, samplr, uv2, 0.0).rgb);
lumaEnd1 = lumaEnd1 - lumaLocalAverage;
lumaEnd2 = lumaEnd2 - lumaLocalAverage;

Expand All @@ -193,12 +193,12 @@ fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4<f32> {
for (var i: i32 = 2; i < ITERATIONS; i = i + 1) {
// If needed, read luma in 1st direction, compute delta.
if (!reached1) {
lumaEnd1 = rgb2luma(textureSampleLevel(screenTexture, textureSampler, uv1, 0.0).rgb);
lumaEnd1 = rgb2luma(textureSampleLevel(screen_texture, samplr, uv1, 0.0).rgb);
lumaEnd1 = lumaEnd1 - lumaLocalAverage;
}
// If needed, read luma in opposite direction, compute delta.
if (!reached2) {
lumaEnd2 = rgb2luma(textureSampleLevel(screenTexture, textureSampler, uv2, 0.0).rgb);
lumaEnd2 = rgb2luma(textureSampleLevel(screen_texture, samplr, uv2, 0.0).rgb);
lumaEnd2 = lumaEnd2 - lumaLocalAverage;
}
// If the luma deltas at the current extremities is larger than the local gradient, we have reached the side of the edge.
Expand Down Expand Up @@ -269,6 +269,6 @@ fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4<f32> {
}

// Read the color at the new UV coordinates, and use it.
var finalColor = textureSampleLevel(screenTexture, textureSampler, finalUv, 0.0).rgb;
var finalColor = textureSampleLevel(screen_texture, samplr, finalUv, 0.0).rgb;
return vec4<f32>(finalColor, centerSample.a);
}
6 changes: 3 additions & 3 deletions crates/bevy_math/src/common_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl NormedVectorSpace for f32 {
///
/// 3. Importantly, the interpolation must be *subdivision-stable*: for any interpolation curve
/// between two (unnamed) values and any parameter-value pairs `(t0, p)` and `(t1, q)`, the
/// interpolation curve between `p` and `q` must be the *linear* reparameterization of the original
/// interpolation curve between `p` and `q` must be the *linear* reparametrization of the original

Check warning on line 183 in crates/bevy_math/src/common_traits.rs

View workflow job for this annotation

GitHub Actions / typos

"reparametrization" should be "reparameterization".
/// interpolation curve restricted to the interval `[t0, t1]`.
///
/// The last of these conditions is very strong and indicates something like constant speed. It
Expand All @@ -191,13 +191,13 @@ impl NormedVectorSpace for f32 {
/// ```text
/// top curve = u.interpolate_stable(v, t)
///
/// t0 => p t1 => q
/// t0 => p t1 => q
/// |-------------|---------|-------------|
/// 0 => u / \ 1 => v
/// / \
/// / \
/// / linear \
/// / reparameterization \
/// / reparametrization \

Check warning on line 200 in crates/bevy_math/src/common_traits.rs

View workflow job for this annotation

GitHub Actions / typos

"reparametrization" should be "reparameterization".
/// / t = t0 * (1 - s) + t1 * s \
/// / \
/// |-------------------------------------|
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_math/src/cubic_splines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ impl<P: VectorSpace> CyclicCubicGenerator<P> for CubicCardinalSpline<P> {
}

// This would ordinarily be the last segment, but we pick it out so that we can make it first
// in order to get a desirable parameterization where the first segment connects the first two
// in order to get a desirable parametrization where the first segment connects the first two
// control points instead of the second and third.
let first_segment = {
// We take the indices mod `len` in case `len` is very small.
Expand Down Expand Up @@ -482,7 +482,7 @@ impl<P: VectorSpace> CyclicCubicGenerator<P> for CubicBSpline<P> {
.map(|(&a, &b, &c, &d)| CubicSegment::coefficients([a, b, c, d], self.char_matrix()))
.collect_vec();

// Note that the parameterization is consistent with the one for `to_curve` but with
// Note that the parametrization is consistent with the one for `to_curve` but with
// the extra curve segments all tacked on at the end. This might be slightly counter-intuitive,
// since it means the first segment doesn't go "between" the first two control points, but
// between the second and third instead.
Expand Down
12 changes: 6 additions & 6 deletions crates/bevy_math/src/curve/adaptors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ where
}

/// A curve whose sample space is mapped onto that of some base curve's before sampling.
/// Curves of this type are produced by [`Curve::reparameterize`].
/// Curves of this type are produced by [`Curve::reparametrize`].
#[derive(Clone)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
Expand Down Expand Up @@ -362,8 +362,8 @@ where
}
}

/// A curve that has had its domain changed by a linear reparameterization (stretching and scaling).
/// Curves of this type are produced by [`Curve::reparameterize_linear`].
/// A curve that has had its domain changed by a linear reparametrization (stretching and scaling).

Check warning on line 365 in crates/bevy_math/src/curve/adaptors.rs

View workflow job for this annotation

GitHub Actions / typos

"reparametrization" should be "reparameterization".
/// Curves of this type are produced by [`Curve::reparametrize_linear`].
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
Expand Down Expand Up @@ -397,8 +397,8 @@ where
}
}

/// A curve that has been reparameterized by another curve, using that curve to transform the
/// sample times before sampling. Curves of this type are produced by [`Curve::reparameterize_by_curve`].
/// A curve that has been reparametrized by another curve, using that curve to transform the
/// sample times before sampling. Curves of this type are produced by [`Curve::reparametrize_by_curve`].
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
Expand Down Expand Up @@ -497,7 +497,7 @@ where
}

/// The curve that results from chaining one curve with another. The second curve is
/// effectively reparameterized so that its start is at the end of the first.
/// effectively reparametrized so that its start is at the end of the first.
///
/// For this to be well-formed, the first curve's domain must be right-finite and the second's
/// must be left-finite.
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_math/src/curve/cores.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,14 @@ impl<T> UnevenCore<T> {
}

/// This core, but with the sample times moved by the map `f`.
/// In principle, when `f` is monotone, this is equivalent to [`Curve::reparameterize`],
/// In principle, when `f` is monotone, this is equivalent to [`Curve::reparametrize`],
/// but the function inputs to each are inverses of one another.
///
/// The samples are re-sorted by time after mapping and deduplicated by output time, so
/// the function `f` should generally be injective over the set of sample times, otherwise
/// data will be deleted.
///
/// [`Curve::reparameterize`]: crate::curve::Curve::reparameterize
/// [`Curve::reparametrize`]: crate::curve::Curve::reparametrize
#[must_use]
pub fn map_sample_times(mut self, f: impl Fn(f32) -> f32) -> UnevenCore<T> {
let mut timed_samples = self
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_math/src/curve/easing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ pub enum EaseFunction {
/// `n` steps connecting the start and the end
Steps(usize),

/// `f(omega,t) = 1 - (1 - t)²(2sin(omega * t) / omega + cos(omega * t))`, parameterized by `omega`
/// `f(omega,t) = 1 - (1 - t)²(2sin(omega * t) / omega + cos(omega * t))`, parametrized by `omega`
Elastic(f32),
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_math/src/curve/iterable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use super::{ConstantCurve, Interval};
/// but side-stepping issues with allocation on sampling. This happens when the size of an output
/// array cannot be known statically.
pub trait IterableCurve<T> {
/// The interval over which this curve is parameterized.
/// The interval over which this curve is parametrized.
fn domain(&self) -> Interval;

/// Sample a point on this curve at the parameter value `t`, producing an iterator over values.
Expand Down
Loading

0 comments on commit f2af285

Please sign in to comment.