2
0
Эх сурвалжийг харах

Materials: Setting THREE.PremultipliedAlphaBlending as default blending for relevant built-in materials. See #8255.

Mr.doob 9 жил өмнө
parent
commit
df18543f03

+ 6 - 4
src/materials/LineBasicMaterial.js

@@ -6,14 +6,14 @@
  *  color: <hex>,
  *  opacity: <float>,
  *
- *  blending: THREE.NormalBlending,
- *  depthTest: <bool>,
- *  depthWrite: <bool>,
- *
  *  linewidth: <float>,
  *  linecap: "round",
  *  linejoin: "round",
  *
+ *  blending: THREE.PremultipliedAlphaBlending,
+ *  depthTest: <bool>,
+ *  depthWrite: <bool>,
+ *
  *  vertexColors: <bool>
  *
  *  fog: <bool>
@@ -32,6 +32,8 @@ THREE.LineBasicMaterial = function ( parameters ) {
 	this.linecap = 'round';
 	this.linejoin = 'round';
 
+	this.blending = THREE.PremultipliedAlphaBlending;
+
 	this.vertexColors = THREE.NoColors;
 
 	this.fog = true;

+ 7 - 5
src/materials/LineDashedMaterial.js

@@ -5,16 +5,16 @@
  *  color: <hex>,
  *  opacity: <float>,
  *
- *  blending: THREE.NormalBlending,
- *  depthTest: <bool>,
- *  depthWrite: <bool>,
- *
  *  linewidth: <float>,
  *
  *  scale: <float>,
  *  dashSize: <float>,
  *  gapSize: <float>,
  *
+ *  blending: THREE.PremultipliedAlphaBlending,
+ *  depthTest: <bool>,
+ *  depthWrite: <bool>,
+ *
  *  vertexColors: THREE.NoColors / THREE.FaceColors / THREE.VertexColors
  *
  *  fog: <bool>
@@ -35,6 +35,8 @@ THREE.LineDashedMaterial = function ( parameters ) {
 	this.dashSize = 3;
 	this.gapSize = 1;
 
+	this.blending = THREE.PremultipliedAlphaBlending;
+
 	this.vertexColors = THREE.NoColors;
 
 	this.fog = true;
@@ -51,7 +53,7 @@ THREE.LineDashedMaterial.prototype.copy = function ( source ) {
 	THREE.Material.prototype.copy.call( this, source );
 
 	this.color.copy( source.color );
-	
+
 	this.linewidth = source.linewidth;
 
 	this.scale = source.scale;

+ 2 - 1
src/materials/MeshBasicMaterial.js

@@ -20,7 +20,7 @@
  *  refractionRatio: <float>,
  *
  *  shading: THREE.SmoothShading,
- *  blending: THREE.NormalBlending,
+ *  blending: THREE.PremultipliedAlphaBlending,
  *  depthTest: <bool>,
  *  depthWrite: <bool>,
  *
@@ -61,6 +61,7 @@ THREE.MeshBasicMaterial = function ( parameters ) {
 	this.fog = true;
 
 	this.shading = THREE.SmoothShading;
+	this.blending = THREE.PremultipliedAlphaBlending;
 
 	this.wireframe = false;
 	this.wireframeLinewidth = 1;

+ 3 - 1
src/materials/MeshLambertMaterial.js

@@ -27,7 +27,7 @@
  *  reflectivity: <float>,
  *  refractionRatio: <float>,
  *
- *  blending: THREE.NormalBlending,
+ *  blending: THREE.PremultipliedAlphaBlending,
  *  depthTest: <bool>,
  *  depthWrite: <bool>,
  *
@@ -75,6 +75,8 @@ THREE.MeshLambertMaterial = function ( parameters ) {
 
 	this.fog = true;
 
+	this.blending = THREE.PremultipliedAlphaBlending;
+
 	this.wireframe = false;
 	this.wireframeLinewidth = 1;
 	this.wireframeLinecap = 'round';

+ 2 - 1
src/materials/MeshPhongMaterial.js

@@ -40,7 +40,7 @@
  *  refractionRatio: <float>,
  *
  *  shading: THREE.SmoothShading,
- *  blending: THREE.NormalBlending,
+ *  blending: THREE.PremultipliedAlphaBlending,
  *  depthTest: <bool>,
  *  depthWrite: <bool>,
  *
@@ -101,6 +101,7 @@ THREE.MeshPhongMaterial = function ( parameters ) {
 	this.fog = true;
 
 	this.shading = THREE.SmoothShading;
+	this.blending = THREE.PremultipliedAlphaBlending;
 
 	this.wireframe = false;
 	this.wireframeLinewidth = 1;

+ 2 - 1
src/materials/MeshStandardMaterial.js

@@ -41,7 +41,7 @@
  *  refractionRatio: <float>,
  *
  *  shading: THREE.SmoothShading,
- *  blending: THREE.NormalBlending,
+ *  blending: THREE.PremultipliedAlphaBlending,
  *  depthTest: <bool>,
  *  depthWrite: <bool>,
  *
@@ -104,6 +104,7 @@ THREE.MeshStandardMaterial = function ( parameters ) {
 	this.fog = true;
 
 	this.shading = THREE.SmoothShading;
+	this.blending = THREE.PremultipliedAlphaBlending;
 
 	this.wireframe = false;
 	this.wireframeLinewidth = 1;

+ 3 - 1
src/materials/PointsMaterial.js

@@ -10,7 +10,7 @@
  *  size: <float>,
  *  sizeAttenuation: <bool>,
  *
- *  blending: THREE.NormalBlending,
+ *  blending: THREE.PremultipliedAlphaBlending,
  *  depthTest: <bool>,
  *  depthWrite: <bool>,
  *
@@ -33,6 +33,8 @@ THREE.PointsMaterial = function ( parameters ) {
 	this.size = 1;
 	this.sizeAttenuation = true;
 
+	this.blending = THREE.PremultipliedAlphaBlending;
+
 	this.vertexColors = THREE.NoColors;
 
 	this.fog = true;

+ 2 - 2
src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl

@@ -1,6 +1,6 @@
 #ifdef PREMULTIPLIED_ALPHA
 
-  // Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation.
-  gl_FragColor.rgb *= gl_FragColor.a;
+	// Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation.
+	gl_FragColor.rgb *= gl_FragColor.a;
 
 #endif

+ 1 - 1
src/renderers/webgl/WebGLState.js

@@ -230,7 +230,7 @@ THREE.WebGLState = function ( gl, extensions, paramThreeToGL ) {
 				gl.blendEquation( gl.FUNC_ADD );
 				gl.blendFunc( gl.ZERO, gl.SRC_COLOR );
 
-			} else if( blending === THREE.PremultipliedAlphaBlending ) {
+			} else if ( blending === THREE.PremultipliedAlphaBlending ) {
 
 				gl.blendEquationSeparate( gl.FUNC_ADD, gl.FUNC_ADD );
 				gl.blendFuncSeparate( gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );