Skip to content

Commit

Permalink
Release 0.137.11
Browse files Browse the repository at this point in the history
  • Loading branch information
nianxy authored and github-actions[bot] committed Nov 27, 2023
1 parent ce8ec7c commit 6e06c77
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 25 deletions.
21 changes: 13 additions & 8 deletions build/three.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,11 @@ class Texture extends EventDispatcher {
this.isRenderTargetTexture = false; // indicates whether a texture belongs to a render target or not

this.needsPMREMUpdate = false; // indicates whether this texture should be processed by PMREMGenerator or not (only relevant for render target textures)
// In WebGL2, sRGB textures can be trancoded to Linear automatically, but reference to this issue: https://github.com/mrdoob/three.js/issues/26183
// there're performance issues when doing this, so you can set the sRGBToLinearWithShader to false to transcode the sRGB texture to Linear with
// shader, especially to those textures that are updated in each frame

this.sRGBToLinearWithShader = !Texture.useSrgbTextures;
}

updateMatrix() {
Expand Down Expand Up @@ -16810,7 +16815,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
_gl.generateMipmap(target);
}

function getInternalFormat(internalFormatName, glFormat, glType, encoding) {
function getInternalFormat(internalFormatName, glFormat, glType, encoding, sRGBToLinearWithShader = !Texture.useSrgbTextures) {
if (isWebGL2 === false) return glFormat;

if (internalFormatName !== null) {
Expand All @@ -16835,7 +16840,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
if (glFormat === _gl.RGBA) {
if (glType === _gl.FLOAT) internalFormat = _gl.RGBA32F;
if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RGBA16F;
if (glType === _gl.UNSIGNED_BYTE) internalFormat = isWebGL2 && Texture.useSrgbTextures && encoding === sRGBEncoding ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
if (glType === _gl.UNSIGNED_BYTE) internalFormat = isWebGL2 && encoding === sRGBEncoding && !sRGBToLinearWithShader ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
if (glType === _gl.UNSIGNED_SHORT_4_4_4_4) internalFormat = _gl.RGBA4;
if (glType === _gl.UNSIGNED_SHORT_5_5_5_1) internalFormat = _gl.RGB5_A1;
}
Expand Down Expand Up @@ -17118,7 +17123,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
const supportsMips = isPowerOfTwo$1(image) || isWebGL2,
glFormat = utils.convert(texture.format, texture.encoding);
let glType = utils.convert(texture.type),
glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding, texture.sRGBToLinearWithShader);
setTextureParameters(textureType, texture, supportsMips);
let mipmap;
const mipmaps = texture.mipmaps;
Expand Down Expand Up @@ -17340,7 +17345,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
supportsMips = isPowerOfTwo$1(image) || isWebGL2,
glFormat = utils.convert(texture.format, texture.encoding),
glType = utils.convert(texture.type),
glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding, texture.sRGBToLinearWithShader);
const useTexStorage = isWebGL2 && texture.isVideoTexture !== true;
const allocateMemory = textureProperties.__version === undefined;
let levels = getMipLevels(texture, image, supportsMips);
Expand Down Expand Up @@ -17440,7 +17445,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
function setupFrameBufferTexture(framebuffer, renderTarget, texture, attachment, textureTarget) {
const glFormat = utils.convert(texture.format, texture.encoding);
const glType = utils.convert(texture.type);
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding, texture.sRGBToLinearWithShader);
const renderTargetProperties = properties.get(renderTarget);

if (!renderTargetProperties.__hasExternalTextures) {
Expand Down Expand Up @@ -17509,7 +17514,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
const texture = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture[0] : renderTarget.texture;
const glFormat = utils.convert(texture.format, texture.encoding);
const glType = utils.convert(texture.type);
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding, texture.sRGBToLinearWithShader);
const samples = getRenderTargetSamples(renderTarget);

if (isMultisample && renderTarget.useRenderbuffer) {
Expand Down Expand Up @@ -17658,7 +17663,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,

const glFormat = utils.convert(texture.format, texture.encoding);
const glType = utils.convert(texture.type);
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding, texture.sRGBToLinearWithShader);
const samples = getRenderTargetSamples(renderTarget);

_gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);
Expand Down Expand Up @@ -19708,7 +19713,7 @@ function WebGLRenderer(parameters = {}) {
encoding = LinearEncoding;
}

