Skip to content

Minimalistic example of drawing iced custom shader widget using a single fragment shader

License

Notifications You must be signed in to change notification settings

w23/iced-fragment-shader-widget-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom fragment shader widget example for iced

A minimalistic example of making iced 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 pipeline creation for a simple single-triangle pipeline without any buffers for vertex data.
  • 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.

About

Minimalistic example of drawing iced custom shader widget using a single fragment shader

Topics

Resources

License

Stars

Watchers

Forks