hecrj / coffee

An opinionated 2D game engine for Rust
https://docs.rs/coffee
MIT License
1.08k stars 55 forks source link

Drawing sprites with custom alpha values #115

Open xFrednet opened 4 years ago

xFrednet commented 4 years ago

Good morning,

I have a small question about texture rendering. I want to create a fading effect where a texture get more transparent the more you zoom in to it. Sadly I can't find a function for that. Is it currently possible to draw a texture with a set alpha value?

I've also taken a look at some other tickets and I found this one: #1. Would it maybe be possible to add a fading effect with the color attribute if it would be implemented?

Keep up the good work this is an awesome crate :)

hecrj commented 4 years ago

Hey @xFrednet, thank you!

I've also taken a look at some other tickets and I found this one: #1. Would it maybe be possible to add a fading effect with the color attribute if it would be implemented?

That is correct. This is very basic functionality that is currently missing. It should be quite easy to implement, but I haven't got to it because adding color and rotation to each quad instance will potentially affect performance and I would like to explore different implementations.

xFrednet commented 4 years ago

Thank you for the quick response @hecrj. I was hoping that to hear something like that :).

Just out of interest what is the current state on the implementation? Have you already explored some ways?

hecrj commented 4 years ago

@xFrednet I haven't really started. I am currently focusing heavily on iced. I will come back to Coffee soon! Most likely once the new winit minor version is properly released.

The easiest way to implement this is to change the quad pipelines in the different graphics backends. Specifically, the instance definitions here and here. Then, it should be a matter of updating the shaders, doing a bit of compiler-driven development and exposing the new attributes in theQuad struct.