Ring noise functions - sample three z-slices for independent component evolution
| 25 | |
| 26 | /// Ring noise functions - sample three z-slices for independent component evolution |
| 27 | HSV16 noiseRingHSV16(float angle, u32 time, float radius) { |
| 28 | // Convert angle to cartesian coordinates |
| 29 | float x = fl::cosf(angle); |
| 30 | float y = fl::sinf(angle); |
| 31 | |
| 32 | // Map sin/cos values from [-1, 1] to [0, 0xFFFF] |
| 33 | // This ensures positive values for uint32_t conversion |
| 34 | u32 nx = static_cast<u32>((x + 1.0f) * 0.5f * radius * 0xffff); |
| 35 | u32 ny = static_cast<u32>((y + 1.0f) * 0.5f * radius * 0xffff); |
| 36 | |
| 37 | // Sample three different z-slices for H, S, V components |
| 38 | // Using offsets 0x0, 0x10000, 0x20000 to separate them in noise space |
| 39 | u16 h_raw = inoise16(nx, ny, time); |
| 40 | u16 s_raw = inoise16(nx, ny, time + 0x10000); |
| 41 | u16 v_raw = inoise16(nx, ny, time + 0x20000); |
| 42 | |
| 43 | // Rescale from observed noise range to full 0-65535 range using global extents |
| 44 | u16 h = rescaleNoiseValue16(h_raw); |
| 45 | u16 s = rescaleNoiseValue16(s_raw); |
| 46 | u16 v = rescaleNoiseValue16(v_raw); |
| 47 | |
| 48 | return HSV16(h, s, v); |
| 49 | } |
| 50 | |
| 51 | CHSV noiseRingHSV8(float angle, u32 time, float radius) { |
| 52 | fl::HSV16 hsv16 = noiseRingHSV16(angle, time, radius); |
no test coverage detected