提交 857d9e57 编写于 作者: M Mr.doob

Updated builds.

上级 8864ef63
......@@ -19750,15 +19750,12 @@ THREE.WebGLRenderer = function ( parameters ) {
pixelRatio = 1,
_precision = parameters.precision !== undefined ? parameters.precision : 'highp',
_alpha = parameters.alpha !== undefined ? parameters.alpha : false,
_depth = parameters.depth !== undefined ? parameters.depth : true,
_stencil = parameters.stencil !== undefined ? parameters.stencil : true,
_antialias = parameters.antialias !== undefined ? parameters.antialias : false,
_premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true,
_preserveDrawingBuffer = parameters.preserveDrawingBuffer !== undefined ? parameters.preserveDrawingBuffer : false,
_logarithmicDepthBuffer = parameters.logarithmicDepthBuffer !== undefined ? parameters.logarithmicDepthBuffer : false,
_clearColor = new THREE.Color( 0x000000 ),
_clearAlpha = 0;
......@@ -19766,13 +19763,18 @@ THREE.WebGLRenderer = function ( parameters ) {
var lights = [];
var opaqueObjects = [];
var opaqueObjectsLastIndex = -1;
var transparentObjects = [];
var transparentObjectsLastIndex = -1;
var opaqueImmediateObjects = [];
var opaqueImmediateObjectsLastIndex = -1;
var transparentImmediateObjects = [];
var transparentImmediateObjectsLastIndex = -1;
var morphInfluences = new Float32Array( 8 );
var sprites = [];
var lensFlares = [];
......@@ -19937,11 +19939,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
if ( _logarithmicDepthBuffer ) {
extensions.get( 'EXT_frag_depth' );
}
var capabilities = new THREE.WebGLCapabilities( _gl, extensions, parameters );
var state = new THREE.WebGLState( _gl, extensions, paramThreeToGL );
var properties = new THREE.WebGLProperties();
......@@ -19991,6 +19989,7 @@ THREE.WebGLRenderer = function ( parameters ) {
setDefaultGLState();
this.context = _gl;
this.capabilities = capabilities;
this.extensions = extensions;
this.state = state;
......@@ -20000,24 +19999,6 @@ THREE.WebGLRenderer = function ( parameters ) {
this.shadowMap = shadowMap;
// GPU capabilities
var _maxTextures = _gl.getParameter( _gl.MAX_TEXTURE_IMAGE_UNITS );
var _maxVertexTextures = _gl.getParameter( _gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
var _maxTextureSize = _gl.getParameter( _gl.MAX_TEXTURE_SIZE );
var _maxCubemapSize = _gl.getParameter( _gl.MAX_CUBE_MAP_TEXTURE_SIZE );
var _supportsVertexTextures = _maxVertexTextures > 0;
var _supportsBoneTextures = _supportsVertexTextures && extensions.get( 'OES_texture_float' );
var _maxPrecision = state.getMaxPrecision( _precision );
if ( _maxPrecision !== _precision ) {
console.warn( 'THREE.WebGLRenderer:', _precision, 'not supported, using', _maxPrecision, 'instead.' );
_precision = _maxPrecision;
}
// Plugins
......@@ -20072,7 +20053,7 @@ THREE.WebGLRenderer = function ( parameters ) {
this.getPrecision = function () {
return _precision;
return capabilities.precision;
};
......@@ -20354,7 +20335,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( newReferenceCount === 0 ) {
// the last meterial that has been using the program let
// the last material that has been using the program let
// go of it, so remove it from the (unordered) _programs
// set and deallocate the GL resource
......@@ -20877,17 +20858,23 @@ THREE.WebGLRenderer = function ( parameters ) {
lights.length = 0;
opaqueObjects.length = 0;
transparentObjects.length = 0;
opaqueObjectsLastIndex = -1;
transparentObjectsLastIndex = -1;
opaqueImmediateObjects.length = 0;
transparentImmediateObjects.length = 0;
opaqueImmediateObjectsLastIndex = -1;
transparentImmediateObjectsLastIndex = -1;
sprites.length = 0;
lensFlares.length = 0;
projectObject( scene );
opaqueObjects.length = opaqueObjectsLastIndex + 1;
transparentObjects.length = transparentObjectsLastIndex + 1;
opaqueImmediateObjects.length = opaqueImmediateObjectsLastIndex + 1;
transparentImmediateObjects.length = transparentImmediateObjectsLastIndex + 1;
if ( _this.sortObjects === true ) {
opaqueObjects.sort( painterSortStable );
......@@ -20967,36 +20954,82 @@ THREE.WebGLRenderer = function ( parameters ) {
function pushImmediateRenderItem( object ) {
var array, index;
// allocate the next position in the appropriate array
if ( object.material.transparent ) {
transparentImmediateObjects.push( object );
array = transparentImmediateObjects;
index = ++ transparentImmediateObjectsLastIndex;
} else {
array = opaqueImmediateObjects;
index = ++ opaqueImmediateObjectsLastIndex;
}
// recycle existing position or grow the array
if ( index < array.length ) {
array[ index ] = object;
} else {
opaqueImmediateObjects.push( object );
// assert( index === array.length );
array.push( object );
}
}
function pushRenderItem( object, geometry, material, z, group ) {
var renderItem = {
id: object.id,
object: object,
geometry: geometry,
material: material,
z: _vector3.z,
group: group
};
var array, index;
// allocate the next position in the appropriate array
if ( material.transparent ) {
transparentObjects.push( renderItem );
array = transparentObjects;
index = ++ transparentObjectsLastIndex;
} else {
array = opaqueObjects;
index = ++ opaqueObjectsLastIndex;
}
// recycle existing render item or grow the array
var renderItem = array[ index ];
if ( renderItem !== undefined ) {
renderItem.id = object.id;
renderItem.object = object;
renderItem.geometry = geometry;
renderItem.material = material;
renderItem.z = _vector3.z;
renderItem.group = group;
} else {
opaqueObjects.push( renderItem );
renderItem = {
id: object.id,
object: object,
geometry: geometry,
material: material,
z: _vector3.z,
group: group
};
// assert( index === array.length );
array.push( renderItem );
}
......@@ -21159,11 +21192,11 @@ THREE.WebGLRenderer = function ( parameters ) {
var maxLightCount = allocateLights( lights );
var maxShadows = allocateShadows( lights );
var maxBones = allocateBones( object );
var precision = _precision;
var precision = capabilities.precision;
if ( material.precision !== null ) {
precision = state.getMaxPrecision( material.precision );
precision = capabilities.getMaxPrecision( material.precision );
if ( precision !== material.precision ) {
......@@ -21176,7 +21209,7 @@ THREE.WebGLRenderer = function ( parameters ) {
var parameters = {
precision: precision,
supportsVertexTextures: _supportsVertexTextures,
supportsVertexTextures: capabilities.vertexTextures,
map: !! material.map,
envMap: !! material.envMap,
......@@ -21200,11 +21233,11 @@ THREE.WebGLRenderer = function ( parameters ) {
flatShading: material.shading === THREE.FlatShading,
sizeAttenuation: material.sizeAttenuation,
logarithmicDepthBuffer: _logarithmicDepthBuffer,
logarithmicDepthBuffer: capabilities.logarithmicDepthBuffer,
skinning: material.skinning,
maxBones: maxBones,
useVertexTexture: _supportsBoneTextures && object && object.skeleton && object.skeleton.useVertexTexture,
useVertexTexture: capabilities.floatVertexTextures && object && object.skeleton && object.skeleton.useVertexTexture,
morphTargets: material.morphTargets,
morphNormals: material.morphNormals,
......@@ -21471,7 +21504,7 @@ THREE.WebGLRenderer = function ( parameters ) {
_gl.uniformMatrix4fv( p_uniforms.projectionMatrix, false, camera.projectionMatrix.elements );
if ( _logarithmicDepthBuffer ) {
if ( capabilities.logarithmicDepthBuffer ) {
_gl.uniform1f( p_uniforms.logDepthBufFC, 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
......@@ -21530,7 +21563,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
if ( _supportsBoneTextures && object.skeleton && object.skeleton.useVertexTexture ) {
if ( capabilities.floatVertexTextures && object.skeleton && object.skeleton.useVertexTexture ) {
if ( p_uniforms.boneTexture !== undefined ) {
......@@ -21936,9 +21969,9 @@ THREE.WebGLRenderer = function ( parameters ) {
var textureUnit = _usedTextureUnits;
if ( textureUnit >= _maxTextures ) {
if ( textureUnit >= capabilities.maxTextures ) {
console.warn( 'WebGLRenderer: trying to use ' + textureUnit + ' texture units while this GPU supports only ' + _maxTextures );
console.warn( 'WebGLRenderer: trying to use ' + textureUnit + ' texture units while this GPU supports only ' + capabilities.maxTextures );
}
......@@ -22555,7 +22588,10 @@ THREE.WebGLRenderer = function ( parameters ) {
extension = extensions.get( 'EXT_texture_filter_anisotropic' );
if ( extension && texture.type !== THREE.FloatType && texture.type !== THREE.HalfFloatType ) {
if ( extension ) {
if ( texture.type === THREE.FloatType && extensions.get( 'OES_texture_float_linear' ) === null ) return;
if ( texture.type === THREE.HalfFloatType && extensions.get( 'OES_texture_half_float_linear' ) === null ) return;
if ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {
......@@ -22591,7 +22627,7 @@ THREE.WebGLRenderer = function ( parameters ) {
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
texture.image = clampToMaxSize( texture.image, _maxTextureSize );
texture.image = clampToMaxSize( texture.image, capabilities.maxTextureSize );
var image = texture.image,
isImagePowerOfTwo = THREE.Math.isPowerOfTwo( image.width ) && THREE.Math.isPowerOfTwo( image.height ),
......@@ -22776,7 +22812,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( _this.autoScaleCubemaps && ! isCompressed && ! isDataTexture ) {
cubeImage[ i ] = clampToMaxSize( texture.image[ i ], _maxCubemapSize );
cubeImage[ i ] = clampToMaxSize( texture.image[ i ], capabilities.maxCubemapSize );
} else {
......@@ -23239,7 +23275,7 @@ THREE.WebGLRenderer = function ( parameters ) {
function allocateBones ( object ) {
if ( _supportsBoneTextures && object && object.skeleton && object.skeleton.useVertexTexture ) {
if ( capabilities.floatVertexTextures && object && object.skeleton && object.skeleton.useVertexTexture ) {
return 1024;
......@@ -23364,7 +23400,7 @@ THREE.WebGLRenderer = function ( parameters ) {
this.supportsVertexTextures = function () {
return _supportsVertexTextures;
return capabilities.vertexTextures;
};
......@@ -23755,6 +23791,76 @@ THREE.WebGLExtensions = function ( gl ) {
};
// File:src/renderers/webgl/WebGLCapabilities.js
THREE.WebGLCapabilities = function ( gl, extensions, parameters ) {
function getMaxPrecision( precision ) {
if ( precision === 'highp' ) {
if ( gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.HIGH_FLOAT ).precision > 0 &&
gl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ).precision > 0 ) {
return 'highp';
}
precision = 'mediump';
}
if ( precision === 'mediump' ) {
if ( gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.MEDIUM_FLOAT ).precision > 0 &&
gl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ).precision > 0 ) {
return 'mediump';
}
}
return 'lowp';
}
this.getMaxPrecision = getMaxPrecision;
this.precision = parameters.precision !== undefined ? parameters.precision : 'highp',
this.logarithmicDepthBuffer = parameters.logarithmicDepthBuffer !== undefined ? parameters.logarithmicDepthBuffer : false;
this.maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
this.maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
this.maxTextureSize = gl.getParameter( gl.MAX_TEXTURE_SIZE );
this.maxCubemapSize = gl.getParameter( gl.MAX_CUBE_MAP_TEXTURE_SIZE );
this.maxAttributes = gl.getParameter( gl.MAX_VERTEX_ATTRIBS );
this.maxVertexUniforms = gl.getParameter( gl.MAX_VERTEX_UNIFORM_VECTORS );
this.maxVaryings = gl.getParameter( gl.MAX_VARYING_VECTORS );
this.maxFragmentUniforms = gl.getParameter( gl.MAX_FRAGMENT_UNIFORM_VECTORS );
this.vertexTextures = this.maxVertexTextures > 0;
this.floatFragmentTextures = !! extensions.get( 'OES_texture_float' );
this.floatVertexTextures = this.vertexTextures && this.floatFragmentTextures;
var _maxPrecision = getMaxPrecision( this.precision );
if ( _maxPrecision !== this.precision ) {
console.warn( 'THREE.WebGLRenderer:', this.precision, 'not supported, using', _maxPrecision, 'instead.' );
this.precision = _maxPrecision;
}
if ( this.logarithmicDepthBuffer ) {
this.logarithmicDepthBuffer = !! extensions.get( 'EXT_frag_depth' );
}
};
// File:src/renderers/webgl/WebGLGeometries.js
/**
......@@ -24882,9 +24988,9 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
var groups = geometry.groups;
var materials = material.materials;
for ( var j = 0, jl = groups.length; j < jl; j ++ ) {
for ( var k = 0, kl = groups.length; k < kl; k ++ ) {
var group = groups[ j ];
var group = groups[ k ];
var groupMaterial = materials[ group.materialIndex ];
if ( groupMaterial.visible === true ) {
......@@ -25139,36 +25245,6 @@ THREE.WebGLState = function ( gl, extensions, paramThreeToGL ) {
};
this.getMaxPrecision = function ( precision ) {
if ( precision === 'highp' ) {
if ( gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.HIGH_FLOAT ).precision > 0 &&
gl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ).precision > 0 ) {
return 'highp';
}
precision = 'mediump';
}
if ( precision === 'mediump' ) {
if ( gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.MEDIUM_FLOAT ).precision > 0 &&
gl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ).precision > 0 ) {
return 'mediump';
}
}
return 'lowp';
};
this.setBlending = function ( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha ) {
if ( blending !== currentBlending ) {
......
此差异已折叠。
......@@ -2858,6 +2858,7 @@ THREE.WebGLRenderer = function ( parameters ) {
extension = extensions.get( 'EXT_texture_filter_anisotropic' );
if ( extension ) {
if ( texture.type === THREE.FloatType && extensions.get( 'OES_texture_float_linear' ) === null ) return;
if ( texture.type === THREE.HalfFloatType && extensions.get( 'OES_texture_half_float_linear' ) === null ) return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册