提交 3dc950db 编写于 作者: W WestLangley

equirect shader: support decoding, tonemapping, and output encoding

上级 653a5ec8
......@@ -79,6 +79,7 @@
textureCube = new THREE.CubeTextureLoader().load( urls );
textureCube.format = THREE.RGBFormat;
textureCube.mapping = THREE.CubeReflectionMapping;
textureCube.encoding = THREE.sRGBEncoding;
var textureLoader = new THREE.TextureLoader();
......@@ -86,9 +87,11 @@
textureEquirec.mapping = THREE.EquirectangularReflectionMapping;
textureEquirec.magFilter = THREE.LinearFilter;
textureEquirec.minFilter = THREE.LinearMipMapLinearFilter;
textureEquirec.encoding = THREE.sRGBEncoding;
textureSphere = textureLoader.load( "textures/metal.jpg" );
textureSphere.mapping = THREE.SphericalReflectionMapping;
textureSphere.encoding = THREE.sRGBEncoding;
// Materials
......@@ -103,6 +106,16 @@
} );
equirectMaterial.uniforms[ "tEquirect" ].value = textureEquirec;
// enable code injection for non-built-in material
Object.defineProperty( equirectMaterial, 'map', {
get: function () {
return this.uniforms.tEquirect.value;
}
} );
var cubeShader = THREE.ShaderLib[ "cube" ];
var cubeMaterial = new THREE.ShaderMaterial( {
......@@ -114,6 +127,15 @@
} );
cubeMaterial.uniforms[ "tCube" ].value = textureCube;
Object.defineProperty( cubeMaterial, 'map', {
get: function () {
return this.uniforms.tCube.value;
}
} );
// Skybox
......@@ -136,6 +158,8 @@
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
renderer.gammaOutput = true;
//
var params = {
......
......@@ -15,7 +15,12 @@ void main() {
sampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;
gl_FragColor = texture2D( tEquirect, sampleUV );
vec4 texColor = texture2D( tEquirect, sampleUV );
gl_FragColor = mapTexelToLinear( texColor );
#include <tonemapping_fragment>
#include <encodings_fragment>
}
`;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册