Browse Source

remove non-ENERGY_PRESERVATION code

sunag 6 years ago
parent
commit
070101a9b3

+ 0 - 6
src/materials/MeshStandardMaterial.js

@@ -44,8 +44,6 @@ import { Color } from '../math/Color.js';
  *  envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ),
  *  envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ),
  *  envMapIntensity: <float>
  *  envMapIntensity: <float>
  *
  *
- *  energyPreservation: <bool>,
- *
  *  refractionRatio: <float>,
  *  refractionRatio: <float>,
  *
  *
  *  wireframe: <boolean>,
  *  wireframe: <boolean>,
@@ -101,8 +99,6 @@ function MeshStandardMaterial( parameters ) {
 	this.envMap = null;
 	this.envMap = null;
 	this.envMapIntensity = 1.0;
 	this.envMapIntensity = 1.0;
 
 
-	this.energyPreservation = true;
-
 	this.refractionRatio = 0.98;
 	this.refractionRatio = 0.98;
 
 
 	this.wireframe = false;
 	this.wireframe = false;
@@ -165,8 +161,6 @@ MeshStandardMaterial.prototype.copy = function ( source ) {
 	this.envMap = source.envMap;
 	this.envMap = source.envMap;
 	this.envMapIntensity = source.envMapIntensity;
 	this.envMapIntensity = source.envMapIntensity;
 
 
-	this.energyPreservation = source.energyPreservation;
-
 	this.refractionRatio = source.refractionRatio;
 	this.refractionRatio = source.refractionRatio;
 
 
 	this.wireframe = source.wireframe;
 	this.wireframe = source.wireframe;

+ 8 - 22
src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js

@@ -96,13 +96,6 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricC
 
 
 void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
 void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
 
 
-	// Defer to the IndirectSpecular function to compute
-	// the indirectDiffuse if energy preservation is enabled.
-	#ifndef ENERGY_PRESERVATION
-
-		reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
-
-	#endif
 
 
 }
 }
 
 
@@ -120,25 +113,18 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
 
 
 	// Both indirect specular and diffuse light accumulate here
 	// Both indirect specular and diffuse light accumulate here
 	// if energy preservation enabled, and PMREM provided.
 	// if energy preservation enabled, and PMREM provided.
-	#if defined( ENERGY_PRESERVATION )
-
-		vec3 singleScattering = vec3( 0.0 );
-		vec3 multiScattering = vec3( 0.0 );
-		vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
 
 
-		BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );
+	vec3 singleScattering = vec3( 0.0 );
+	vec3 multiScattering = vec3( 0.0 );
+	vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
 
 
-		vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );
+	BRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );
 
 
-		reflectedLight.indirectSpecular += clearCoatInv * radiance * singleScattering;
-		reflectedLight.indirectDiffuse += multiScattering * cosineWeightedIrradiance;
-		reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
+	vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );
 
 
-	#else
-
-		reflectedLight.indirectSpecular += clearCoatInv * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );
-
-	#endif
+	reflectedLight.indirectSpecular += clearCoatInv * radiance * singleScattering;
+	reflectedLight.indirectDiffuse += multiScattering * cosineWeightedIrradiance;
+	reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
 
 
 	#ifndef STANDARD
 	#ifndef STANDARD
 
 

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

@@ -522,8 +522,6 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters,
 
 
 			parameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '',
 			parameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '',
 
 
-			parameters.energyPreservation ? '#define ENERGY_PRESERVATION' : '',
-
 			parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
 			parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
 			parameters.logarithmicDepthBuffer && ( capabilities.isWebGL2 || extensions.get( 'EXT_frag_depth' ) ) ? '#define USE_LOGDEPTHBUF_EXT' : '',
 			parameters.logarithmicDepthBuffer && ( capabilities.isWebGL2 || extensions.get( 'EXT_frag_depth' ) ) ? '#define USE_LOGDEPTHBUF_EXT' : '',
 
 

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

@@ -201,8 +201,6 @@ function WebGLPrograms( renderer, extensions, capabilities ) {
 			toneMapping: renderer.toneMapping,
 			toneMapping: renderer.toneMapping,
 			physicallyCorrectLights: renderer.physicallyCorrectLights,
 			physicallyCorrectLights: renderer.physicallyCorrectLights,
 
 
-			energyPreservation: material.energyPreservation,
-
 			premultipliedAlpha: material.premultipliedAlpha,
 			premultipliedAlpha: material.premultipliedAlpha,
 
 
 			alphaTest: material.alphaTest,
 			alphaTest: material.alphaTest,