Skip to content

Commit

Permalink
Allow WebGLCubeMap to accept renderTarget textures (mrdoob#27230)
Browse files Browse the repository at this point in the history
* remove unnecessary check

* simplified example

* revert build files
  • Loading branch information
elalish authored and AdaRoseCannon committed Jan 15, 2024
1 parent 8b2d967 commit 21f2b9c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions examples/webgl_loader_texture_hdrjpg.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@
resolutions[ 'HDR JPG' ] = hdrJpg.width + 'x' + hdrJpg.height;
displayStats( 'HDR JPG' );

hdrJpgPMREMRenderTarget = pmremGenerator.fromEquirectangular( hdrJpg.renderTarget.texture );
hdrJpgEquirectangularMap = hdrJpg.renderTarget.texture;
hdrJpgPMREMRenderTarget = pmremGenerator.fromEquirectangular( hdrJpgEquirectangularMap );

hdrJpgEquirectangularMap = hdrJpg.toDataTexture();
hdrJpgEquirectangularMap.mapping = THREE.EquirectangularReflectionMapping;
hdrJpgEquirectangularMap.minFilter = THREE.LinearFilter;
hdrJpgEquirectangularMap.magFilter = THREE.LinearFilter;
Expand All @@ -159,9 +159,9 @@

resolutions[ 'Webp Gain map (separate)' ] = gainMap.width + 'x' + gainMap.height;

gainMapPMREMRenderTarget = pmremGenerator.fromEquirectangular( gainMap.renderTarget.texture );
gainMapBackground = hdrJpg.renderTarget.texture;
gainMapPMREMRenderTarget = pmremGenerator.fromEquirectangular( gainMapBackground );

gainMapBackground = gainMap.toDataTexture();
gainMapBackground.mapping = THREE.EquirectangularReflectionMapping;
gainMapBackground.minFilter = THREE.LinearFilter;
gainMapBackground.magFilter = THREE.LinearFilter;
Expand Down Expand Up @@ -285,11 +285,11 @@

case 'HDR JPG':
pmremRenderTarget = hdrJpgPMREMRenderTarget;
equirectangularMap = hdrJpgEquirectangularMap || hdrJpg.renderTarget.texture;
equirectangularMap = hdrJpgEquirectangularMap;
break;
case 'Webp Gain map (separate)':
pmremRenderTarget = gainMapPMREMRenderTarget;
equirectangularMap = gainMapBackground || gainMap.renderTarget.texture;
equirectangularMap = gainMapBackground;
break;
case 'HDR':
pmremRenderTarget = hdrPMREMRenderTarget;
Expand All @@ -302,9 +302,6 @@

if ( newEnvMap && newEnvMap !== torusMesh.material.envMap ) {

torusMesh.material.envMap = newEnvMap;
torusMesh.material.needsUpdate = true;

planeMesh.material.map = newEnvMap;
planeMesh.material.needsUpdate = true;

Expand All @@ -313,6 +310,7 @@
torusMesh.rotation.y += 0.005;
planeMesh.visible = params.debug;

scene.environment = equirectangularMap;
scene.background = equirectangularMap;
renderer.toneMappingExposure = params.exposure;

Expand Down
2 changes: 1 addition & 1 deletion src/renderers/webgl/WebGLCubeMaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function WebGLCubeMaps( renderer ) {

function get( texture ) {

if ( texture && texture.isTexture && texture.isRenderTargetTexture === false ) {
if ( texture && texture.isTexture ) {

const mapping = texture.mapping;

Expand Down

0 comments on commit 21f2b9c

Please sign in to comment.