Browse Source

WebGLPrograms: Cache isWebGL2, logarithmicDepthBuffer, floatVertexTextures, precision, maxVertexUniforms, vertexTextures.

linbingquan 5 years ago
parent
commit
29fcc2a482
1 changed files with 13 additions and 7 deletions
  1. 13 7
      src/renderers/webgl/WebGLPrograms.js

+ 13 - 7
src/renderers/webgl/WebGLPrograms.js

@@ -9,6 +9,13 @@ function WebGLPrograms( renderer, extensions, capabilities ) {
 
 
 	var programs = [];
 	var programs = [];
 
 
+	var isWebGL2 = capabilities.isWebGL2;
+	var logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
+	var floatVertexTextures = capabilities.floatVertexTextures;
+	var precision = capabilities.precision;
+	var maxVertexUniforms = capabilities.maxVertexUniforms;
+	var vertexTextures = capabilities.vertexTextures;
+
 	var shaderIDs = {
 	var shaderIDs = {
 		MeshDepthMaterial: 'depth',
 		MeshDepthMaterial: 'depth',
 		MeshDistanceMaterial: 'distanceRGBA',
 		MeshDistanceMaterial: 'distanceRGBA',
@@ -48,7 +55,7 @@ function WebGLPrograms( renderer, extensions, capabilities ) {
 		var skeleton = object.skeleton;
 		var skeleton = object.skeleton;
 		var bones = skeleton.bones;
 		var bones = skeleton.bones;
 
 
-		if ( capabilities.floatVertexTextures ) {
+		if ( floatVertexTextures ) {
 
 
 			return 1024;
 			return 1024;
 
 
@@ -61,7 +68,7 @@ function WebGLPrograms( renderer, extensions, capabilities ) {
 			//  - limit here is ANGLE's 254 max uniform vectors
 			//  - limit here is ANGLE's 254 max uniform vectors
 			//    (up to 54 should be safe)
 			//    (up to 54 should be safe)
 
 
-			var nVertexUniforms = capabilities.maxVertexUniforms;
+			var nVertexUniforms = maxVertexUniforms;
 			var nVertexMatrices = Math.floor( ( nVertexUniforms - 20 ) / 4 );
 			var nVertexMatrices = Math.floor( ( nVertexUniforms - 20 ) / 4 );
 
 
 			var maxBones = Math.min( nVertexMatrices, bones.length );
 			var maxBones = Math.min( nVertexMatrices, bones.length );
@@ -117,7 +124,6 @@ function WebGLPrograms( renderer, extensions, capabilities ) {
 		// (not to blow over maxLights budget)
 		// (not to blow over maxLights budget)
 
 
 		var maxBones = object.isSkinnedMesh ? allocateBones( object ) : 0;
 		var maxBones = object.isSkinnedMesh ? allocateBones( object ) : 0;
-		var precision = capabilities.precision;
 
 
 		if ( material.precision !== null ) {
 		if ( material.precision !== null ) {
 
 
@@ -135,7 +141,7 @@ function WebGLPrograms( renderer, extensions, capabilities ) {
 
 
 		var parameters = {
 		var parameters = {
 
 
-			isWebGL2: capabilities.isWebGL2,
+			isWebGL2: isWebGL2,
 
 
 			shaderID: shaderID,
 			shaderID: shaderID,
 
 
@@ -143,7 +149,7 @@ function WebGLPrograms( renderer, extensions, capabilities ) {
 
 
 			instancing: object.isInstancedMesh === true,
 			instancing: object.isInstancedMesh === true,
 
 
-			supportsVertexTextures: capabilities.vertexTextures,
+			supportsVertexTextures: vertexTextures,
 			outputEncoding: getTextureEncodingFromMap( ( ! currentRenderTarget ) ? null : currentRenderTarget.texture, renderer.gammaOutput ),
 			outputEncoding: getTextureEncodingFromMap( ( ! currentRenderTarget ) ? null : currentRenderTarget.texture, renderer.gammaOutput ),
 			map: !! material.map,
 			map: !! material.map,
 			mapEncoding: getTextureEncodingFromMap( material.map, renderer.gammaInput ),
 			mapEncoding: getTextureEncodingFromMap( material.map, renderer.gammaInput ),
@@ -185,11 +191,11 @@ function WebGLPrograms( renderer, extensions, capabilities ) {
 			flatShading: material.flatShading,
 			flatShading: material.flatShading,
 
 
 			sizeAttenuation: material.sizeAttenuation,
 			sizeAttenuation: material.sizeAttenuation,
-			logarithmicDepthBuffer: capabilities.logarithmicDepthBuffer,
+			logarithmicDepthBuffer: logarithmicDepthBuffer,
 
 
 			skinning: material.skinning && maxBones > 0,
 			skinning: material.skinning && maxBones > 0,
 			maxBones: maxBones,
 			maxBones: maxBones,
-			useVertexTexture: capabilities.floatVertexTextures,
+			useVertexTexture: floatVertexTextures,
 
 
 			morphTargets: material.morphTargets,
 			morphTargets: material.morphTargets,
 			morphNormals: material.morphNormals,
 			morphNormals: material.morphNormals,