bakeNoiseTexture function Noise

Texture2D bakeNoiseTexture(
  1. FastNoiseLite noise, {
  2. required int width,
  3. required int height,
  4. double originX = 0.0,
  5. double originY = 0.0,
  6. double cellSize = 1.0,
  7. TextureSampling sampling = const TextureSampling(),
})

Bakes noise into a grayscale Texture2D, ready to bind as a material sampler.

A convenience over bakeNoisePixels plus Texture2D.fromPixels; must run where GPU resources may be created (the raster thread). Content is linear data, so mipmaps (when sampling enables them) average directly.

Implementation

Texture2D bakeNoiseTexture(
  FastNoiseLite noise, {
  required int width,
  required int height,
  double originX = 0.0,
  double originY = 0.0,
  double cellSize = 1.0,
  TextureSampling sampling = const TextureSampling(),
}) {
  return Texture2D.fromPixels(
    bakeNoisePixels(
      noise,
      width: width,
      height: height,
      originX: originX,
      originY: originY,
      cellSize: cellSize,
    ),
    width,
    height,
    content: TextureContent.data,
    sampling: sampling,
  );
}