@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
31 lines (24 loc) • 764 B
JavaScript
import { ClampToEdgeWrapping, DataTexture, FloatType, NearestFilter, RGFormat } from "three";
/**
*
* @param {number} resolution
* @returns {DataTexture}
*/
export function makeOctahedralDepthAtlas(resolution = 4096) {
const texture = new DataTexture(
new Float32Array(resolution * resolution * 2),
resolution,
resolution,
RGFormat,
FloatType
);
texture.minFilter = texture.magFilter = NearestFilter;
texture.wrapT = ClampToEdgeWrapping;
texture.wrapS = ClampToEdgeWrapping;
texture.flipY = false;
texture.generateMipmaps = false;
texture.unpackAlignment = 4;
texture.internalFormat = "RG32F";
texture.needsUpdate = true;
return texture;
}