Skip to content

Commit 6234608

Browse files
authored
Remove inline sRGB decode of video textures (#25752)
* WebGLRenderer: Use texStorage2D and hardware sRGB decoding for video textures * Revert useTexStorage change. * Clean up
1 parent 40ae0b7 commit 6234608

File tree

5 files changed

+6
-30
lines changed

5 files changed

+6
-30
lines changed
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
export default /* glsl */`
22
#ifdef USE_MAP
33
4-
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
5-
6-
#ifdef DECODE_VIDEO_TEXTURE
7-
8-
// inline sRGB decode (TODO: Remove this code when https://crbug.com/1256340 is solved)
9-
10-
sampledDiffuseColor = 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 );
11-
12-
#endif
13-
14-
diffuseColor *= sampledDiffuseColor;
4+
diffuseColor *= texture2D( map, vMapUv );
155
166
#endif
177
`;

src/renderers/shaders/ShaderLib/background.glsl.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ void main() {
2121
2222
vec4 texColor = texture2D( t2D, vUv );
2323
24-
#ifdef DECODE_VIDEO_TEXTURE
25-
26-
// inline sRGB decode (TODO: Remove this code when https://crbug.com/1256340 is solved)
27-
28-
texColor = 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 );
29-
30-
#endif
31-
3224
texColor.rgb *= backgroundIntensity;
3325
3426
gl_FragColor = texColor;

src/renderers/webgl/WebGLProgram.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,8 +685,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
685685
parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '',
686686
parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '',
687687

688-
parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
689-
690688
parameters.vertexTangents ? '#define USE_TANGENT' : '',
691689
parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '',
692690
parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '',

src/renderers/webgl/WebGLPrograms.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BackSide, DoubleSide, CubeUVReflectionMapping, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping, LinearEncoding, sRGBEncoding, NormalBlending } from '../../constants.js';
1+
import { BackSide, DoubleSide, CubeUVReflectionMapping, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping, LinearEncoding, NormalBlending } from '../../constants.js';
22
import { Layers } from '../../core/Layers.js';
33
import { WebGLProgram } from './WebGLProgram.js';
44
import { WebGLShaderCache } from './WebGLShaderCache.js';
@@ -193,8 +193,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
193193
normalMapObjectSpace: HAS_NORMALMAP && material.normalMapType === ObjectSpaceNormalMap,
194194
normalMapTangentSpace: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap,
195195

196-
decodeVideoTexture: HAS_MAP && ( material.map.isVideoTexture === true ) && ( material.map.encoding === sRGBEncoding ),
197-
198196
metalnessMap: HAS_METALNESSMAP,
199197
roughnessMap: HAS_ROUGHNESSMAP,
200198

@@ -499,12 +497,10 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
499497
_programLayers.enable( 15 );
500498
if ( parameters.sheen )
501499
_programLayers.enable( 16 );
502-
if ( parameters.decodeVideoTexture )
503-
_programLayers.enable( 17 );
504500
if ( parameters.opaque )
505-
_programLayers.enable( 18 );
501+
_programLayers.enable( 17 );
506502
if ( parameters.pointsUvs )
507-
_programLayers.enable( 19 );
503+
_programLayers.enable( 18 );
508504

509505
array.push( _programLayers.mask );
510506

src/renderers/webgl/WebGLTextures.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
701701
glFormat = utils.convert( texture.format, texture.encoding );
702702

703703
let glType = utils.convert( texture.type ),
704-
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding, texture.isVideoTexture );
704+
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
705705

706706
setTextureParameters( textureType, texture, supportsMips );
707707

@@ -1924,7 +1924,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
19241924
const format = texture.format;
19251925
const type = texture.type;
19261926

1927-
if ( texture.isCompressedTexture === true || texture.isVideoTexture === true || texture.format === _SRGBAFormat ) return image;
1927+
if ( texture.isCompressedTexture === true || texture.format === _SRGBAFormat ) return image;
19281928

19291929
if ( encoding !== LinearEncoding ) {
19301930

0 commit comments

Comments
 (0)