Nilirad / bevy_prototype_lyon

Draw 2D shapes in Bevy
Apache License 2.0
702 stars 87 forks source link

App crashes if rendering to an HDR texture #177

Closed asafigan closed 2 years ago

asafigan commented 2 years ago

With Bevy 0.9 cameras can render to HDR textures. I tested this with the code on master and the app crashed.

Here is the error:

thread 'main' panicked at 'wgpu error: Validation Error

Caused by:
    In a RenderPass
      note: encoder = `<CommandBuffer-(0, 1, Vulkan)>`
    In a set_pipeline command
      note: render pipeline = `shape_pipeline`
    Render pipeline targets are incompatible with render pass
    Incompatible color attachment: the renderpass expected [Some(Rgba16Float)] but was given [Some(Rgba8UnormSrgb)]

This is caused by the target color texture format being hard coded as TextureFormat::bevy_default(). I changed the hard coded value to Rgba16Float in a local clone of this repo and it fixed the problem, but obviously would cause crashes for none HDR cameras.

Unfortunately I'm not familiar enough with the Bevy render pipeline to figure out how to determine the correct format at runtime. I believe you would have to specialize the mesh2d pipeline but I don't know how. It might be easier to replace the current rendering implementation with one of the newer high level material APIs.