11 Commits
Author SHA1 Message Date
.CooCoo e36f7973da craft-texture: add height to normal and ORM packing over row-read sources (#1403) 2026-11-16 21:32:18 -05:00
FredApps a341e86b6d Merge pull request #1709 from dotCooCoo/feat/craft-texture-axis-sampling
craft-texture: add per-axis wrapping and MaterialCraft's stored sampling
2026-11-16 18:37:03 +01:00
Dylan M. Taylor 8ef4542960 Fix DDS test fixture Header module path 2026-11-15 14:39:53 -05:00
Dylan M. Taylor 726ad0f829 Document DDS result fields and errors 2026-11-15 13:59:20 -05:00
Dylan M. Taylor 2797955187 Cover compressed half-float and first-face DDS behavior 2026-11-15 13:55:19 -05:00
chasse20 eeaa77c081 Share bounded DDS float surface decoding
Adapt MaterialCraft DDS backend integration from cc052aeaa8c61fbe6975674b6d5e28bb3c597b9d; retain float precision and first-surface behavior, keep transfer policy app-local.
2026-11-15 13:54:31 -05:00
dotCooCoo 92fb3fa8ac craft-texture: add per-axis wrapping and MaterialCraft's stored sampling
MaterialCraft's `crates/image` gained per-axis wrap modes and the texture
read of its function graphs. This adds them to craft-texture so the app
can switch to the crate.

- `get_axes`, `sample_axes` and `sample_nearest_axes` take
  `tiling: [bool; 2]`, the wrap mode of `u` and of `v` on their own. With
  equal entries they give the same results as `get`, `sample` and
  `sample_nearest`, which now call them.
- `sample_stored` rounds the bilinear weights to multiples of 1/256 and
  blends by linear interpolation in `f32`. With the image's
  integer-sampling flag on, it clamps each channel to 0..=1 and rounds it
  to a multiple of 1/65535. A channel whose interpolation is not finite
  is taken from the `f64` weighted sum, so finite texels give a finite
  sample.
- `with_integer_sampling` and `integer_sampling` set and read the flag.
  New images start with it off, clones keep it, and `PartialEq` compares
  it.
2026-11-15 10:27:00 -08:00
dotCooCoo 47baffee9d craft-texture: compare images by value whether or not the buffer is shared
Image equality no longer short-cuts on a shared buffer. An image holding
NaN compared equal to its clone but unequal to the same image built
again; it is now unequal to both, as f32 comparison gives.
2026-11-13 19:55:39 -08:00
dotCooCoo 316db97052 craft-texture: keep bilinear samples of finite texels finite
The four weighted texels are summed in f64 and a finite sum is clamped
to the f32 range. Rounded weights can add up to slightly more than 1,
which made a constant image of f32::MAX sample to infinity at some
coordinates. Infinite texels still give an infinite or NaN sample.

The crate docs and README now limit the OutOfMemory guarantee of the
try_ forms to the pixel buffer, and name the Arc and the try_resize
resampler as allocations that are not fallible.
2026-11-13 19:52:40 -08:00
dotCooCoo 261e7a4c5c craft-texture: keep image planes within isize::MAX bytes when limits are raised
With raised Limits, a gray image over 512 MiB could be converted to
color on wasm32, where the color plane needs more than isize::MAX bytes
and vec! panics with capacity overflow.

- Limits::check returns TooLarge when the byte count is over isize::MAX,
  so the try_ forms report the size instead of OutOfMemory.
- map, to_color and to_kind clamp each side to 1..=MAX_SIDE when the
  result would be over isize::MAX bytes, and map the top-left part.
- The size checks are pure functions that take the bound as a value, and
  three tests check them against the 32-bit bound without allocating.
2026-11-13 13:28:35 -08:00
dotCooCoo 3c3a83151d craft-texture: add bounded float image planes and texture sampling
Adds crates/texture (craft-texture), the first step of RFC-0032
(storytold/craft-contrib#50). The code comes from MaterialCraft
crates/image/src/lib.rs at 31330629, with its six tests unchanged. No app
uses the crate yet.

Changes from the source:
- Image fields are private; from_data checks the size and the buffer
  length, so a zero side can no longer reach a panic and a short buffer
  is rejected instead of read with defaults.
- Limits caps the side, pixels and bytes; the try_ constructors and
  try_map, try_to_kind, try_resize and try_to_rgba8_display reserve
  memory first and return an error.
- Repeat sampling reduces the coordinate to its fractional part, so the
  period holds at large coordinates.
- Bilinear sampling sums the four weighted texels and skips zero weights;
  box shrinking sums in f64.
- generate_uv clamps the size before computing pixel centers.
- linear_to_srgb(NaN) returns NaN.
- rayon is behind the parallel feature.
2026-11-13 13:14:55 -08:00