Parameters
| Name | Type | Description |
|---|---|---|
| x | f32 | Input position. |
| frequency | f32 | Wave frequency. |
| amplitude | f32 | Wave amplitude. |
| phase | f32 | Phase offset. |
| width | f32 | Pulse width (0-1). |
| falloff | f32 | Smooth falloff duration. |
Returns
f32wave value.
WGSL Code
fn pulseWave(x: f32, frequency: f32, amplitude: f32, phase: f32, width: f32, falloff: f32) -> f32 { let t = x * frequency + phase; let tt = fract(t); // Create a pulse with smooth edges var pulse = 0.0; // If tt is within the width, pulse is 1.0 if (tt < width) { pulse = 1.0; } else if (tt < width + falloff) { // Smooth falloff pulse = 1.0 - (tt - width) / falloff; } return pulse * amplitude; }