dither_float

Function dither_float 

Source
pub fn dither_float<Src, Dest>(value: Src, index: u32, seed: u32) -> Dest
Expand description

Dither a float value when converting to lower precision using default hash method.

This reduces quantization artifacts like banding in smooth gradients when converting between floating-point types (e.g., f32 to f16, f64 to f32).

ยงExample

use dithereens::dither_float;

let value: f32 = 1.234567;
let result: f16 = dither_float(value, 0, 42);
use dithereens::dither_float;

let value: f64 = 1.234567890123456;
let result: f32 = dither_float(value, 0, 42);