UNPKG

3.93 kBTypeScriptView Raw
1import { WebGLRenderer } from "../renderers/WebGLRenderer.js";
2import { WebGLRenderTarget } from "../renderers/WebGLRenderTarget.js";
3import { Scene } from "../scenes/Scene.js";
4import { CubeTexture } from "../textures/CubeTexture.js";
5import { Texture } from "../textures/Texture.js";
6
7/**
8 * This class generates a Prefiltered, Mipmapped Radiance Environment Map (PMREM) from a cubeMap environment texture.
9 * @remarks
10 * This allows different levels of blur to be quickly accessed based on material roughness
11 * Unlike a traditional mipmap chain, it only goes down to the LOD_MIN level (above), and then creates extra even more filtered 'mips' at the same LOD_MIN resolution,
12 * associated with higher roughness levels
13 * In this way we maintain resolution to smoothly interpolate diffuse lighting while limiting sampling computation.
14 * @remarks
15 * Note: The minimum {@link THREE.MeshStandardMaterial | MeshStandardMaterial}'s roughness depends on the size of the provided texture
16 * If your render has small dimensions or the shiny parts have a lot of curvature, you may still be able to get away with a smaller texture size.
17 *
18 * | texture size | minimum roughness |
19 * |--------------|--------------------|
20 * | 16 | 0.21 |
21 * | 32 | 0.15 |
22 * | 64 | 0.11 |
23 * | 128 | 0.076 |
24 * | 256 | 0.054 |
25 * | 512 | 0.038 |
26 * | 1024 | 0.027 |
27 *
28 * @see {@link https://threejs.org/docs/index.html#api/en/extras/PMREMGenerator | Official Documentation}
29 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/PMREMGenerator.js | Source}
30 */
31export class PMREMGenerator {
32 /**
33 * This constructor creates a new PMREMGenerator.
34 * @param renderer
35 */
36 constructor(renderer: WebGLRenderer);
37
38 /**
39 * Generates a PMREM from a supplied Scene, which can be faster than using an image if networking bandwidth is low
40 * @remarks
41 * Optional near and far planes ensure the scene is rendered in its entirety (the cubeCamera is placed at the origin).
42 * @param scene The given scene.
43 * @param sigma Specifies a blur radius in radians to be applied to the scene before PMREM generation. Default `0`.
44 * @param near The near plane value. Default `0.1`.
45 * @param far The far plane value. Default `100`.
46 */
47 fromScene(scene: Scene, sigma?: number, near?: number, far?: number): WebGLRenderTarget;
48
49 /**
50 * Generates a PMREM from an equirectangular texture, which can be either LDR or HDR. The ideal input image size is
51 * 1k (1024 x 512), as this matches best with the 256 x 256 cubemap output. The smallest supported equirectangular
52 * image size is 64 x 32.
53 */
54 fromEquirectangular(equirectangular: Texture, renderTarget?: WebGLRenderTarget | null): WebGLRenderTarget;
55
56 /**
57 * Generates a PMREM from an cubemap texture, which can be either LDR or HDR. The ideal input cube size is
58 * 256 x 256, as this matches best with the 256 x 256 cubemap output. The smallest supported cube size is 16 x 16.
59 */
60 fromCubemap(cubemap: CubeTexture, renderTarget?: WebGLRenderTarget | null): WebGLRenderTarget;
61
62 /**
63 * Pre-compiles the cubemap shader
64 * @remarks
65 * You can get faster start-up by invoking this method during your texture's network fetch for increased concurrency.
66 */
67 compileCubemapShader(): void;
68
69 /**
70 * Pre-compiles the equirectangular shader
71 * @remarks
72 * You can get faster start-up by invoking this method during your texture's network fetch for increased concurrency.
73 */
74 compileEquirectangularShader(): void;
75
76 /**
77 * Frees the GPU-related resources allocated by this instance
78 * @remarks
79 * Call this method whenever this instance is no longer used in your app.
80 */
81 dispose(): void;
82}