123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773 |
- import NodeMaterial from '../../../nodes/materials/NodeMaterial.js';
- import { getDirection, blur } from '../../../nodes/pmrem/PMREMUtils.js';
- import { equirectUV } from '../../../nodes/utils/EquirectUVNode.js';
- import { uniform } from '../../../nodes/core/UniformNode.js';
- import { uniforms } from '../../../nodes/accessors/UniformsNode.js';
- import { texture } from '../../../nodes/accessors/TextureNode.js';
- import { cubeTexture } from '../../../nodes/accessors/CubeTextureNode.js';
- import { float, vec3 } from '../../../nodes/shadernode/ShaderNode.js';
- import { uv } from '../../../nodes/accessors/UVNode.js';
- import { attribute } from '../../../nodes/core/AttributeNode.js';
- import {
- OrthographicCamera,
- Color,
- Vector3,
- BufferGeometry,
- BufferAttribute,
- RenderTarget,
- Mesh,
- CubeReflectionMapping,
- CubeRefractionMapping,
- CubeUVReflectionMapping,
- LinearFilter,
- NoBlending,
- RGBAFormat,
- HalfFloatType,
- BackSide,
- LinearSRGBColorSpace,
- PerspectiveCamera,
- MeshBasicMaterial,
- BoxGeometry
- } from 'three';
- const LOD_MIN = 4;
- // The standard deviations (radians) associated with the extra mips. These are
- // chosen to approximate a Trowbridge-Reitz distribution function times the
- // geometric shadowing function. These sigma values squared must match the
- // variance #defines in cube_uv_reflection_fragment.glsl.js.
- const EXTRA_LOD_SIGMA = [ 0.125, 0.215, 0.35, 0.446, 0.526, 0.582 ];
- // The maximum length of the blur for loop. Smaller sigmas will use fewer
- // samples and exit early, but not recompile the shader.
- const MAX_SAMPLES = 20;
- const _flatCamera = /*@__PURE__*/ new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
- const _cubeCamera = /*@__PURE__*/ new PerspectiveCamera( 90, 1 );
- const _clearColor = /*@__PURE__*/ new Color();
- let _oldTarget = null;
- let _oldActiveCubeFace = 0;
- let _oldActiveMipmapLevel = 0;
- // Golden Ratio
- const PHI = ( 1 + Math.sqrt( 5 ) ) / 2;
- const INV_PHI = 1 / PHI;
- // Vertices of a dodecahedron (except the opposites, which represent the
- // same axis), used as axis directions evenly spread on a sphere.
- const _axisDirections = [
- /*@__PURE__*/ new Vector3( - PHI, INV_PHI, 0 ),
- /*@__PURE__*/ new Vector3( PHI, INV_PHI, 0 ),
- /*@__PURE__*/ new Vector3( - INV_PHI, 0, PHI ),
- /*@__PURE__*/ new Vector3( INV_PHI, 0, PHI ),
- /*@__PURE__*/ new Vector3( 0, PHI, - INV_PHI ),
- /*@__PURE__*/ new Vector3( 0, PHI, INV_PHI ),
- /*@__PURE__*/ new Vector3( - 1, 1, - 1 ),
- /*@__PURE__*/ new Vector3( 1, 1, - 1 ),
- /*@__PURE__*/ new Vector3( - 1, 1, 1 ),
- /*@__PURE__*/ new Vector3( 1, 1, 1 )
- ];
- //
- // WebGPU Face indices
- const _faceLib = [
- 3, 1, 5,
- 0, 4, 2
- ];
- const direction = getDirection( uv(), attribute( 'faceIndex' ) ).normalize();
- const outputDirection = vec3( direction.x, direction.y.negate(), direction.z );
- /**
- * This class generates a Prefiltered, Mipmapped Radiance Environment Map
- * (PMREM) from a cubeMap environment texture. This allows different levels of
- * blur to be quickly accessed based on material roughness. It is packed into a
- * special CubeUV format that allows us to perform custom interpolation so that
- * we can support nonlinear formats such as RGBE. 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, associated with
- * higher roughness levels. In this way we maintain resolution to smoothly
- * interpolate diffuse lighting while limiting sampling computation.
- *
- * Paper: Fast, Accurate Image-Based Lighting
- * https://drive.google.com/file/d/15y8r_UpKlU9SvV4ILb0C3qCPecS8pvLz/view
- */
- class PMREMGenerator {
- constructor( renderer ) {
- this._renderer = renderer;
- this._pingPongRenderTarget = null;
- this._lodMax = 0;
- this._cubeSize = 0;
- this._lodPlanes = [];
- this._sizeLods = [];
- this._sigmas = [];
- this._lodMeshes = [];
- this._blurMaterial = null;
- this._cubemapMaterial = null;
- this._equirectMaterial = null;
- this._backgroundBox = null;
- }
- /**
- * Generates a PMREM from a supplied Scene, which can be faster than using an
- * image if networking bandwidth is low. Optional sigma specifies a blur radius
- * in radians to be applied to the scene before PMREM generation. Optional near
- * and far planes ensure the scene is rendered in its entirety (the cubeCamera
- * is placed at the origin).
- */
- fromScene( scene, sigma = 0, near = 0.1, far = 100 ) {
- _oldTarget = this._renderer.getRenderTarget();
- _oldActiveCubeFace = this._renderer.getActiveCubeFace();
- _oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();
- this._setSize( 256 );
- const cubeUVRenderTarget = this._allocateTargets();
- cubeUVRenderTarget.depthBuffer = true;
- this._sceneToCubeUV( scene, near, far, cubeUVRenderTarget );
- if ( sigma > 0 ) {
- this._blur( cubeUVRenderTarget, 0, 0, sigma );
- }
- this._applyPMREM( cubeUVRenderTarget );
- this._cleanup( cubeUVRenderTarget );
- return cubeUVRenderTarget;
- }
- /**
- * Generates a PMREM from an equirectangular texture, which can be either LDR
- * or HDR. The ideal input image size is 1k (1024 x 512),
- * as this matches best with the 256 x 256 cubemap output.
- */
- fromEquirectangular( equirectangular, renderTarget = null ) {
- return this._fromTexture( equirectangular, renderTarget );
- }
- /**
- * Generates a PMREM from an cubemap texture, which can be either LDR
- * or HDR. The ideal input cube size is 256 x 256,
- * as this matches best with the 256 x 256 cubemap output.
- */
- fromCubemap( cubemap, renderTarget = null ) {
- return this._fromTexture( cubemap, renderTarget );
- }
- /**
- * Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during
- * your texture's network fetch for increased concurrency.
- */
- compileCubemapShader() {
- if ( this._cubemapMaterial === null ) {
- this._cubemapMaterial = _getCubemapMaterial();
- this._compileMaterial( this._cubemapMaterial );
- }
- }
- /**
- * Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during
- * your texture's network fetch for increased concurrency.
- */
- compileEquirectangularShader() {
- if ( this._equirectMaterial === null ) {
- this._equirectMaterial = _getEquirectMaterial();
- this._compileMaterial( this._equirectMaterial );
- }
- }
- /**
- * Disposes of the PMREMGenerator's internal memory. Note that PMREMGenerator is a static class,
- * so you should not need more than one PMREMGenerator object. If you do, calling dispose() on
- * one of them will cause any others to also become unusable.
- */
- dispose() {
- this._dispose();
- if ( this._cubemapMaterial !== null ) this._cubemapMaterial.dispose();
- if ( this._equirectMaterial !== null ) this._equirectMaterial.dispose();
- if ( this._backgroundBox !== null ) {
- this._backgroundBox.geometry.dispose();
- this._backgroundBox.material.dispose();
- }
- }
- // private interface
- _setSize( cubeSize ) {
- this._lodMax = Math.floor( Math.log2( cubeSize ) );
- this._cubeSize = Math.pow( 2, this._lodMax );
- }
- _dispose() {
- if ( this._blurMaterial !== null ) this._blurMaterial.dispose();
- if ( this._pingPongRenderTarget !== null ) this._pingPongRenderTarget.dispose();
- for ( let i = 0; i < this._lodPlanes.length; i ++ ) {
- this._lodPlanes[ i ].dispose();
- }
- }
- _cleanup( outputTarget ) {
- this._renderer.setRenderTarget( _oldTarget, _oldActiveCubeFace, _oldActiveMipmapLevel );
- outputTarget.scissorTest = false;
- _setViewport( outputTarget, 0, 0, outputTarget.width, outputTarget.height );
- }
- _fromTexture( texture, renderTarget ) {
- if ( texture.mapping === CubeReflectionMapping || texture.mapping === CubeRefractionMapping ) {
- this._setSize( texture.image.length === 0 ? 16 : ( texture.image[ 0 ].width || texture.image[ 0 ].image.width ) );
- } else { // Equirectangular
- this._setSize( texture.image.width / 4 );
- }
- _oldTarget = this._renderer.getRenderTarget();
- _oldActiveCubeFace = this._renderer.getActiveCubeFace();
- _oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();
- const cubeUVRenderTarget = renderTarget || this._allocateTargets();
- this._textureToCubeUV( texture, cubeUVRenderTarget );
- this._applyPMREM( cubeUVRenderTarget );
- this._cleanup( cubeUVRenderTarget );
- return cubeUVRenderTarget;
- }
- _allocateTargets() {
- const width = 3 * Math.max( this._cubeSize, 16 * 7 );
- const height = 4 * this._cubeSize;
- const params = {
- magFilter: LinearFilter,
- minFilter: LinearFilter,
- generateMipmaps: false,
- type: HalfFloatType,
- format: RGBAFormat,
- colorSpace: LinearSRGBColorSpace,
- //depthBuffer: false
- };
- const cubeUVRenderTarget = _createRenderTarget( width, height, params );
- if ( this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== width || this._pingPongRenderTarget.height !== height ) {
- if ( this._pingPongRenderTarget !== null ) {
- this._dispose();
- }
- this._pingPongRenderTarget = _createRenderTarget( width, height, params );
- const { _lodMax } = this;
- ( { sizeLods: this._sizeLods, lodPlanes: this._lodPlanes, sigmas: this._sigmas, lodMeshes: this._lodMeshes } = _createPlanes( _lodMax ) );
- this._blurMaterial = _getBlurShader( _lodMax, width, height );
- }
- return cubeUVRenderTarget;
- }
- _compileMaterial( material ) {
- const tmpMesh = this._lodMeshes[ 0 ];
- tmpMesh.material = material;
- this._renderer.compile( tmpMesh, _flatCamera );
- }
- _sceneToCubeUV( scene, near, far, cubeUVRenderTarget ) {
- const cubeCamera = _cubeCamera;
- cubeCamera.near = near;
- cubeCamera.far = far;
- // px, py, pz, nx, ny, nz
- const upSign = [ - 1, 1, - 1, - 1, - 1, - 1 ];
- const forwardSign = [ 1, 1, 1, - 1, - 1, - 1 ];
- const renderer = this._renderer;
- const originalAutoClear = renderer.autoClear;
- renderer.getClearColor( _clearColor );
- renderer.autoClear = false;
- let backgroundBox = this._backgroundBox;
- if ( backgroundBox === null ) {
- const backgroundMaterial = new MeshBasicMaterial( {
- name: 'PMREM.Background',
- side: BackSide,
- depthWrite: false,
- depthTest: false
- } );
- backgroundBox = new Mesh( new BoxGeometry(), backgroundMaterial );
- }
- let useSolidColor = false;
- const background = scene.background;
- if ( background ) {
- if ( background.isColor ) {
- backgroundBox.material.color.copy( background );
- scene.background = null;
- useSolidColor = true;
- }
- } else {
- backgroundBox.material.color.copy( _clearColor );
- useSolidColor = true;
- }
- renderer.setRenderTarget( cubeUVRenderTarget );
- renderer.clear();
- if ( useSolidColor ) {
- renderer.render( backgroundBox, cubeCamera );
- }
- for ( let i = 0; i < 6; i ++ ) {
- const col = i % 3;
- if ( col === 0 ) {
- cubeCamera.up.set( 0, upSign[ i ], 0 );
- cubeCamera.lookAt( forwardSign[ i ], 0, 0 );
- } else if ( col === 1 ) {
- cubeCamera.up.set( 0, 0, upSign[ i ] );
- cubeCamera.lookAt( 0, forwardSign[ i ], 0 );
- } else {
- cubeCamera.up.set( 0, upSign[ i ], 0 );
- cubeCamera.lookAt( 0, 0, forwardSign[ i ] );
- }
- const size = this._cubeSize;
- _setViewport( cubeUVRenderTarget, col * size, i > 2 ? size : 0, size, size );
- renderer.render( scene, cubeCamera );
- }
- renderer.autoClear = originalAutoClear;
- scene.background = background;
- }
- _textureToCubeUV( texture, cubeUVRenderTarget ) {
- const renderer = this._renderer;
- const isCubeTexture = ( texture.mapping === CubeReflectionMapping || texture.mapping === CubeRefractionMapping );
- if ( isCubeTexture ) {
- if ( this._cubemapMaterial === null ) {
- this._cubemapMaterial = _getCubemapMaterial( texture );
- }
- } else {
- if ( this._equirectMaterial === null ) {
- this._equirectMaterial = _getEquirectMaterial( texture );
- }
- }
- const material = isCubeTexture ? this._cubemapMaterial : this._equirectMaterial;
- material.fragmentNode.value = texture;
- const mesh = this._lodMeshes[ 0 ];
- mesh.material = material;
- const size = this._cubeSize;
- _setViewport( cubeUVRenderTarget, 0, 0, 3 * size, 2 * size );
- renderer.setRenderTarget( cubeUVRenderTarget );
- renderer.render( mesh, _flatCamera );
- }
- _applyPMREM( cubeUVRenderTarget ) {
- const renderer = this._renderer;
- const autoClear = renderer.autoClear;
- renderer.autoClear = false;
- const n = this._lodPlanes.length;
- for ( let i = 1; i < n; i ++ ) {
- const sigma = Math.sqrt( this._sigmas[ i ] * this._sigmas[ i ] - this._sigmas[ i - 1 ] * this._sigmas[ i - 1 ] );
- const poleAxis = _axisDirections[ ( n - i - 1 ) % _axisDirections.length ];
- this._blur( cubeUVRenderTarget, i - 1, i, sigma, poleAxis );
- }
- renderer.autoClear = autoClear;
- }
- /**
- * This is a two-pass Gaussian blur for a cubemap. Normally this is done
- * vertically and horizontally, but this breaks down on a cube. Here we apply
- * the blur latitudinally (around the poles), and then longitudinally (towards
- * the poles) to approximate the orthogonally-separable blur. It is least
- * accurate at the poles, but still does a decent job.
- */
- _blur( cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis ) {
- const pingPongRenderTarget = this._pingPongRenderTarget;
- this._halfBlur(
- cubeUVRenderTarget,
- pingPongRenderTarget,
- lodIn,
- lodOut,
- sigma,
- 'latitudinal',
- poleAxis );
- this._halfBlur(
- pingPongRenderTarget,
- cubeUVRenderTarget,
- lodOut,
- lodOut,
- sigma,
- 'longitudinal',
- poleAxis );
- }
- _halfBlur( targetIn, targetOut, lodIn, lodOut, sigmaRadians, direction, poleAxis ) {
- const renderer = this._renderer;
- const blurMaterial = this._blurMaterial;
- if ( direction !== 'latitudinal' && direction !== 'longitudinal' ) {
- console.error( 'blur direction must be either latitudinal or longitudinal!' );
- }
- // Number of standard deviations at which to cut off the discrete approximation.
- const STANDARD_DEVIATIONS = 3;
- const blurMesh = this._lodMeshes[ lodOut ];
- blurMesh.material = blurMaterial;
- const blurUniforms = blurMaterial.uniforms;
- const pixels = this._sizeLods[ lodIn ] - 1;
- const radiansPerPixel = isFinite( sigmaRadians ) ? Math.PI / ( 2 * pixels ) : 2 * Math.PI / ( 2 * MAX_SAMPLES - 1 );
- const sigmaPixels = sigmaRadians / radiansPerPixel;
- const samples = isFinite( sigmaRadians ) ? 1 + Math.floor( STANDARD_DEVIATIONS * sigmaPixels ) : MAX_SAMPLES;
- if ( samples > MAX_SAMPLES ) {
- console.warn( `sigmaRadians, ${
- sigmaRadians}, is too large and will clip, as it requested ${
- samples} samples when the maximum is set to ${MAX_SAMPLES}` );
- }
- const weights = [];
- let sum = 0;
- for ( let i = 0; i < MAX_SAMPLES; ++ i ) {
- const x = i / sigmaPixels;
- const weight = Math.exp( - x * x / 2 );
- weights.push( weight );
- if ( i === 0 ) {
- sum += weight;
- } else if ( i < samples ) {
- sum += 2 * weight;
- }
- }
- for ( let i = 0; i < weights.length; i ++ ) {
- weights[ i ] = weights[ i ] / sum;
- }
- targetIn.texture.frame = ( targetIn.texture.frame || 0 ) + 1;
- blurUniforms.envMap.value = targetIn.texture;
- blurUniforms.samples.value = samples;
- blurUniforms.weights.array = weights;
- blurUniforms.latitudinal.value = direction === 'latitudinal' ? 1 : 0;
- if ( poleAxis ) {
- blurUniforms.poleAxis.value = poleAxis;
- }
- const { _lodMax } = this;
- blurUniforms.dTheta.value = radiansPerPixel;
- blurUniforms.mipInt.value = _lodMax - lodIn;
- const outputSize = this._sizeLods[ lodOut ];
- const x = 3 * outputSize * ( lodOut > _lodMax - LOD_MIN ? lodOut - _lodMax + LOD_MIN : 0 );
- const y = 4 * ( this._cubeSize - outputSize );
- _setViewport( targetOut, x, y, 3 * outputSize, 2 * outputSize );
- renderer.setRenderTarget( targetOut );
- renderer.render( blurMesh, _flatCamera );
- }
- }
- function _createPlanes( lodMax ) {
- const lodPlanes = [];
- const sizeLods = [];
- const sigmas = [];
- const lodMeshes = [];
- let lod = lodMax;
- const totalLods = lodMax - LOD_MIN + 1 + EXTRA_LOD_SIGMA.length;
- for ( let i = 0; i < totalLods; i ++ ) {
- const sizeLod = Math.pow( 2, lod );
- sizeLods.push( sizeLod );
- let sigma = 1.0 / sizeLod;
- if ( i > lodMax - LOD_MIN ) {
- sigma = EXTRA_LOD_SIGMA[ i - lodMax + LOD_MIN - 1 ];
- } else if ( i === 0 ) {
- sigma = 0;
- }
- sigmas.push( sigma );
- const texelSize = 1.0 / ( sizeLod - 2 );
- const min = - texelSize;
- const max = 1 + texelSize;
- const uv1 = [ min, min, max, min, max, max, min, min, max, max, min, max ];
- const cubeFaces = 6;
- const vertices = 6;
- const positionSize = 3;
- const uvSize = 2;
- const faceIndexSize = 1;
- const position = new Float32Array( positionSize * vertices * cubeFaces );
- const uv = new Float32Array( uvSize * vertices * cubeFaces );
- const faceIndex = new Float32Array( faceIndexSize * vertices * cubeFaces );
- for ( let face = 0; face < cubeFaces; face ++ ) {
- const x = ( face % 3 ) * 2 / 3 - 1;
- const y = face > 2 ? 0 : - 1;
- const coordinates = [
- x, y, 0,
- x + 2 / 3, y, 0,
- x + 2 / 3, y + 1, 0,
- x, y, 0,
- x + 2 / 3, y + 1, 0,
- x, y + 1, 0
- ];
- const faceIdx = _faceLib[ face ];
- position.set( coordinates, positionSize * vertices * faceIdx );
- uv.set( uv1, uvSize * vertices * faceIdx );
- const fill = [ faceIdx, faceIdx, faceIdx, faceIdx, faceIdx, faceIdx ];
- faceIndex.set( fill, faceIndexSize * vertices * faceIdx );
- }
- const planes = new BufferGeometry();
- planes.setAttribute( 'position', new BufferAttribute( position, positionSize ) );
- planes.setAttribute( 'uv', new BufferAttribute( uv, uvSize ) );
- planes.setAttribute( 'faceIndex', new BufferAttribute( faceIndex, faceIndexSize ) );
- lodPlanes.push( planes );
- lodMeshes.push( new Mesh( planes, null ) );
- if ( lod > LOD_MIN ) {
- lod --;
- }
- }
- return { lodPlanes, sizeLods, sigmas, lodMeshes };
- }
- function _createRenderTarget( width, height, params ) {
- const cubeUVRenderTarget = new RenderTarget( width, height, params );
- cubeUVRenderTarget.texture.mapping = CubeUVReflectionMapping;
- cubeUVRenderTarget.texture.name = 'PMREM.cubeUv';
- cubeUVRenderTarget.texture.isPMREMTexture = true;
- cubeUVRenderTarget.scissorTest = true;
- return cubeUVRenderTarget;
- }
- function _setViewport( target, x, y, width, height ) {
- const viewY = target.height - height - y;
- target.viewport.set( x, viewY, width, height );
- target.scissor.set( x, viewY, width, height );
- }
- function _getMaterial() {
- const material = new NodeMaterial();
- material.depthTest = false;
- material.depthWrite = false;
- material.blending = NoBlending;
- return material;
- }
- function _getBlurShader( lodMax, width, height ) {
- const weights = uniforms( new Array( MAX_SAMPLES ).fill( 0 ) );
- const poleAxis = uniform( new Vector3( 0, 1, 0 ) );
- const dTheta = uniform( 0 );
- const n = float( MAX_SAMPLES );
- const latitudinal = uniform( 0 ); // false, bool
- const samples = uniform( 1 ); // int
- const envMap = texture( null );
- const mipInt = uniform( 0 ); // int
- const CUBEUV_TEXEL_WIDTH = float( 1 / width );
- const CUBEUV_TEXEL_HEIGHT = float( 1 / height );
- const CUBEUV_MAX_MIP = float( lodMax );
- const materialUniforms = {
- n,
- latitudinal,
- weights,
- poleAxis,
- outputDirection,
- dTheta,
- samples,
- envMap,
- mipInt,
- CUBEUV_TEXEL_WIDTH,
- CUBEUV_TEXEL_HEIGHT,
- CUBEUV_MAX_MIP
- };
- const material = _getMaterial();
- material.uniforms = materialUniforms; // TODO: Move to outside of the material
- material.fragmentNode = blur( { ...materialUniforms, latitudinal: latitudinal.equal( 1 ) } );
- return material;
- }
- function _getCubemapMaterial( envTexture ) {
- const material = _getMaterial();
- material.fragmentNode = cubeTexture( envTexture, outputDirection );
- return material;
- }
- function _getEquirectMaterial( envTexture ) {
- const material = _getMaterial();
- material.fragmentNode = texture( envTexture, equirectUV( outputDirection ), 0 );
- return material;
- }
- export default PMREMGenerator;
|