|
@@ -489,29 +489,14 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters
|
|
|
|
|
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
parameters.logarithmicDepthBuffer && ( parameters.isWebGL2 || extensions.get( 'EXT_frag_depth' ) ) ? '#define USE_LOGDEPTHBUF_EXT' : '',
|
|
parameters.logarithmicDepthBuffer && ( parameters.isWebGL2 || extensions.get( 'EXT_frag_depth' ) ) ? '#define USE_LOGDEPTHBUF_EXT' : '',
|
|
|
|
+
|
|
'uniform mat4 modelMatrix;',
|
|
'uniform mat4 modelMatrix;',
|
|
|
|
+ 'uniform mat4 modelViewMatrix;',
|
|
|
|
+ 'uniform mat4 projectionMatrix;',
|
|
|
|
+ 'uniform mat4 viewMatrix;',
|
|
|
|
+ 'uniform mat3 normalMatrix;',
|
|
'uniform vec3 cameraPosition;',
|
|
'uniform vec3 cameraPosition;',
|
|
|
|
|
|
- numMultiviewViews > 0 ? [
|
|
|
|
- 'uniform mat4 modelViewMatrices[' + numMultiviewViews + '];',
|
|
|
|
- 'uniform mat3 normalMatrices[' + numMultiviewViews + '];',
|
|
|
|
- 'uniform mat4 viewMatrices[' + numMultiviewViews + '];',
|
|
|
|
- 'uniform mat4 projectionMatrices[' + numMultiviewViews + '];',
|
|
|
|
-
|
|
|
|
- '#define modelViewMatrix modelViewMatrices[VIEW_ID]',
|
|
|
|
- '#define normalMatrix normalMatrices[VIEW_ID]',
|
|
|
|
- '#define viewMatrix viewMatrices[VIEW_ID]',
|
|
|
|
- '#define projectionMatrix projectionMatrices[VIEW_ID]'
|
|
|
|
-
|
|
|
|
- ].join( '\n' ) : [
|
|
|
|
-
|
|
|
|
- 'uniform mat4 modelViewMatrix;',
|
|
|
|
- 'uniform mat4 projectionMatrix;',
|
|
|
|
- 'uniform mat4 viewMatrix;',
|
|
|
|
- 'uniform mat3 normalMatrix;',
|
|
|
|
-
|
|
|
|
- ].join( '\n' ),
|
|
|
|
-
|
|
|
|
'#ifdef USE_INSTANCING',
|
|
'#ifdef USE_INSTANCING',
|
|
|
|
|
|
' attribute mat4 instanceMatrix;',
|
|
' attribute mat4 instanceMatrix;',
|
|
@@ -631,15 +616,9 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters
|
|
|
|
|
|
( ( material.extensions ? material.extensions.shaderTextureLOD : false ) || parameters.envMap ) && ( parameters.isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) ) ? '#define TEXTURE_LOD_EXT' : '',
|
|
( ( material.extensions ? material.extensions.shaderTextureLOD : false ) || parameters.envMap ) && ( parameters.isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) ) ? '#define TEXTURE_LOD_EXT' : '',
|
|
|
|
|
|
|
|
+ 'uniform mat4 viewMatrix;',
|
|
'uniform vec3 cameraPosition;',
|
|
'uniform vec3 cameraPosition;',
|
|
|
|
|
|
- numMultiviewViews > 0 ? [
|
|
|
|
-
|
|
|
|
- 'uniform mat4 viewMatrices[' + numMultiviewViews + '];',
|
|
|
|
- '#define viewMatrix viewMatrices[VIEW_ID]'
|
|
|
|
-
|
|
|
|
- ].join( '\n' ) : 'uniform mat4 viewMatrix;',
|
|
|
|
-
|
|
|
|
( parameters.toneMapping !== NoToneMapping ) ? '#define TONE_MAPPING' : '',
|
|
( parameters.toneMapping !== NoToneMapping ) ? '#define TONE_MAPPING' : '',
|
|
( parameters.toneMapping !== NoToneMapping ) ? ShaderChunk[ 'tonemapping_pars_fragment' ] : '', // this code is required here because it is used by the toneMapping() function defined below
|
|
( parameters.toneMapping !== NoToneMapping ) ? ShaderChunk[ 'tonemapping_pars_fragment' ] : '', // this code is required here because it is used by the toneMapping() function defined below
|
|
( parameters.toneMapping !== NoToneMapping ) ? getToneMappingFunction( 'toneMapping', parameters.toneMapping ) : '',
|
|
( parameters.toneMapping !== NoToneMapping ) ? getToneMappingFunction( 'toneMapping', parameters.toneMapping ) : '',
|
|
@@ -691,17 +670,9 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters
|
|
}
|
|
}
|
|
|
|
|
|
// GLSL 3.0 conversion
|
|
// GLSL 3.0 conversion
|
|
|
|
+
|
|
prefixVertex = [
|
|
prefixVertex = [
|
|
'#version 300 es\n',
|
|
'#version 300 es\n',
|
|
-
|
|
|
|
- numMultiviewViews > 0 ? [
|
|
|
|
-
|
|
|
|
- '#extension GL_OVR_multiview2 : require',
|
|
|
|
- 'layout(num_views = ' + numMultiviewViews + ') in;',
|
|
|
|
- '#define VIEW_ID gl_ViewID_OVR'
|
|
|
|
-
|
|
|
|
- ].join( '\n' ) : '',
|
|
|
|
-
|
|
|
|
'#define attribute in',
|
|
'#define attribute in',
|
|
'#define varying out',
|
|
'#define varying out',
|
|
'#define texture2D texture'
|
|
'#define texture2D texture'
|
|
@@ -709,12 +680,6 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters
|
|
|
|
|
|
prefixFragment = [
|
|
prefixFragment = [
|
|
'#version 300 es\n',
|
|
'#version 300 es\n',
|
|
- numMultiviewViews > 0 ? [
|
|
|
|
-
|
|
|
|
- '#extension GL_OVR_multiview2 : require',
|
|
|
|
- '#define VIEW_ID gl_ViewID_OVR'
|
|
|
|
-
|
|
|
|
- ].join( '\n' ) : '',
|
|
|
|
'#define varying in',
|
|
'#define varying in',
|
|
isGLSL3ShaderMaterial ? '' : 'out highp vec4 pc_fragColor;',
|
|
isGLSL3ShaderMaterial ? '' : 'out highp vec4 pc_fragColor;',
|
|
isGLSL3ShaderMaterial ? '' : '#define gl_FragColor pc_fragColor',
|
|
isGLSL3ShaderMaterial ? '' : '#define gl_FragColor pc_fragColor',
|
|
@@ -730,6 +695,59 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters
|
|
'#define textureCubeGradEXT textureGrad'
|
|
'#define textureCubeGradEXT textureGrad'
|
|
].join( '\n' ) + '\n' + prefixFragment;
|
|
].join( '\n' ) + '\n' + prefixFragment;
|
|
|
|
|
|
|
|
+ // Multiview
|
|
|
|
+
|
|
|
|
+ if ( numMultiviewViews > 0 ) {
|
|
|
|
+
|
|
|
|
+ prefixVertex = prefixVertex.replace(
|
|
|
|
+ '#version 300 es\n',
|
|
|
|
+ [
|
|
|
|
+ '#version 300 es\n',
|
|
|
|
+ '#extension GL_OVR_multiview2 : require',
|
|
|
|
+ 'layout(num_views = ' + numMultiviewViews + ') in;',
|
|
|
|
+ '#define VIEW_ID gl_ViewID_OVR'
|
|
|
|
+ ].join( '\n' )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ prefixVertex = prefixVertex.replace(
|
|
|
|
+ [
|
|
|
|
+ 'uniform mat4 modelViewMatrix;',
|
|
|
|
+ 'uniform mat4 projectionMatrix;',
|
|
|
|
+ 'uniform mat4 viewMatrix;',
|
|
|
|
+ 'uniform mat3 normalMatrix;'
|
|
|
|
+ ].join( '\n' ),
|
|
|
|
+ [
|
|
|
|
+ 'uniform mat4 modelViewMatrices[' + numMultiviewViews + '];',
|
|
|
|
+ 'uniform mat3 normalMatrices[' + numMultiviewViews + '];',
|
|
|
|
+ 'uniform mat4 viewMatrices[' + numMultiviewViews + '];',
|
|
|
|
+ 'uniform mat4 projectionMatrices[' + numMultiviewViews + '];',
|
|
|
|
+
|
|
|
|
+ '#define modelViewMatrix modelViewMatrices[VIEW_ID]',
|
|
|
|
+ '#define normalMatrix normalMatrices[VIEW_ID]',
|
|
|
|
+ '#define viewMatrix viewMatrices[VIEW_ID]',
|
|
|
|
+ '#define projectionMatrix projectionMatrices[VIEW_ID]'
|
|
|
|
+ ].join( '\n' )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ prefixFragment = prefixFragment.replace(
|
|
|
|
+ '#version 300 es\n',
|
|
|
|
+ [
|
|
|
|
+ '#version 300 es\n',
|
|
|
|
+ '#extension GL_OVR_multiview2 : require',
|
|
|
|
+ '#define VIEW_ID gl_ViewID_OVR'
|
|
|
|
+ ].join( '\n' )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ prefixFragment = prefixFragment.replace(
|
|
|
|
+ 'uniform mat4 viewMatrix;',
|
|
|
|
+ [
|
|
|
|
+ 'uniform mat4 viewMatrices[' + numMultiviewViews + '];',
|
|
|
|
+ '#define viewMatrix viewMatrices[VIEW_ID]'
|
|
|
|
+ ].join( '\n' )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
var vertexGlsl = prefixVertex + vertexShader;
|
|
var vertexGlsl = prefixVertex + vertexShader;
|