未验证 提交 8904cb3b 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #13750 from WestLangley/dev-pmrem_cleanup

PMREM: Clean up
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
* The arrangement of the faces is fixed, as assuming this arrangement, the sampling function has been written. * The arrangement of the faces is fixed, as assuming this arrangement, the sampling function has been written.
*/ */
THREE.PMREMCubeUVPacker = function ( cubeTextureLods, numLods ) {
THREE.PMREMCubeUVPacker = function( cubeTextureLods, numLods ) {
this.cubeLods = cubeTextureLods; this.cubeLods = cubeTextureLods;
this.numLods = numLods; this.numLods = numLods;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* by this class. * by this class.
*/ */
THREE.PMREMGenerator = function( sourceTexture, samplesPerLevel, resolution ) { THREE.PMREMGenerator = function ( sourceTexture, samplesPerLevel, resolution ) {
this.sourceTexture = sourceTexture; this.sourceTexture = sourceTexture;
this.resolution = ( resolution !== undefined ) ? resolution : 256; // NODE: 256 is currently hard coded in the glsl code for performance reasons this.resolution = ( resolution !== undefined ) ? resolution : 256; // NODE: 256 is currently hard coded in the glsl code for performance reasons
...@@ -52,7 +52,7 @@ THREE.PMREMGenerator = function( sourceTexture, samplesPerLevel, resolution ) { ...@@ -52,7 +52,7 @@ THREE.PMREMGenerator = function( sourceTexture, samplesPerLevel, resolution ) {
this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0.0, 1000 ); this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0.0, 1000 );
this.shader = this.getShader(); this.shader = this.getShader();
this.shader.defines['SAMPLES_PER_LEVEL'] = this.samplesPerLevel; this.shader.defines[ 'SAMPLES_PER_LEVEL' ] = this.samplesPerLevel;
this.planeMesh = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2, 0 ), this.shader ); this.planeMesh = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2, 0 ), this.shader );
this.planeMesh.material.side = THREE.DoubleSide; this.planeMesh.material.side = THREE.DoubleSide;
this.scene = new THREE.Scene(); this.scene = new THREE.Scene();
...@@ -66,7 +66,7 @@ THREE.PMREMGenerator = function( sourceTexture, samplesPerLevel, resolution ) { ...@@ -66,7 +66,7 @@ THREE.PMREMGenerator = function( sourceTexture, samplesPerLevel, resolution ) {
THREE.PMREMGenerator.prototype = { THREE.PMREMGenerator.prototype = {
constructor : THREE.PMREMGenerator, constructor: THREE.PMREMGenerator,
/* /*
* Prashant Sharma / spidersharma03: More thought and work is needed here. * Prashant Sharma / spidersharma03: More thought and work is needed here.
...@@ -81,7 +81,7 @@ THREE.PMREMGenerator.prototype = { ...@@ -81,7 +81,7 @@ THREE.PMREMGenerator.prototype = {
* This method requires the most amount of thinking I guess. Here is a paper which we could try to implement in future:: * This method requires the most amount of thinking I guess. Here is a paper which we could try to implement in future::
* http://http.developer.nvidia.com/GPUGems3/gpugems3_ch20.html * http://http.developer.nvidia.com/GPUGems3/gpugems3_ch20.html
*/ */
update: function( renderer ) { update: function ( renderer ) {
this.shader.uniforms[ 'envMap' ].value = this.sourceTexture; this.shader.uniforms[ 'envMap' ].value = this.sourceTexture;
this.shader.envMap = this.sourceTexture; this.shader.envMap = this.sourceTexture;
...@@ -101,7 +101,7 @@ THREE.PMREMGenerator.prototype = { ...@@ -101,7 +101,7 @@ THREE.PMREMGenerator.prototype = {
var r = i / ( this.numLods - 1 ); var r = i / ( this.numLods - 1 );
this.shader.uniforms[ 'roughness' ].value = r * 0.9; // see comment above, pragmatic choice this.shader.uniforms[ 'roughness' ].value = r * 0.9; // see comment above, pragmatic choice
this.shader.uniforms[ 'queryScale' ].value.x = ( i == 0 ) ? -1 : 1; this.shader.uniforms[ 'queryScale' ].value.x = ( i == 0 ) ? - 1 : 1;
var size = this.cubeLods[ i ].width; var size = this.cubeLods[ i ].width;
this.shader.uniforms[ 'mapSize' ].value = size; this.shader.uniforms[ 'mapSize' ].value = size;
this.renderToCubeMapTarget( renderer, this.cubeLods[ i ] ); this.renderToCubeMapTarget( renderer, this.cubeLods[ i ] );
...@@ -118,17 +118,17 @@ THREE.PMREMGenerator.prototype = { ...@@ -118,17 +118,17 @@ THREE.PMREMGenerator.prototype = {
}, },
renderToCubeMapTarget: function( renderer, renderTarget ) { renderToCubeMapTarget: function ( renderer, renderTarget ) {
for ( var i = 0; i < 6; i ++ ) { for ( var i = 0; i < 6; i ++ ) {
this.renderToCubeMapTargetFace( renderer, renderTarget, i ) this.renderToCubeMapTargetFace( renderer, renderTarget, i );
} }
}, },
renderToCubeMapTargetFace: function( renderer, renderTarget, faceIndex ) { renderToCubeMapTargetFace: function ( renderer, renderTarget, faceIndex ) {
renderTarget.activeCubeFace = faceIndex; renderTarget.activeCubeFace = faceIndex;
this.shader.uniforms[ 'faceIndex' ].value = faceIndex; this.shader.uniforms[ 'faceIndex' ].value = faceIndex;
...@@ -136,7 +136,7 @@ THREE.PMREMGenerator.prototype = { ...@@ -136,7 +136,7 @@ THREE.PMREMGenerator.prototype = {
}, },
getShader: function() { getShader: function () {
return new THREE.ShaderMaterial( { return new THREE.ShaderMaterial( {
...@@ -258,12 +258,14 @@ THREE.PMREMGenerator.prototype = { ...@@ -258,12 +258,14 @@ THREE.PMREMGenerator.prototype = {
//rgbColor = testColorMap( roughness ).rgb;\n\ //rgbColor = testColorMap( roughness ).rgb;\n\
gl_FragColor = linearToOutputTexel( vec4( rgbColor, 1.0 ) );\n\ gl_FragColor = linearToOutputTexel( vec4( rgbColor, 1.0 ) );\n\
}", }",
blending: THREE.CustomBlending, blending: THREE.CustomBlending,
blendSrc: THREE.OneFactor, blendSrc: THREE.OneFactor,
blendDst: THREE.ZeroFactor, blendDst: THREE.ZeroFactor,
blendSrcAlpha: THREE.OneFactor, blendSrcAlpha: THREE.OneFactor,
blendDstAlpha: THREE.ZeroFactor, blendDstAlpha: THREE.ZeroFactor,
blendEquation: THREE.AddEquation blendEquation: THREE.AddEquation
} ); } );
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册