Problem
I had set up a scene that behaves as follows:
- Camera A is looking at a 2D scene containing a set of moving white dots on a black background, and its render target is set to Image A
- Camera B is looking at a 2D scene containing a rectangle with a custom material, and its render target is set to Image B. The material reads both Image A and Image B, and applies the following code for its shader.
@fragment
fn fragment(mesh: VertexOutput) -> @location(0) vec4<f32> {
let color_1 = textureSample(first_pass_texture, first_pass_sampler, mesh.uv).rgb;
let color_2 = textureSample(second_pass_texture, second_pass_sampler, mesh.uv).rgb;
var working_color = color_2;
working_color -= 0.005;
let color_final = max(working_color, color_1);
return vec4(color_final, 1.0);
}
The intent of this setup is that the color information from Image A is retained, but slowly fades to black over time. Both images were set to use TextureFormat::Rgba32Float. However, the behavior that I got was that the fade would eventually hit an arbitrary grey value (which changes depending on what gets subtracted from working_color), and then it would never progress in fading beyond that point.
Further testing revealed that it is only once the colors are modified by less than an arbitrary infinitesimal that this behavior would occur. In the supplied fragment shader code, this problem does not present itself if 0.006 is subtracted.
However, if Hdr is added as a component to both of the camera entities, the fade works as expected.
Further investigation revealed that this issue relates to this specific code snippet:
https://github.com/bevyengine/bevy/blob/main/crates/bevy_render/src/view/mod.rs#L1087-L1097
Problem
I had set up a scene that behaves as follows:
The intent of this setup is that the color information from Image A is retained, but slowly fades to black over time. Both images were set to use
TextureFormat::Rgba32Float. However, the behavior that I got was that the fade would eventually hit an arbitrary grey value (which changes depending on what gets subtracted fromworking_color), and then it would never progress in fading beyond that point.Further testing revealed that it is only once the colors are modified by less than an arbitrary infinitesimal that this behavior would occur. In the supplied fragment shader code, this problem does not present itself if 0.006 is subtracted.
However, if
Hdris added as a component to both of the camera entities, the fade works as expected.Further investigation revealed that this issue relates to this specific code snippet:
https://github.com/bevyengine/bevy/blob/main/crates/bevy_render/src/view/mod.rs#L1087-L1097