ComputeMipAwareBlueNoise
new ComputeMipAwareBlueNoise(width : number, height : number, mipScaleExponent : number)Generates a mip-aware blue noise texture using the Hilbert R1 blue noise algorithm.
Overview Blue noise textures are essential for high-quality rendering techniques such as:
- Dithering: Reducing quantization artifacts in gradients.
- Stochastic Sampling: Monte Carlo integration, soft shadows, and ambient occlusion.
- Temporal Anti-Aliasing (TAA): Providing stable, high-frequency noise that integrates well over time.
Features
- Mip-Awareness: Generates noise that remains blue (high-frequency) across mip levels, preventing aliasing artifacts when the texture is minified.
- Hilbert R1 Algorithm: Uses a low-discrepancy sequence mapped to a Hilbert curve for optimal spatial distribution.
- GPU Generation: Fully computed on the GPU for fast initialization.
Constructor Parameters
widthoptionalnumberWidth of the texture in pixels.
Default is
Default is
128.heightoptionalnumberHeight of the texture in pixels.
Default is
Default is
128.mipScaleExponentoptionalnumberControls the scaling of noise coordinates across mip levels.
1.0: Standard scaling (doubles frequency per level).0.5: Slower scaling, preserving larger structures.
Default is
1.0.Example
import { ComputeMipAwareBlueNoise } from '@three-blocks/core';
// Create generator
const blueNoiseGen = new ComputeMipAwareBlueNoise(512, 512);
// Generate texture (async GPU operation)
const blueNoiseTexture = await blueNoiseGen.init(renderer);
// Use in a material
const material = new THREE.MeshBasicNodeMaterial();
material.colorNode = texture(blueNoiseTexture, uv().mul(10));Properties
# .storageTexture : THREE.StorageTexture|null
Methods
init#
init(renderer : THREE.WebGPURenderer) : THREE.StorageTextureInitializes and generates the blue noise texture using compute shaders. This method must be called before using the texture.
Parameters
rendererTHREE.WebGPURendererThe WebGPU renderer instance used for computation.
Returns
THREE.StorageTexture — The generated storage texture.getTexture#
getTexture() : THREE.StorageTexture|nullReturns the generated blue noise texture.
Returns
THREE.StorageTexture | null — The generated texture, or null if init() has not been called.