-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Custom Shader Widget #2085
Conversation
8b25fce
to
343302f
Compare
25ecfb5
to
a08eff8
Compare
... and move `Shader` widget to `iced_widget` crate
This is needed for Wasm compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome stuff, @bungoboingo!
I made a bunch of changes here and there, moved some stuff around, and renamed some things. Check out the commit history and let me know what you think!
Amazing progress! Any estimates on when this would be merged? |
@0x7CFE Today or tomorrow, most likely! |
Changes all LGTM! Let's 🚢! |
🌈 Custom Shader Widget
iced_cubes_dot_mp4.mov
This PR implements RFC #23 and adds support for a new type of widget which allows for the use of custom pipelines & shaders embedded directly into your Iced application, using Iced's existing
iced_wgpu
crate! 🥳🎨 Creating a custom shader
If you have the
wgpu
feature enabled for Iced, a custom shader can be created very similarly to aCanvas
:Each shader widget requires a
widget::shader::Program
which holds internal state, provides ways to update the widget based on input events, and defines a special associated type calledPrimitive
.🔺 Primitives
A
Primitive
must implement a new trait,shader::Primitive
. This trait defines how a thePrimitive
will be uploaded to the GPU, and how it will be rendered.This trait gives unique widget-level access to necessary wgpu reference needed to render primitives! Note that due to not knowing the nature of what a custom shader might contain, every
render
call gets access to theCommandEncoder
and must start its own render pass.The
Primitive
trait has access to the underlying custom pipeline storage, appropriately namedStorage
, where users can store & fetch their pipelines to prepare & render their primitives, referenced byTypeID
.Let me know what you think! I've tried to work through few different use cases and hope I've covered all bases. Go forth and shade! 🔢 🌈