Browse Source

Remove unneeded constants (#23765)

LeviPesin 3 years ago
parent
commit
cc2ddada58

+ 0 - 5
examples/jsm/nodes/ShaderNode.js

@@ -421,10 +421,5 @@ export const step = new ShaderNodeProxy( MathNode, 'step' );
 export const tan = new ShaderNodeProxy( MathNode, 'tan' );
 export const tan = new ShaderNodeProxy( MathNode, 'tan' );
 export const transformDirection = new ShaderNodeProxy( MathNode, 'transformDirection' );
 export const transformDirection = new ShaderNodeProxy( MathNode, 'transformDirection' );
 
 
-export const PI = float( Math.PI );
-export const PI2 = float( Math.PI * 2 );
-export const PI_HALF = float( Math.PI / 2 );
-export const RECIPROCAL_PI = float( 1 / Math.PI );
-export const RECIPROCAL_PI2 = float( 1 / ( 2 * Math.PI ) );
 export const EPSILON = float( 1e-6 );
 export const EPSILON = float( 1e-6 );
 export const INFINITY = float( 1e6 );
 export const INFINITY = float( 1e6 );

+ 4 - 4
examples/jsm/nodes/functions/BSDFs.js

@@ -3,7 +3,7 @@ import { ShaderNode,
 	cond, greaterThan, and,
 	cond, greaterThan, and,
 	transformedNormalView, positionViewDirection,
 	transformedNormalView, positionViewDirection,
 	diffuseColor, specularColor, roughness,
 	diffuseColor, specularColor, roughness,
-	PI, RECIPROCAL_PI, EPSILON
+	EPSILON
 } from '../ShaderNode.js';
 } from '../ShaderNode.js';
 
 
 export const F_Schlick = new ShaderNode( ( inputs ) => {
 export const F_Schlick = new ShaderNode( ( inputs ) => {
@@ -23,7 +23,7 @@ export const F_Schlick = new ShaderNode( ( inputs ) => {
 
 
 export const BRDF_Lambert = new ShaderNode( ( inputs ) => {
 export const BRDF_Lambert = new ShaderNode( ( inputs ) => {
 
 
-	return mul( RECIPROCAL_PI, inputs.diffuseColor ); // punctual light
+	return mul( 1 / Math.PI, inputs.diffuseColor ); // punctual light
 
 
 } ); // validated
 } ); // validated
 
 
@@ -69,7 +69,7 @@ export const D_GGX = new ShaderNode( ( inputs ) => {
 
 
 	const denom = add( mul( pow2( dotNH ), sub( a2, 1.0 ) ), 1.0 ); // avoid alpha = 0 with dotNH = 1
 	const denom = add( mul( pow2( dotNH ), sub( a2, 1.0 ) ), 1.0 ); // avoid alpha = 0 with dotNH = 1
 
 
-	return mul( RECIPROCAL_PI, div( a2, pow2( denom ) ) );
+	return mul( 1 / Math.PI, div( a2, pow2( denom ) ) );
 
 
 } ); // validated
 } ); // validated
 
 
@@ -105,7 +105,7 @@ export const RE_Direct_Physical = new ShaderNode( ( inputs ) => {
 	const dotNL = saturate( dot( transformedNormalView, lightDirection ) );
 	const dotNL = saturate( dot( transformedNormalView, lightDirection ) );
 	let irradiance = mul( dotNL, lightColor );
 	let irradiance = mul( dotNL, lightColor );
 
 
-	irradiance = mul( irradiance, PI ); // punctual light
+	irradiance = mul( irradiance, Math.PI ); // punctual light
 
 
 	addTo( directDiffuse, mul( irradiance, BRDF_Lambert( { diffuseColor: diffuseColor.rgb } ) ) );
 	addTo( directDiffuse, mul( irradiance, BRDF_Lambert( { diffuseColor: diffuseColor.rgb } ) ) );
 
 

+ 2 - 2
examples/jsm/nodes/utils/OscNode.js

@@ -1,6 +1,6 @@
 import Node from '../core/Node.js';
 import Node from '../core/Node.js';
 import TimerNode from './TimerNode.js';
 import TimerNode from './TimerNode.js';
-import { abs, fract, round, sin, add, sub, mul, PI2 } from '../ShaderNode.js';
+import { abs, fract, round, sin, add, sub, mul } from '../ShaderNode.js';
 
 
 class OscNode extends Node {
 class OscNode extends Node {
 
 
@@ -33,7 +33,7 @@ class OscNode extends Node {
 
 
 		if ( method === OscNode.SINE ) {
 		if ( method === OscNode.SINE ) {
 
 
-			outputNode = add( mul( sin( mul( add( timeNode, .75 ), PI2 ) ), .5 ), .5 );
+			outputNode = add( mul( sin( mul( add( timeNode, .75 ), Math.PI * 2 ) ), .5 ), .5 );
 
 
 		} else if ( method === OscNode.SQUARE ) {
 		} else if ( method === OscNode.SQUARE ) {