if (capabilities.isWebGL2 && Texture.useSrgbTextures && map && map.isTexture && map.format === RGBAFormat && map.type === UnsignedByteType && map.encoding === sRGBEncoding) {
if (capabilities.isWebGL2 && map && map.isTexture && map.format === RGBAFormat && map.type === UnsignedByteType && map.encoding === sRGBEncoding && !map.sRGBToLinearWithShader) {
encoding = LinearEncoding; // disable inline decode for sRGB textures in WebGL 2
}

Expand Down
21 changes: 13 additions & 8 deletions build/three.js
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,11 @@
this.isRenderTargetTexture = false; // indicates whether a texture belongs to a render target or not

this.needsPMREMUpdate = false; // indicates whether this texture should be processed by PMREMGenerator or not (only relevant for render target textures)
// In WebGL2, sRGB textures can be trancoded to Linear automatically, but reference to this issue: https://github.com/mrdoob/three.js/issues/26183
// there're performance issues when doing this, so you can set the sRGBToLinearWithShader to false to transcode the sRGB texture to Linear with
// shader, especially to those textures that are updated in each frame

this.sRGBToLinearWithShader = !Texture.useSrgbTextures;
}

updateMatrix() {
Expand Down Expand Up @@ -16812,7 +16817,7 @@
_gl.generateMipmap(target);
}

function getInternalFormat(internalFormatName, glFormat, glType, encoding) {
function getInternalFormat(internalFormatName, glFormat, glType, encoding, sRGBToLinearWithShader = !Texture.useSrgbTextures) {
if (isWebGL2 === false) return glFormat;

if (internalFormatName !== null) {
Expand All @@ -16837,7 +16842,7 @@
if (glFormat === _gl.RGBA) {
if (glType === _gl.FLOAT) internalFormat = _gl.RGBA32F;
if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RGBA16F;
if (glType === _gl.UNSIGNED_BYTE) internalFormat = isWebGL2 && Texture.useSrgbTextures && encoding === sRGBEncoding ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
if (glType === _gl.UNSIGNED_BYTE) internalFormat = isWebGL2 && encoding === sRGBEncoding && !sRGBToLinearWithShader ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
if (glType === _gl.UNSIGNED_SHORT_4_4_4_4) internalFormat = _gl.RGBA4;
if (glType === _gl.UNSIGNED_SHORT_5_5_5_1) internalFormat = _gl.RGB5_A1;
}
Expand Down Expand Up @@ -17120,7 +17125,7 @@
const supportsMips = isPowerOfTwo$1(image) || isWebGL2,
glFormat = utils.convert(texture.format, texture.encoding);
let glType = utils.convert(texture.type),
glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding, texture.sRGBToLinearWithShader);
setTextureParameters(textureType, texture, supportsMips);
let mipmap;
const mipmaps = texture.mipmaps;
Expand Down Expand Up @@ -17342,7 +17347,7 @@
supportsMips = isPowerOfTwo$1(image) || isWebGL2,
glFormat = utils.convert(texture.format, texture.encoding),
glType = utils.convert(texture.type),
glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding, texture.sRGBToLinearWithShader);
const useTexStorage = isWebGL2 && texture.isVideoTexture !== true;
const allocateMemory = textureProperties.__version === undefined;
let levels = getMipLevels(texture, image, supportsMips);
Expand Down Expand Up @@ -17442,7 +17447,7 @@
function setupFrameBufferTexture(framebuffer, renderTarget, texture, attachment, textureTarget) {
const glFormat = utils.convert(texture.format, texture.encoding);
const glType = utils.convert(texture.type);
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding, texture.sRGBToLinearWithShader);
const renderTargetProperties = properties.get(renderTarget);

if (!renderTargetProperties.__hasExternalTextures) {
Expand Down Expand Up @@ -17511,7 +17516,7 @@
const texture = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture[0] : renderTarget.texture;
const glFormat = utils.convert(texture.format, texture.encoding);
const glType = utils.convert(texture.type);
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding, texture.sRGBToLinearWithShader);
const samples = getRenderTargetSamples(renderTarget);

if (isMultisample && renderTarget.useRenderbuffer) {
Expand Down Expand Up @@ -17660,7 +17665,7 @@

const glFormat = utils.convert(texture.format, texture.encoding);
const glType = utils.convert(texture.type);
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding, texture.sRGBToLinearWithShader);
const samples = getRenderTargetSamples(renderTarget);

_gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);
Expand Down Expand Up @@ -19710,7 +19715,7 @@
encoding = LinearEncoding;
}

