three-virtual-geometry
Version:
Virtual geometry for three.js WebGPU: automatic cluster LOD and GPU-driven culling for billions of triangles. Independent implementation, not affiliated with Epic Games.
34 lines (33 loc) • 2.06 kB
TypeScript
/**
* Texture coordinates for materials on a VirtualMesh.
*
* A VirtualMesh pulls its vertices from storage buffers, so its placeholder geometry has no `uv` attribute and
* three's default texture lookups (`uv()`) would read nothing. The vertex stage writes the pulled UV into the
* `vgUv` varying, and `bindVirtualGeometryTextures` points the material's textures at it.
*/
import * as THREE from 'three/webgpu';
type Node = any;
/** Interpolated texture coordinates of the current fragment (vec2), for custom material nodes. */
export declare const vgUv: THREE.PropertyNode<"vec2">;
/** Texture lookup at `vgUv`, with the texture's offset/repeat/rotation applied like three's own maps. */
export declare function vgTexture(map: THREE.Texture): Node;
/**
* Normal map without precomputed tangents: the tangent frame comes from screen-space derivatives of the view
* position and `vgUv` (same construction as three's derivative tangents, http://www.thetenthplanet.de/archives/1180).
*/
export declare function vgNormalMap(map: THREE.Texture, scale: Node, type?: THREE.NormalMapTypes): Node;
/**
* Makes a material's textures sample `vgUv`. Called by VirtualMesh on the material it takes over.
*
* - `map` and `alphaMap` move into `colorNode` (and are cleared on the material): the shadow pass reads
* `colorNode.a` for alpha-tested shadows, but would sample the material's `map` with the missing `uv()`.
* - Normal, bump and clearcoat normal maps become explicit normal nodes, because three builds normals in a
* context that ignores custom UVs.
* - Every other texture lookup without explicit coordinates (roughness, metalness, emissive, AO, light,
* clearcoat, sheen, transmission maps, textures in your own nodes, ...) gets `vgUv` through
* `material.contextNode`. A `getUV` in your own `contextNode` takes precedence.
*
* Nodes the material already has are kept: only properties three would otherwise read implicitly are rewired.
*/
export declare function bindVirtualGeometryTextures(material: THREE.NodeMaterial): void;
export {};