|
@@ -13779,7 +13779,7 @@ var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_
|
|
|
|
|
|
var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif";
|
|
|
|
|
|
-var map_fragment = "#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vMapUv );\n#endif";
|
|
|
+var map_fragment = "#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif";
|
|
|
|
|
|
var map_pars_fragment = "#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif";
|
|
|
|
|
@@ -13873,7 +13873,7 @@ var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defin
|
|
|
|
|
|
const vertex$h = "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}";
|
|
|
|
|
|
-const fragment$h = "uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}";
|
|
|
+const fragment$h = "uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}";
|
|
|
|
|
|
const vertex$g = "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}";
|
|
|
|
|
@@ -19816,6 +19816,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
|
|
|
parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
|
|
|
|
|
|
+ parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
|
|
|
+
|
|
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
|
( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',
|
|
|
|
|
@@ -20503,6 +20505,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
toneMapping: toneMapping,
|
|
|
useLegacyLights: renderer._useLegacyLights,
|
|
|
|
|
|
+ decodeVideoTexture: HAS_MAP && ( material.map.isVideoTexture === true ) && ( material.map.colorSpace === SRGBColorSpace ),
|
|
|
+
|
|
|
premultipliedAlpha: material.premultipliedAlpha,
|
|
|
|
|
|
doubleSided: material.side === DoubleSide,
|
|
@@ -20704,6 +20708,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
_programLayers.enable( 17 );
|
|
|
if ( parameters.pointsUvs )
|
|
|
_programLayers.enable( 18 );
|
|
|
+ if ( parameters.decodeVideoTexture )
|
|
|
+ _programLayers.enable( 19 );
|
|
|
|
|
|
array.push( _programLayers.mask );
|
|
|
|
|
@@ -24264,7 +24270,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
|
|
|
|
let glType = utils.convert( texture.type ),
|
|
|
- glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
|
+ glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture );
|
|
|
|
|
|
setTextureParameters( textureType, texture, supportsMips );
|
|
|
|
|
@@ -25543,7 +25549,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
const format = texture.format;
|
|
|
const type = texture.type;
|
|
|
|
|
|
- if ( texture.isCompressedTexture === true || texture.format === _SRGBAFormat ) return image;
|
|
|
+ if ( texture.isCompressedTexture === true || texture.isVideoTexture === true || texture.format === _SRGBAFormat ) return image;
|
|
|
|
|
|
if ( colorSpace !== LinearSRGBColorSpace && colorSpace !== NoColorSpace ) {
|
|
|
|
|
@@ -29773,48 +29779,28 @@ class WebGLRenderer {
|
|
|
|
|
|
if ( refreshProgram || _currentCamera !== camera ) {
|
|
|
|
|
|
- p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
|
|
|
-
|
|
|
- if ( capabilities.logarithmicDepthBuffer ) {
|
|
|
-
|
|
|
- p_uniforms.setValue( _gl, 'logDepthBufFC',
|
|
|
- 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
|
|
|
-
|
|
|
- }
|
|
|
+ // common camera uniforms
|
|
|
|
|
|
- if ( _currentCamera !== camera ) {
|
|
|
+ p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
|
|
|
+ p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
|
|
|
|
|
|
- _currentCamera = camera;
|
|
|
+ const uCamPos = p_uniforms.map.cameraPosition;
|
|
|
|
|
|
- // lighting uniforms depend on the camera so enforce an update
|
|
|
- // now, in case this material supports lights - or later, when
|
|
|
- // the next material that does gets activated:
|
|
|
+ if ( uCamPos !== undefined ) {
|
|
|
|
|
|
- refreshMaterial = true; // set to true on material change
|
|
|
- refreshLights = true; // remains set until update done
|
|
|
+ uCamPos.setValue( _gl, _vector3.setFromMatrixPosition( camera.matrixWorld ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
- // load material specific uniforms
|
|
|
- // (shader material also gets them for the sake of genericity)
|
|
|
-
|
|
|
- if ( material.isShaderMaterial ||
|
|
|
- material.isMeshPhongMaterial ||
|
|
|
- material.isMeshToonMaterial ||
|
|
|
- material.isMeshStandardMaterial ||
|
|
|
- material.envMap ) {
|
|
|
-
|
|
|
- const uCamPos = p_uniforms.map.cameraPosition;
|
|
|
-
|
|
|
- if ( uCamPos !== undefined ) {
|
|
|
-
|
|
|
- uCamPos.setValue( _gl,
|
|
|
- _vector3.setFromMatrixPosition( camera.matrixWorld ) );
|
|
|
+ if ( capabilities.logarithmicDepthBuffer ) {
|
|
|
|
|
|
- }
|
|
|
+ p_uniforms.setValue( _gl, 'logDepthBufFC',
|
|
|
+ 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // consider moving isOrthographic to UniformLib and WebGLMaterials, see https://github.com/mrdoob/three.js/pull/26467#issuecomment-1645185067
|
|
|
+
|
|
|
if ( material.isMeshPhongMaterial ||
|
|
|
material.isMeshToonMaterial ||
|
|
|
material.isMeshLambertMaterial ||
|
|
@@ -29826,16 +29812,16 @@ class WebGLRenderer {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( material.isMeshPhongMaterial ||
|
|
|
- material.isMeshToonMaterial ||
|
|
|
- material.isMeshLambertMaterial ||
|
|
|
- material.isMeshBasicMaterial ||
|
|
|
- material.isMeshStandardMaterial ||
|
|
|
- material.isShaderMaterial ||
|
|
|
- material.isShadowMaterial ||
|
|
|
- object.isSkinnedMesh ) {
|
|
|
+ if ( _currentCamera !== camera ) {
|
|
|
|
|
|
- p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
|
|
|
+ _currentCamera = camera;
|
|
|
+
|
|
|
+ // lighting uniforms depend on the camera so enforce an update
|
|
|
+ // now, in case this material supports lights - or later, when
|
|
|
+ // the next material that does gets activated:
|
|
|
+
|
|
|
+ refreshMaterial = true; // set to true on material change
|
|
|
+ refreshLights = true; // remains set until update done
|
|
|
|
|
|
}
|
|
|
|