howtos
This folder contains small examples that illustrate individual
concepts / techniques. The howtos in this directory are presented in a
few different ways:
- The
main.verbose.js file in each demo contains both the
WebGPU JavaScript and all the WGSL shaders (in JS strings) in a single,
heavily commented file. These files are the best places to go to
understand how gulls work.
- When viewing each demo, you can switch between the various
JavaScript files and shader files used.
- the
main.js, frag.wgsl, and
compute.wgsl files are minimal, non-commented files that
are designed to be terse and readable.
- Simplest
- the smallest gulls project needed to get a fullscreen fragment
shader presented on screen.
- One
Uniform - adding a single uniform to a fragment shader, and
setting up the CPU to use it for communication with the GPU
- Using
coordinates - by passing the canvas resolution to our shader as
a uniform, we can create normalized coordinates for each pixel we’re
operating on.
- Mouse
coordinates - sending mouse position and left click status to
the fragment shader as a uniform
- Tweakpane
using the Tweakpane system to add a GUI to control our shader
- Audio
- using the Audio helper to send FFT analysis of incoming audio to
gulls to the fragment shader.
- Read
texture - Read from a texture.
- Feedback
- a simple mouse-driven feedback example.
- Video
Feedback - how to use live video feeds + feedback together
- Simplest
Compute - Using a compute shader to incremeent a single number,
which in turn is used to determine the color of all pixels in a fragment
shader.
- Compute
with position - Performing compute shader computations for
every pixel on the screen.
- Particle
- A single instanced particle drawn with a vertex shader.
- Many
particles - Many particles driven by compute + vertex
shaders.
- Post-processing
- Demonstrates how to render to texture and then color process the
results.
- Multipass
post-processing -A two-pass gaussian blur post-processing
effect.