Fix: EEVEE displays wrong pass if Cryptomatte is enabled

EEVEE displays the Cryptomatte false color if the Cryptomatte passes are
enabled in the viewport, even if the display pass is set to something
else. This problem doesn't really trigger at the moment, because
Cryptomatte passes can't be enabled in the viewport unless the display
pass is set to Cryptomatte. But the issue triggers in case of multi-pass
compositing as in #123378.

This is caused by unconditional write to the fragment color in the film
shader in case of Cryptomatte. To fix this, we only write the fragment
color if the display storage type is Cryptomatte.

Needed by #123378.

Pull Request: https://projects.blender.org/blender/blender/pulls/123723
This commit is contained in:
Omar Emara
2024-06-26 08:44:43 +02:00
committed by Omar Emara
parent 9ee6da08ab
commit 58f19f41ce

View File

@@ -178,8 +178,13 @@ void film_cryptomatte_layer_accum_and_store(
FilmSample src = film_sample_get(i, texel_film);
film_sample_cryptomatte_accum(src, layer_component, cryptomatte_tx, crypto_samples);
}
vec4 display_color = vec4(0.0);
for (int i = 0; i < 4; i++) {
cryptomatte_store_film_sample(dst, pass_id, crypto_samples[i], out_color);
cryptomatte_store_film_sample(dst, pass_id, crypto_samples[i], display_color);
}
if (uniform_buf.film.display_storage_type == PASS_STORAGE_CRYPTOMATTE) {
out_color = display_color;
}
}