Browse Source

Remove string literals for ie11

WestLangley 6 years ago
parent
commit
3de13b171f
1 changed files with 52 additions and 49 deletions
  1. 52 49
      src/helpers/LightProbeHelper.js

+ 52 - 49
src/helpers/LightProbeHelper.js

@@ -28,92 +28,95 @@ function LightProbeHelper( lightProbe, size ) {
 
 		},
 
-		vertexShader: `
+		vertexShader: [
 
-			varying vec3 vNormal;
+			'varying vec3 vNormal;',
 
-			void main() {
+			'void main() {',
 
-				vNormal = normalize( normalMatrix * normal );
+			'	vNormal = normalize( normalMatrix * normal );',
 
-				gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+			'	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',
 
-			}`,
+			'}',
 
-		fragmentShader: `
+			].join( '\n' ),
 
-			#define RECIPROCAL_PI 0.318309886
+		fragmentShader: [
 
-			vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {
+			'#define RECIPROCAL_PI 0.318309886',
 
-				// matrix is assumed to be orthogonal
+			'vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {',
 
-				return normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );
+			'	// matrix is assumed to be orthogonal',
 
-			}
+			'	return normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );',
 
-			vec3 linearToOutput( in vec3 a ) {
+			'}',
 
-				#ifdef GAMMA_OUTPUT
+			'vec3 linearToOutput( in vec3 a ) {',
 
-					return pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );
+			'	#ifdef GAMMA_OUTPUT',
 
-				#else
+			'		return pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );',
 
-					return a;
+			'	#else',
 
-				#endif
+			'		return a;',
 
-			}
+			'	#endif',
 
-			// get the irradiance (radiance convolved with cosine lobe) at the point 'normal' on the unit sphere
-			// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf
-			vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
+			'}',
 
-				// normal is assumed to have unit length
+			'// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf',
+			'vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {',
 
-				float x = normal.x, y = normal.y, z = normal.z;
+			'	// normal is assumed to have unit length',
 
-				// band 0
-				vec3 result = shCoefficients[ 0 ] * 0.886227;
+			'	float x = normal.x, y = normal.y, z = normal.z;',
 
-				// band 1
-				result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
-				result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
-				result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
+			'	// band 0',
+			'	vec3 result = shCoefficients[ 0 ] * 0.886227;',
 
-				// band 2
-				result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
-				result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
-				result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
-				result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
-				result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
+			'	// band 1',
+			'	result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;',
+			'	result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;',
+			'	result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;',
 
-				return result;
+			'	// band 2',
+			'	result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;',
+			'	result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;',
+			'	result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );',
+			'	result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;',
+			'	result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );',
 
-			}
+			'	return result;',
 
-			uniform vec3 sh[ 9 ]; // sh coefficients
+			'}',
 
-			uniform float intensity; // light probe intensity
+			'uniform vec3 sh[ 9 ]; // sh coefficients',
 
-			varying vec3 vNormal;
+			'uniform float intensity; // light probe intensity',
 
-			void main() {
+			'varying vec3 vNormal;',
 
-				vec3 normal = normalize( vNormal );
+			'void main() {',
 
-				vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
+			'	vec3 normal = normalize( vNormal );',
 
-				vec3 irradiance = shGetIrradianceAt( worldNormal, sh );
+			'	vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );',
 
-				vec3 outgoingLight = RECIPROCAL_PI * irradiance * intensity;
+			'	vec3 irradiance = shGetIrradianceAt( worldNormal, sh );',
 
-				outgoingLight = linearToOutput( outgoingLight );
+			'	vec3 outgoingLight = RECIPROCAL_PI * irradiance * intensity;',
 
-				gl_FragColor = vec4( outgoingLight, 1.0 );
+			'	outgoingLight = linearToOutput( outgoingLight );',
 
-			}`
+			'	gl_FragColor = vec4( outgoingLight, 1.0 );',
+
+			'}'
+
+			].join( '\n' )
 
 	} );