if (capabilities.isWebGL2 && Texture.useSrgbTextures && map && map.isTexture && map.format === RGBAFormat && map.type === UnsignedByteType && map.encoding === sRGBEncoding) {
if (capabilities.isWebGL2 && map && map.isTexture && map.format === RGBAFormat && map.type === UnsignedByteType && map.encoding === sRGBEncoding && !map.sRGBToLinearWithShader) {
encoding = LinearEncoding; // disable inline decode for sRGB textures in WebGL 2
}

Expand Down
2 changes: 1 addition & 1 deletion build/three.min.js

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions build/three.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,11 @@ class Texture extends EventDispatcher {
this.isRenderTargetTexture = false; // indicates whether a texture belongs to a render target or not
this.needsPMREMUpdate = false; // indicates whether this texture should be processed by PMREMGenerator or not (only relevant for render target textures)

// In WebGL2, sRGB textures can be trancoded to Linear automatically, but reference to this issue: https://github.com/mrdoob/three.js/issues/26183
// there're performance issues when doing this, so you can set the sRGBToLinearWithShader to false to transcode the sRGB texture to Linear with
// shader, especially to those textures that are updated in each frame
this.sRGBToLinearWithShader = ! Texture.useSrgbTextures;

}

updateMatrix() {
Expand Down Expand Up @@ -22494,7 +22499,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

}

function getInternalFormat( internalFormatName, glFormat, glType, encoding ) {
function getInternalFormat( internalFormatName, glFormat, glType, encoding, sRGBToLinearWithShader = ! Texture.useSrgbTextures ) {

if ( isWebGL2 === false ) return glFormat;

Expand Down Expand Up @@ -22528,7 +22533,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

if ( glType === 5126 ) internalFormat = 34836;
if ( glType === 5131 ) internalFormat = 34842;
if ( glType === 5121 ) internalFormat = ( isWebGL2 && Texture.useSrgbTextures && encoding === sRGBEncoding ) ? 35907 : 32856;
if ( glType === 5121 ) internalFormat = ( isWebGL2 && encoding === sRGBEncoding && ! sRGBToLinearWithShader ) ? 35907 : 32856;
if ( glType === 32819 ) internalFormat = 32854;
if ( glType === 32820 ) internalFormat = 32855;

Expand Down Expand Up @@ -22925,7 +22930,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
glFormat = utils.convert( texture.format, texture.encoding );

let glType = utils.convert( texture.type ),
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding, texture.sRGBToLinearWithShader );

setTextureParameters( textureType, texture, supportsMips );

Expand Down Expand Up @@ -23284,7 +23289,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
supportsMips = isPowerOfTwo$1( image ) || isWebGL2,
glFormat = utils.convert( texture.format, texture.encoding ),
glType = utils.convert( texture.type ),
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding, texture.sRGBToLinearWithShader );

const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
const allocateMemory = ( textureProperties.__version === undefined );
Expand Down Expand Up @@ -23449,7 +23454,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

const glFormat = utils.convert( texture.format, texture.encoding );
const glType = utils.convert( texture.type );
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding, texture.sRGBToLinearWithShader );
const renderTargetProperties = properties.get( renderTarget );

if ( ! renderTargetProperties.__hasExternalTextures ) {
Expand Down Expand Up @@ -23557,7 +23562,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

const glFormat = utils.convert( texture.format, texture.encoding );
const glType = utils.convert( texture.type );
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding, texture.sRGBToLinearWithShader );
const samples = getRenderTargetSamples( renderTarget );

if ( isMultisample && renderTarget.useRenderbuffer ) {
Expand Down Expand Up @@ -23782,7 +23787,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

const glFormat = utils.convert( texture.format, texture.encoding );
const glType = utils.convert( texture.type );
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding, texture.sRGBToLinearWithShader );
const samples = getRenderTargetSamples( renderTarget );
_gl.renderbufferStorageMultisample( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height );

Expand Down Expand Up @@ -26667,7 +26672,7 @@ function WebGLRenderer( parameters = {} ) {

}

if ( capabilities.isWebGL2 && Texture.useSrgbTextures && map && map.isTexture && map.format === RGBAFormat && map.type === UnsignedByteType && map.encoding === sRGBEncoding ) {
if ( capabilities.isWebGL2 && map && map.isTexture && map.format === RGBAFormat && map.type === UnsignedByteType && map.encoding === sRGBEncoding && ! map.sRGBToLinearWithShader ) {

encoding = LinearEncoding; // disable inline decode for sRGB textures in WebGL 2

Expand Down

0 comments on commit 6e06c77

Please sign in to comment.