Skip to content

Commit

Permalink
Examples: Use RGBM16 format in webgl_materials_standard example.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Feb 27, 2019
1 parent 0df6685 commit 8094686
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions examples/webgl_materials_standard.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@

<script src="js/controls/TrackballControls.js"></script>
<script src="js/loaders/OBJLoader.js"></script>
<script src="js/loaders/RGBELoader.js"></script>
<script src="js/loaders/HDRCubeTextureLoader.js"></script>

<script src="js/pmrem/PMREMGenerator.js"></script>
<script src="js/pmrem/PMREMCubeUVPacker.js"></script>
Expand Down Expand Up @@ -140,33 +138,26 @@

} );

var genCubeUrls = function ( prefix, postfix ) {
new THREE.CubeTextureLoader().setPath( './textures/cube/pisaRGBM16/' )
.load( [ 'px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png' ], function ( rgbmCubeMap ) {

return [
prefix + 'px' + postfix, prefix + 'nx' + postfix,
prefix + 'py' + postfix, prefix + 'ny' + postfix,
prefix + 'pz' + postfix, prefix + 'nz' + postfix
];
rgbmCubeMap.encoding = THREE.RGBM16Encoding;
rgbmCubeMap.format = THREE.RGBAFormat;

};

var hdrUrls = genCubeUrls( './textures/cube/pisaHDR/', '.hdr' );
new THREE.HDRCubeTextureLoader().load( THREE.UnsignedByteType, hdrUrls, function ( hdrCubeMap ) {

var pmremGenerator = new THREE.PMREMGenerator( hdrCubeMap );
var pmremGenerator = new THREE.PMREMGenerator( rgbmCubeMap );
pmremGenerator.update( renderer );

var pmremCubeUVPacker = new THREE.PMREMCubeUVPacker( pmremGenerator.cubeLods );
pmremCubeUVPacker.update( renderer );

var hdrCubeRenderTarget = pmremCubeUVPacker.CubeUVRenderTarget;
var rgbmCubeRenderTarget = pmremCubeUVPacker.CubeUVRenderTarget;

material.envMap = hdrCubeRenderTarget.texture;
material.envMap = rgbmCubeRenderTarget.texture;
material.needsUpdate = true; // is this needed?

hdrCubeMap.magFilter = THREE.LinearFilter;
hdrCubeMap.needsUpdate = true;
scene.background = hdrCubeMap;
rgbmCubeMap.magFilter = THREE.LinearFilter;
rgbmCubeMap.needsUpdate = true;
scene.background = rgbmCubeMap;

pmremGenerator.dispose();
pmremCubeUVPacker.dispose();
Expand Down

5 comments on commit 8094686

@WestLangley
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrdoob Can you please explain why this is preferable?

@mrdoob
Copy link
Owner Author

@mrdoob mrdoob commented on 8094686 Feb 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RGBM16 is preferable so we no longer require RGBELoader and HDRCubeTextureLoader.

The output seems to be identical to my eyes:
https://threejs.org/examples/#webgl_materials_envmaps_hdr

Am I missing something?

@WestLangley
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not to my knowledge...

So for clarification, what loaders, encodings, and file extensions will be removed from the library and examples?

@mrdoob
Copy link
Owner Author

@mrdoob mrdoob commented on 8094686 Feb 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I do not think we have to remove any loader or encodings. I was just trying to get that example to load as fast as possible.

@WestLangley
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks!

Please sign in to comment.