17cupsofcoffee / tetra

🎮 A simple 2D game framework written in Rust
MIT License
909 stars 63 forks source link

Add hdr option to CanvasBuilder #274

Closed davideGiovannini closed 2 years ago

davideGiovannini commented 3 years ago

Added the possibility of creating Canvas that use RGBA16F as internal format, in order to have effects like HDR and Bloom.


let canvas = Canvas::builder(width, height).hdr(true).build(ctx)?;
17cupsofcoffee commented 3 years ago

I would be open to adding something like this! I would like to add more comprensive support for alternate texture formats in the future, so I'll need to give a little thought to how this would mesh with that, but the idea seems reasonable enough.

17cupsofcoffee commented 3 years ago

Just a quick update - I've not forgotten about this PR!

I spent a bit of time earlier this month trying to hack together some proper support for texture formats, and got something basic working, but the code's a bit of a mess and I haven't had time to finish it off.

Once I've got a better idea of what that API's going to look like, I'll take another look at this PR and see if it still makes sense. It could be that we'll still want a hdr method, but as a shortcut for the more flexible API - we'll see :)

17cupsofcoffee commented 2 years ago

Sorry for the delay in resolving this, been a busy few months! I have pushed a first pass at implementing this to the 0.7 branch - it is exposed via a texture_format method on CanvasBuilder, which you can now pass TextureFormat::Rgba16F to. Please give this a try and let me know if works for you :)

davideGiovannini commented 2 years ago

Works perfectly! :smile: