MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / tex_sample_coords

Function tex_sample_coords

tools/bloom-reference/src/main.rs:378–388  ·  view source on GitHub ↗

Shared bilinear coord computation so every texture sampler does the same wrapping and interpolation math.

(tex: &Texture, uv: Vec2)

Source from the content-addressed store, hash-verified

376/// Shared bilinear coord computation so every texture sampler does
377/// the same wrapping and interpolation math.
378fn tex_sample_coords(tex: &Texture, uv: Vec2) -> (i32, i32, f32, f32) {
379 let u = uv.x - uv.x.floor();
380 let v = uv.y - uv.y.floor();
381 let fx = u * tex.width as f32 - 0.5;
382 let fy = v * tex.height as f32 - 0.5;
383 let x0 = fx.floor() as i32;
384 let y0 = fy.floor() as i32;
385 let tx = fx - x0 as f32;
386 let ty = fy - y0 as f32;
387 (x0, y0, tx, ty)
388}
389
390fn srgb_u8_to_linear(c: u8) -> f32 {
391 let s = c as f32 / 255.0;

Callers 2

sample_texture_srgbMethod · 0.85
sample_texture_linearMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected