bevyengine / bevyengine/bevy

Rendering to texture requires RenderAssetUsages::default()

Open
#18,908 0 comments 0 reactions 0 assignees View on GitHub
A-Assets A-Rendering C-Bug
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version

Latest main @ 12f71a8936c77735b6f702b1ef849dfc8a306a37

## \[Optional\] Relevant system information

```
2025-04-23T18:00:48.078539Z INFO log: SystemInfo { os: "Windows 10 Home", kernel: "19045", cpu: "Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz", core_count: "6", memory: "63.9 GiB" }
2025-04-23T18:00:48.408691Z INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce GTX 1080 Ti", vendor: 4318, device: 6918, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "560.94", backend: Vulkan }
2025-04-23T18:00:48.632350Z INFO bevy_render::batching::gpu_preprocessing: GPU preprocessing is fully supported on this device.
```

## What you did

Modify line 48 of example `render_to_texture.rs`

```diff
// This is the texture that will be rendered to.
let mut image = Image::new_fill(
size,
TextureDimension::D2,
&[0, 0, 0, 0],
TextureFormat::Bgra8UnormSrgb,
- RenderAssetUsages::default(),
+ RenderAssetUsages::RENDER_WORLD,
);
```

## What went wrong

Although this example doesn't seem to be accessing the image from the CPU after creation:

With `RenderAssetUsages::default()` (`RenderAssetUsages::MAIN_WORLD | RenderAssetUsages::RENDER_WORLD`) the image renders as expected:

![image](https://github.com/user-attachments/assets/233da1ae-81a6-4d47-ba57-edbfbe87cc2d)

But with only `RenderAssetUsages::RENDER_WORLD` the cube in the first pass image isn't rendering correctly:

![image](https://github.com/user-attachments/assets/666e8821-f3a2-4a0e-959a-b79b9486a08d)

## Additional information

More context where it was discovered in this PR: https://github.com/bevyengine/bevy/pull/17209#discussion_r2056431938

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.