PistonDevelopers / conrod

An easy-to-use, 2D GUI library written entirely in Rust.
Other
3.35k stars 297 forks source link

Add Drop Shadows #1105

Open mitchmindtree opened 6 years ago

mitchmindtree commented 6 years ago

It would be nice if certain widgets could opt-in to displaying a drop-shadow on top of whatever surface is below them.

One way of implementing this in a portable manner might be to triangulate from the widget's edges toward the direction of the drop shadow with the given length. If the DropShadow is added as a primitive widget, a new PrimitiveKind could be added to allow the rendering backend to distinguish it from other primitives. Each DropShadow would be emitted by the Primitives iterator prior to all other widgets at the depth of the widget causing the drop shadow.

A gradient can be drawn from BLACK to TRANSPARENT and the fragment shader can be used to adjust the curve of the gradient (by multiplying the luminance to some power for example) and to add a blur effect (using some basic, fast noise function). The frag shader can be notified which vertices are intended to be drawn as shadows by adding another constant to the existing mode vertex attribute. This way shadows could still be drawn in the same pass as the rest of the geometry and text.

ales-tsurko commented 6 years ago

What's the state of this feature?

mitchmindtree commented 6 years ago

This issue is as much as I've had a chance to do! I'd be happy to review any PRs that want to have a go at this, otherwise it's not particularly high on my priority list at the moment so I can't really give a prediction on when I'll get around to it yet.