https://github.com/w23/iced-fragment-shader-widget-example
Minimalistic example of drawing iced custom shader widget using a single fragment shader
https://github.com/w23/iced-fragment-shader-widget-example
custom-widget fragment-shader iced rust wgpu wgpu-rs wgsl wgsl-shader widget
Last synced: 5 months ago
JSON representation
Minimalistic example of drawing iced custom shader widget using a single fragment shader
- Host: GitHub
- URL: https://github.com/w23/iced-fragment-shader-widget-example
- Owner: w23
- License: unlicense
- Created: 2024-04-01T18:08:10.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-04-01T18:09:27.000Z (over 1 year ago)
- Last Synced: 2025-04-01T06:27:40.362Z (6 months ago)
- Topics: custom-widget, fragment-shader, iced, rust, wgpu, wgpu-rs, wgsl, wgsl-shader, widget
- Language: Rust
- Homepage:
- Size: 5.86 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Custom fragment shader widget example for iced
A minimalistic example of making [iced](https://iced.rs/) custom shader widget draw its contents using just a fragment shader. This provides reasonably fast access to writing arbitrary pixels into widget's canvas, something that iced custom canvas widget struggles with.
This example consists of:
- Iced boilerplate code for creating, updating, and drawing custom shader widget.
- [Wgpu](https://wgpu.rs/) pipeline creation for a simple single-triangle pipeline without any buffers for vertex data.
- [Wgsl](https://www.w3.org/TR/WGSL/) shader file including both vertex and fragment shader code.
- vertex shader generates 3 vertices coordinates based on `vertex_index` to make a triangle that fills the entire viewport.
- fragment shader draws a pannable/zoomable mandelbrot set as a trivial example
- Mouse event handling that updates widget state. This state is then passed into the shader as uniform data.