|
|
@@ -161,7 +161,7 @@ class PMREMGenerator {
|
|
|
|
|
|
console.warn( 'THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.' );
|
|
|
|
|
|
- const cubeUVRenderTarget = renderTarget || this._allocateTargets();
|
|
|
+ const cubeUVRenderTarget = renderTarget || this._allocateTarget();
|
|
|
|
|
|
options.renderTarget = cubeUVRenderTarget;
|
|
|
|
|
|
@@ -175,9 +175,11 @@ class PMREMGenerator {
|
|
|
_oldActiveCubeFace = this._renderer.getActiveCubeFace();
|
|
|
_oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();
|
|
|
|
|
|
- const cubeUVRenderTarget = renderTarget || this._allocateTargets();
|
|
|
+ const cubeUVRenderTarget = renderTarget || this._allocateTarget();
|
|
|
cubeUVRenderTarget.depthBuffer = true;
|
|
|
|
|
|
+ this._init( cubeUVRenderTarget );
|
|
|
+
|
|
|
this._sceneToCubeUV( scene, near, far, cubeUVRenderTarget, position );
|
|
|
|
|
|
if ( sigma > 0 ) {
|
|
|
@@ -238,7 +240,7 @@ class PMREMGenerator {
|
|
|
|
|
|
this._setSizeFromTexture( equirectangular );
|
|
|
|
|
|
- const cubeUVRenderTarget = renderTarget || this._allocateTargets();
|
|
|
+ const cubeUVRenderTarget = renderTarget || this._allocateTarget();
|
|
|
|
|
|
this.fromEquirectangularAsync( equirectangular, cubeUVRenderTarget );
|
|
|
|
|
|
@@ -286,7 +288,7 @@ class PMREMGenerator {
|
|
|
|
|
|
this._setSizeFromTexture( cubemap );
|
|
|
|
|
|
- const cubeUVRenderTarget = renderTarget || this._allocateTargets();
|
|
|
+ const cubeUVRenderTarget = renderTarget || this._allocateTarget();
|
|
|
|
|
|
this.fromCubemapAsync( cubemap, renderTarget );
|
|
|
|
|
|
@@ -423,7 +425,8 @@ class PMREMGenerator {
|
|
|
_oldActiveCubeFace = this._renderer.getActiveCubeFace();
|
|
|
_oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();
|
|
|
|
|
|
- const cubeUVRenderTarget = renderTarget || this._allocateTargets();
|
|
|
+ const cubeUVRenderTarget = renderTarget || this._allocateTarget();
|
|
|
+ this._init( cubeUVRenderTarget );
|
|
|
this._textureToCubeUV( texture, cubeUVRenderTarget );
|
|
|
this._applyPMREM( cubeUVRenderTarget );
|
|
|
this._cleanup( cubeUVRenderTarget );
|
|
|
@@ -432,24 +435,20 @@ class PMREMGenerator {
|
|
|
|
|
|
}
|
|
|
|
|
|
- _allocateTargets() {
|
|
|
+ _allocateTarget() {
|
|
|
|
|
|
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 );
|
|
|
+
|
|
|
+ return cubeUVRenderTarget;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- const cubeUVRenderTarget = _createRenderTarget( width, height, params );
|
|
|
+ _init( renderTarget ) {
|
|
|
|
|
|
- if ( this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== width || this._pingPongRenderTarget.height !== height ) {
|
|
|
+ if ( this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== renderTarget.width || this._pingPongRenderTarget.height !== renderTarget.height ) {
|
|
|
|
|
|
if ( this._pingPongRenderTarget !== null ) {
|
|
|
|
|
|
@@ -457,17 +456,15 @@ class PMREMGenerator {
|
|
|
|
|
|
}
|
|
|
|
|
|
- this._pingPongRenderTarget = _createRenderTarget( width, height, params );
|
|
|
+ this._pingPongRenderTarget = _createRenderTarget( renderTarget.width, renderTarget.height );
|
|
|
|
|
|
const { _lodMax } = this;
|
|
|
( { sizeLods: this._sizeLods, lodPlanes: this._lodPlanes, sigmas: this._sigmas, lodMeshes: this._lodMeshes } = _createPlanes( _lodMax ) );
|
|
|
|
|
|
- this._blurMaterial = _getBlurShader( _lodMax, width, height );
|
|
|
+ this._blurMaterial = _getBlurShader( _lodMax, renderTarget.width, renderTarget.height );
|
|
|
|
|
|
}
|
|
|
|
|
|
- return cubeUVRenderTarget;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
async _compileMaterial( material ) {
|
|
|
@@ -849,7 +846,17 @@ function _createPlanes( lodMax ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-function _createRenderTarget( width, height, params ) {
|
|
|
+function _createRenderTarget( width, height ) {
|
|
|
+
|
|
|
+ const params = {
|
|
|
+ magFilter: LinearFilter,
|
|
|
+ minFilter: LinearFilter,
|
|
|
+ generateMipmaps: false,
|
|
|
+ type: HalfFloatType,
|
|
|
+ format: RGBAFormat,
|
|
|
+ colorSpace: LinearSRGBColorSpace,
|
|
|
+ //depthBuffer: false
|
|
|
+ };
|
|
|
|
|
|
const cubeUVRenderTarget = new RenderTarget( width, height, params );
|
|
|
cubeUVRenderTarget.texture.mapping = CubeUVReflectionMapping;
|