Browse Source

src: add missing /* glsl */ & string template

yushijinhun 5 years ago
parent
commit
310591df0f
2 changed files with 26 additions and 39 deletions
  1. 5 5
      src/extras/PMREMGenerator.js
  2. 21 34
      src/renderers/WebGLCubeRenderTarget.js

+ 5 - 5
src/extras/PMREMGenerator.js

@@ -624,7 +624,7 @@ function _getBlurShader( maxSamples ) {
 
 		vertexShader: _getCommonVertexShader(),
 
-		fragmentShader: `
+		fragmentShader: /* glsl */`
 precision mediump float;
 precision mediump int;
 varying vec3 vOutputDirection;
@@ -694,7 +694,7 @@ function _getEquirectShader() {
 
 		vertexShader: _getCommonVertexShader(),
 
-		fragmentShader: `
+		fragmentShader: /* glsl */`
 precision mediump float;
 precision mediump int;
 varying vec3 vOutputDirection;
@@ -749,7 +749,7 @@ function _getCubemapShader() {
 
 		vertexShader: _getCommonVertexShader(),
 
-		fragmentShader: `
+		fragmentShader: /* glsl */`
 precision mediump float;
 precision mediump int;
 varying vec3 vOutputDirection;
@@ -776,7 +776,7 @@ void main() {
 
 function _getCommonVertexShader() {
 
-	return `
+	return /* glsl */`
 precision mediump float;
 precision mediump int;
 attribute vec3 position;
@@ -817,7 +817,7 @@ void main() {
 
 function _getEncodings() {
 
-	return `
+	return /* glsl */`
 uniform int inputEncoding;
 uniform int outputEncoding;
 

+ 21 - 34
src/renderers/WebGLCubeRenderTarget.js

@@ -45,46 +45,33 @@ WebGLCubeRenderTarget.prototype.fromEquirectangularTexture = function ( renderer
 			tEquirect: { value: null },
 		},
 
-		vertexShader: [
+		vertexShader: /* glsl */`
+varying vec3 vWorldDirection;
 
-			"varying vec3 vWorldDirection;",
-
-			"vec3 transformDirection( in vec3 dir, in mat4 matrix ) {",
-
-			"	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );",
-
-			"}",
-
-			"void main() {",
-
-			"	vWorldDirection = transformDirection( position, modelMatrix );",
-
-			"	#include <begin_vertex>",
-			"	#include <project_vertex>",
-
-			"}"
-
-		].join( '\n' ),
-
-		fragmentShader: [
-
-			"uniform sampler2D tEquirect;",
-
-			"varying vec3 vWorldDirection;",
-
-			"#include <common>",
-
-			"void main() {",
+vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
+	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
+}
 
-			"	vec3 direction = normalize( vWorldDirection );",
+void main() {
+	vWorldDirection = transformDirection( position, modelMatrix );
 
-			"	vec2 sampleUV = equirectUv( direction );",
+	#include <begin_vertex>
+	#include <project_vertex>
+}
+		`,
 
-			"	gl_FragColor = texture2D( tEquirect, sampleUV );",
+		fragmentShader: /* glsl */`
+uniform sampler2D tEquirect;
+varying vec3 vWorldDirection;
 
-			"}"
+#include <common>
 
-		].join( '\n' ),
+void main() {
+	vec3 direction = normalize( vWorldDirection );
+	vec2 sampleUV = equirectUv( direction );
+	gl_FragColor = texture2D( tEquirect, sampleUV );
+}
+		`
 	};
 
 	const material = new ShaderMaterial( {