Browse Source

Rename specular2 with specular of MeshStandardMaterialSG

Takahiro 8 years ago
parent
commit
8053b6f96c

+ 6 - 6
src/materials/MeshStandardMaterialSG.js

@@ -7,11 +7,11 @@ import { Color } from '../math/Color';
  *
  *
  * parameters = {
  * parameters = {
  *  glossiness: <float>,
  *  glossiness: <float>,
- *  specular2: <hex>,
+ *  specular: <hex>,
  *
  *
  *  glossinessMap: new THREE.Texture( <Image> ),
  *  glossinessMap: new THREE.Texture( <Image> ),
  *
  *
- *  specular2Map: new THREE.Texture( <Image> ),
+ *  specularMap: new THREE.Texture( <Image> ),
  * }
  * }
  */
  */
 
 
@@ -24,11 +24,11 @@ function MeshStandardMaterialSG( parameters ) {
 	this.type = 'MeshStandardMaterialSG';
 	this.type = 'MeshStandardMaterialSG';
 
 
 	this.glossiness = 0.5;
 	this.glossiness = 0.5;
-	this.specular2 = new Color ( 0x000000 );
+	this.specular = new Color( 0x111111 );
 
 
 	this.glossinessMap = null;
 	this.glossinessMap = null;
 
 
-	this.specular2Map = null;
+	this.specularMap = null;
 
 
 	this.setValues( parameters );
 	this.setValues( parameters );
 
 
@@ -46,11 +46,11 @@ MeshStandardMaterialSG.prototype.copy = function ( source ) {
 	this.defines[ 'STANDARD_SG' ] = '';
 	this.defines[ 'STANDARD_SG' ] = '';
 
 
 	this.glossiness = source.glossiness;
 	this.glossiness = source.glossiness;
-	this.speculars.copy( source.specular2 );
+	this.specular.copy( source.specular );
 
 
 	this.glossinessMap = source.glossinessMap;
 	this.glossinessMap = source.glossinessMap;
 
 
-	this.specular2Map = source.specular2Map;
+	this.specularMap = source.specularMap;
 
 
 	return this;
 	return this;
 
 

+ 3 - 3
src/renderers/WebGLRenderer.js

@@ -2202,7 +2202,7 @@ function WebGLRenderer( parameters ) {
 	function refreshUniformsStandardSG( uniforms, material ) {
 	function refreshUniformsStandardSG( uniforms, material ) {
 
 
 		uniforms.glossiness.value = material.roughness;
 		uniforms.glossiness.value = material.roughness;
-		uniforms.specular2.value.copy( material.specular2 );
+		uniforms.specular.value.copy( material.specular );
 
 
 		if ( material.glossinessMap ) {
 		if ( material.glossinessMap ) {
 
 
@@ -2210,9 +2210,9 @@ function WebGLRenderer( parameters ) {
 
 
 		}
 		}
 
 
-		if ( material.specular2Map ) {
+		if ( material.specularMap ) {
 
 
-			uniforms.specular2Map.value = material.specular2Map;
+			uniforms.specularMap.value = material.specularMap;
 
 
 		}
 		}
 
 

+ 0 - 4
src/renderers/shaders/ShaderChunk.js

@@ -75,8 +75,6 @@ import skinning_vertex from './ShaderChunk/skinning_vertex.glsl';
 import skinnormal_vertex from './ShaderChunk/skinnormal_vertex.glsl';
 import skinnormal_vertex from './ShaderChunk/skinnormal_vertex.glsl';
 import specularmap_fragment from './ShaderChunk/specularmap_fragment.glsl';
 import specularmap_fragment from './ShaderChunk/specularmap_fragment.glsl';
 import specularmap_pars_fragment from './ShaderChunk/specularmap_pars_fragment.glsl';
 import specularmap_pars_fragment from './ShaderChunk/specularmap_pars_fragment.glsl';
-import specular2map_fragment from './ShaderChunk/specular2map_fragment.glsl';
-import specular2map_pars_fragment from './ShaderChunk/specular2map_pars_fragment.glsl';
 import tonemapping_fragment from './ShaderChunk/tonemapping_fragment.glsl';
 import tonemapping_fragment from './ShaderChunk/tonemapping_fragment.glsl';
 import tonemapping_pars_fragment from './ShaderChunk/tonemapping_pars_fragment.glsl';
 import tonemapping_pars_fragment from './ShaderChunk/tonemapping_pars_fragment.glsl';
 import uv_pars_fragment from './ShaderChunk/uv_pars_fragment.glsl';
 import uv_pars_fragment from './ShaderChunk/uv_pars_fragment.glsl';
@@ -190,8 +188,6 @@ export var ShaderChunk = {
 	skinnormal_vertex: skinnormal_vertex,
 	skinnormal_vertex: skinnormal_vertex,
 	specularmap_fragment: specularmap_fragment,
 	specularmap_fragment: specularmap_fragment,
 	specularmap_pars_fragment: specularmap_pars_fragment,
 	specularmap_pars_fragment: specularmap_pars_fragment,
-	specular2map_fragment: specular2map_fragment,
-	specular2map_pars_fragment: specular2map_pars_fragment,
 	tonemapping_fragment: tonemapping_fragment,
 	tonemapping_fragment: tonemapping_fragment,
 	tonemapping_pars_fragment: tonemapping_pars_fragment,
 	tonemapping_pars_fragment: tonemapping_pars_fragment,
 	uv_pars_fragment: uv_pars_fragment,
 	uv_pars_fragment: uv_pars_fragment,

+ 1 - 1
src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl

@@ -3,7 +3,7 @@ PhysicalMaterial material;
 #ifdef STANDARD_SG
 #ifdef STANDARD_SG
 	material.diffuseColor = diffuseColor.rgb;
 	material.diffuseColor = diffuseColor.rgb;
 	material.specularRoughness = clamp( 1.0 - glossinessFactor, 0.04, 1.0 );
 	material.specularRoughness = clamp( 1.0 - glossinessFactor, 0.04, 1.0 );
-	material.specularColor = specular2Factor.rgb;
+	material.specularColor = specularFactor.rgb;
 #else
 #else
 	material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
 	material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
 	material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );
 	material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );

+ 0 - 10
src/renderers/shaders/ShaderChunk/specular2map_fragment.glsl

@@ -1,10 +0,0 @@
-vec3 specular2Factor = specular2;
-
-#ifdef USE_SPECULAR2MAP
-
-	vec4 texelSpecular2 = texture2D( specular2Map, vUv );
-
-	// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture
-	specular2Factor *= texelSpecular2.rgb;
-
-#endif

+ 0 - 5
src/renderers/shaders/ShaderChunk/specular2map_pars_fragment.glsl

@@ -1,5 +0,0 @@
-#ifdef USE_SPECULAR2MAP
-
-	uniform sampler2D specular2Map;
-
-#endif

+ 18 - 5
src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl

@@ -1,12 +1,25 @@
-float specularStrength;
+#ifdef STANDARD_SG
+	vec3 specularFactor = specular;
 
 
-#ifdef USE_SPECULARMAP
+	#ifdef USE_SPECULARMAP
 
 
-	vec4 texelSpecular = texture2D( specularMap, vUv );
-	specularStrength = texelSpecular.r;
+		vec4 texelSpecular = texture2D( specularMap, vUv );
 
 
+		// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture
+		specularFactor *= texelSpecular.rgb;
+
+	#endif
 #else
 #else
+	float specularStrength;
+
+	#ifdef USE_SPECULARMAP
+
+		vec4 texelSpecular = texture2D( specularMap, vUv );
+		specularStrength = texelSpecular.r;
+
+	#else
 
 
-	specularStrength = 1.0;
+		specularStrength = 1.0;
 
 
+	#endif
 #endif
 #endif

+ 1 - 2
src/renderers/shaders/ShaderLib.js

@@ -83,7 +83,6 @@ var ShaderLib = {
 			UniformsLib.roughnessmap,
 			UniformsLib.roughnessmap,
 			UniformsLib.metalnessmap,
 			UniformsLib.metalnessmap,
 			UniformsLib.glossinessmap,
 			UniformsLib.glossinessmap,
-			UniformsLib.specular2map,
 			UniformsLib.fog,
 			UniformsLib.fog,
 			UniformsLib.lights,
 			UniformsLib.lights,
 			{
 			{
@@ -91,7 +90,7 @@ var ShaderLib = {
 				roughness: { value: 0.5 },
 				roughness: { value: 0.5 },
 				metalness: { value: 0 },
 				metalness: { value: 0 },
 				glossiness: { value: 0.5 },
 				glossiness: { value: 0.5 },
-				specular2: { value: new Color( 0x000000 ) },
+				specular: { value: new Color( 0x111111 ) },
 				envMapIntensity: { value: 1 } // temporary
 				envMapIntensity: { value: 1 } // temporary
 			}
 			}
 		] ),
 		] ),

+ 3 - 4
src/renderers/shaders/ShaderLib/meshphysical_frag.glsl

@@ -5,7 +5,7 @@ uniform vec3 emissive;
 
 
 #ifdef STANDARD_SG
 #ifdef STANDARD_SG
 	uniform float glossiness;
 	uniform float glossiness;
-	uniform vec3 specular2;
+	uniform vec3 specular;
 #else
 #else
 	uniform float roughness;
 	uniform float roughness;
 	uniform float metalness;
 	uniform float metalness;
@@ -48,7 +48,7 @@ varying vec3 vViewPosition;
 
 
 #ifdef STANDARD_SG
 #ifdef STANDARD_SG
 	#include <glossinessmap_pars_fragment>
 	#include <glossinessmap_pars_fragment>
-	#include <specular2map_pars_fragment>
+	#include <specularmap_pars_fragment>
 #else
 #else
 	#include <roughnessmap_pars_fragment>
 	#include <roughnessmap_pars_fragment>
 	#include <metalnessmap_pars_fragment>
 	#include <metalnessmap_pars_fragment>
@@ -70,11 +70,10 @@ void main() {
 	#include <color_fragment>
 	#include <color_fragment>
 	#include <alphamap_fragment>
 	#include <alphamap_fragment>
 	#include <alphatest_fragment>
 	#include <alphatest_fragment>
-	#include <specularmap_fragment>
 
 
 	#ifdef STANDARD_SG
 	#ifdef STANDARD_SG
 		#include <glossinessmap_fragment>
 		#include <glossinessmap_fragment>
-		#include <specular2map_fragment>
+		#include <specularmap_fragment>
 	#else
 	#else
 		#include <roughnessmap_fragment>
 		#include <roughnessmap_fragment>
 		#include <metalnessmap_fragment>
 		#include <metalnessmap_fragment>

+ 0 - 1
src/renderers/shaders/ShaderLib/meshphysical_vert.glsl

@@ -17,7 +17,6 @@ varying vec3 vViewPosition;
 #include <morphtarget_pars_vertex>
 #include <morphtarget_pars_vertex>
 #include <skinning_pars_vertex>
 #include <skinning_pars_vertex>
 #include <shadowmap_pars_vertex>
 #include <shadowmap_pars_vertex>
-#include <specularmap_pars_fragment>
 #include <logdepthbuf_pars_vertex>
 #include <logdepthbuf_pars_vertex>
 #include <clipping_planes_pars_vertex>
 #include <clipping_planes_pars_vertex>
 
 

+ 0 - 6
src/renderers/shaders/UniformsLib.js

@@ -93,12 +93,6 @@ var UniformsLib = {
 
 
 	},
 	},
 
 
-	specular2map: {
-
-		specular2Map: { value: null }
-
-	},
-
 	fog: {
 	fog: {
 
 
 		fogDensity: { value: 0.00025 },
 		fogDensity: { value: 0.00025 },

+ 0 - 2
src/renderers/webgl/WebGLProgram.js

@@ -339,7 +339,6 @@ function WebGLProgram( renderer, code, material, parameters ) {
 			parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',
 			parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',
 			parameters.metalnessMap ? '#define USE_METALNESSMAP' : '',
 			parameters.metalnessMap ? '#define USE_METALNESSMAP' : '',
 			parameters.glossinessMap ? '#define USE_GLOSSINESSMAP' : '',
 			parameters.glossinessMap ? '#define USE_GLOSSINESSMAP' : '',
-			parameters.specular2Map ? '#define USE_SPECULAR2MAP' : '',
 			parameters.alphaMap ? '#define USE_ALPHAMAP' : '',
 			parameters.alphaMap ? '#define USE_ALPHAMAP' : '',
 			parameters.vertexColors ? '#define USE_COLOR' : '',
 			parameters.vertexColors ? '#define USE_COLOR' : '',
 
 
@@ -448,7 +447,6 @@ function WebGLProgram( renderer, code, material, parameters ) {
 			parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',
 			parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',
 			parameters.metalnessMap ? '#define USE_METALNESSMAP' : '',
 			parameters.metalnessMap ? '#define USE_METALNESSMAP' : '',
 			parameters.glossinessMap ? '#define USE_GLOSSINESSMAP' : '',
 			parameters.glossinessMap ? '#define USE_GLOSSINESSMAP' : '',
-			parameters.specular2Map ? '#define USE_SPECULAR2MAP' : '',
 			parameters.alphaMap ? '#define USE_ALPHAMAP' : '',
 			parameters.alphaMap ? '#define USE_ALPHAMAP' : '',
 			parameters.vertexColors ? '#define USE_COLOR' : '',
 			parameters.vertexColors ? '#define USE_COLOR' : '',
 
 

+ 1 - 2
src/renderers/webgl/WebGLPrograms.js

@@ -27,7 +27,7 @@ function WebGLPrograms( renderer, capabilities ) {
 	var parameterNames = [
 	var parameterNames = [
 		"precision", "supportsVertexTextures", "map", "mapEncoding", "envMap", "envMapMode", "envMapEncoding",
 		"precision", "supportsVertexTextures", "map", "mapEncoding", "envMap", "envMapMode", "envMapEncoding",
 		"lightMap", "aoMap", "emissiveMap", "emissiveMapEncoding", "bumpMap", "normalMap", "displacementMap", "specularMap",
 		"lightMap", "aoMap", "emissiveMap", "emissiveMapEncoding", "bumpMap", "normalMap", "displacementMap", "specularMap",
-		"roughnessMap", "metalnessMap", "gradientMap", "glossinessMap", "specular2Map",
+		"roughnessMap", "metalnessMap", "gradientMap", "glossinessMap",
 		"alphaMap", "combine", "vertexColors", "fog", "useFog", "fogExp",
 		"alphaMap", "combine", "vertexColors", "fog", "useFog", "fogExp",
 		"flatShading", "sizeAttenuation", "logarithmicDepthBuffer", "skinning",
 		"flatShading", "sizeAttenuation", "logarithmicDepthBuffer", "skinning",
 		"maxBones", "useVertexTexture", "morphTargets", "morphNormals",
 		"maxBones", "useVertexTexture", "morphTargets", "morphNormals",
@@ -151,7 +151,6 @@ function WebGLPrograms( renderer, capabilities ) {
 			roughnessMap: !! material.roughnessMap,
 			roughnessMap: !! material.roughnessMap,
 			metalnessMap: !! material.metalnessMap,
 			metalnessMap: !! material.metalnessMap,
 			glossinessMap: !! material.glossinessMap,
 			glossinessMap: !! material.glossinessMap,
-			specular2Map: !! material.specular2Map,
 			specularMap: !! material.specularMap,
 			specularMap: !! material.specularMap,
 			alphaMap: !! material.alphaMap,
 			alphaMap: !! material.alphaMap,