Sectional color grading gives the shadows→midtones blend to the highlights, a hard step at level 0.1

Abierto Apto para principiantes
#26,460 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
1/5
Tiempo estimado
Menos de una hora
Aptitud para principiantes
92/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust

Línea de trabajo

Lee sectional_color_grading en crates/bevy_core_pipeline/src/tonemapping.wesl, especialmente la rama de sombras a medios tonos identificada en el informe. Comprueba cómo cambian sus tres pesos de sección a lo largo de la banda de transición y compáralos con la rama siguiente, de medios tonos a altas luces. La tarea estará terminada cuando la mezcla de sombras a medios tonos asigne el peso restante a las sombras y se elimine el salto brusco señalado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

A-Rendering C-Bug D-Straightforward S-Ready-For-Implementation X-Uncontroversial

Bevy version and features

  • 0.20.0, default features. The same code is on main at 526f9e4.

[Optional] Relevant system information

  • macOS 26 (Darwin 25.6), Apple M1 Pro, Metal. This is a logic bug in the shader, so it should not depend on the platform.

What you did

I graded the shadows and midtones of a camera and left the highlights at their defaults:

let section = ColorGradingSection { gain: 1.12, gamma: 0.74, ..default() };
let grading = ColorGrading {
    global: ColorGradingGlobal::default(), // midtones_range: 0.2..0.7
    shadows: section,
    midtones: section,
    highlights: ColorGradingSection::default(),
};

Then I looked at a smooth gradient whose brightness passes 0.1 (mean linear RGB before tone mapping). In my case this was the sky round the sun just after sunset with Atmosphere. Any smooth gradient over that brightness shows it.

What went wrong

  • Expected: the grade fades smoothly from the shadows' setting into the midtones', as the comment in sectional_color_grading says ("blend between the two to avoid sharp color discontinuities").
  • Actual: there is a hard step along the contour where the level is 0.1. Below it the full shadows grade applies. Just above it the highlights grade applies, which here means no grade. In my scene this drew a sharp pale ellipse round the dusk glow. Adjacent rows read sRGB (77, 60, 60) and (99, 83, 83).

The cause is in sectional_color_grading in crates/bevy_core_pipeline/src/tonemapping.wesl:

https://github.com/bevyengine/bevy/blob/526f9e40253348a52a0d0380db98e287e4b5e0b3/crates/bevy_core_pipeline/src/tonemapping.wesl#L330-L341

} else if (level < midtone_range.x + LEVEL_MARGIN) {
    levels.y = ((level - midtone_range.x) * LEVEL_MARGIN_DIV) + 0.5;
    levels.z = 1.0 - levels.y;   // gives the rest to the highlights

In the shadows-to-midtones band the weight the midtones don't take goes to levels.z (highlights) instead of levels.x (shadows). At the bottom of the band (level = midtone_range.x - LEVEL_MARGIN) the weights jump from (1, 0, 0) to (0, 0, 1). The midtones-to-highlights branch below it is correct.

The fix is one line:

    levels.x = 1.0 - levels.y;

The step is visible with any setting where the shadows differ from the highlights (contrast, gain, gamma, lift, saturation). The color_grading example probably hides it because its scene has few colours near a level of 0.1.

Additional information

Workaround: if the shadows and midtones can share one ColorGradingSection, start midtones_range below -LEVEL_MARGIN, for example -0.2..0.7, so no colour falls in the broken band. With that change our dusk sky grades smoothly.

Lenguaje dominante
Rust
Estrellas
49.5k
Forks
5k
Merge medio
5 d 11 h
PR fusionados (30 d)
138

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de bevyengine/bevy

Todos los issues de bevyengine/bevy

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.