Shared bilinear coord computation so every texture sampler does the same wrapping and interpolation math.
(tex: &Texture, uv: Vec2)
| 376 | /// Shared bilinear coord computation so every texture sampler does |
| 377 | /// the same wrapping and interpolation math. |
| 378 | fn 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 | |
| 390 | fn srgb_u8_to_linear(c: u8) -> f32 { |
| 391 | let s = c as f32 / 255.0; |
no outgoing calls
no test coverage detected