File tree Expand file tree Collapse file tree 3 files changed +8
-11
lines changed Expand file tree Collapse file tree 3 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -823,14 +823,12 @@ impl Image {
823
823
/// Create a new zero-filled image with a given size, which can be rendered to. This is primarily
824
824
/// for use as a render target for a [`Camera`]. See [`RenderTarget::Image`].
825
825
///
826
+ /// You can use [TEXTURE_FORMAT_SDR] and [TEXTURE_FORMAT_HDR]
827
+ /// for Standard Dynamic Range (SDR) and High Dynamic Range (HDR) respectively.
828
+ ///
826
829
/// [`Camera`]: https://docs.rs/bevy/latest/bevy/render/camera/struct.Camera.html
827
830
/// [`RenderTarget::Image`]: https://docs.rs/bevy/latest/bevy/render/camera/enum.RenderTarget.html#variant.Image
828
- pub fn new_target_texture ( width : u32 , height : u32 , hdr : bool ) -> Self {
829
- let format = if hdr {
830
- TEXTURE_FORMAT_HDR
831
- } else {
832
- TEXTURE_FORMAT_SDR
833
- } ;
831
+ pub fn new_target_texture ( width : u32 , height : u32 , format : TextureFormat ) -> Self {
834
832
let size = Extent3d {
835
833
width,
836
834
height,
@@ -844,7 +842,7 @@ impl Image {
844
842
let data = vec ! [ 0 ; format. pixel_size( ) * size. volume( ) ] ;
845
843
846
844
Image {
847
- data,
845
+ data : Some ( data ) ,
848
846
texture_descriptor : TextureDescriptor {
849
847
size,
850
848
format,
Original file line number Diff line number Diff line change 2
2
3
3
use std:: f32:: consts:: PI ;
4
4
5
- use bevy:: { prelude:: * , render:: view:: RenderLayers } ;
5
+ use bevy:: { image :: TEXTURE_FORMAT_SDR , prelude:: * , render:: view:: RenderLayers } ;
6
6
7
7
fn main ( ) {
8
8
App :: new ( )
@@ -27,7 +27,7 @@ fn setup(
27
27
mut images : ResMut < Assets < Image > > ,
28
28
) {
29
29
// This is the texture that will be rendered to.
30
- let image = Image :: new_target_texture ( 512 , 512 , false ) ;
30
+ let image = Image :: new_target_texture ( 512 , 512 , TEXTURE_FORMAT_SDR ) ;
31
31
32
32
let image_handle = images. add ( image) ;
33
33
Original file line number Diff line number Diff line change @@ -51,9 +51,8 @@ fn main() {
51
51
}
52
52
53
53
fn setup ( mut commands : Commands , mut images : ResMut < Assets < Image > > ) {
54
- let mut image = Image :: new_target_texture ( SIZE . 0 , SIZE . 1 , false ) ;
54
+ let mut image = Image :: new_target_texture ( SIZE . 0 , SIZE . 1 , TextureFormat :: R32Float ) ;
55
55
image. asset_usage = RenderAssetUsages :: RENDER_WORLD ;
56
- image. texture_descriptor . format = TextureFormat :: R32Float ;
57
56
image. texture_descriptor . usage =
58
57
TextureUsages :: COPY_DST | TextureUsages :: STORAGE_BINDING | TextureUsages :: TEXTURE_BINDING ;
59
58
let image0 = images. add ( image. clone ( ) ) ;
You can’t perform that action at this time.
0 commit comments