Skip to content

Commit

Permalink
Revert "WebGLRenderer: Enable usage of SRGB8_ALPHA8 again. (mrdoob#…
Browse files Browse the repository at this point in the history
…22952)"

This reverts commit 25c7f7a.
  • Loading branch information
chubei-oppen committed Jan 14, 2022
1 parent 70e3720 commit e884099
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
5 changes: 3 additions & 2 deletions examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SlotNode from './SlotNode.js';
import GLSLNodeParser from '../../nodes/parsers/GLSLNodeParser.js';
import WebGLPhysicalContextNode from './WebGLPhysicalContextNode.js';

import { ShaderChunk, LinearEncoding, RGBAFormat, UnsignedByteType, sRGBEncoding } from '../../../../../build/three.module.js';
import { ShaderChunk /*, LinearEncoding, RGBAFormat, UnsignedByteType, sRGBEncoding */ } from '../../../../../build/three.module.js';

const shaderStages = [ 'vertex', 'fragment' ];

Expand Down Expand Up @@ -286,14 +286,15 @@ class WebGLNodeBuilder extends NodeBuilder {

getTextureEncodingFromMap( map ) {

/*
const isWebGL2 = this.renderer.capabilities.isWebGL2;
if ( isWebGL2 && map && map.isTexture && map.format === RGBAFormat && map.type === UnsignedByteType && map.encoding === sRGBEncoding ) {
return LinearEncoding; // disable inline decode for sRGB textures in WebGL 2
}

*/
return super.getTextureEncodingFromMap( map );

}
Expand Down
Binary file modified examples/screenshots/webgl_loader_md2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions src/extras/PMREMGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
NearestFilter,
NoBlending,
RGBEEncoding,
RGBAFormat,
RGBEFormat,
UnsignedByteType,
sRGBEncoding
Expand Down Expand Up @@ -345,15 +344,17 @@ class PMREMGenerator {

_setEncoding( uniform, texture ) {

if ( this._renderer.capabilities.isWebGL2 === true && texture.format === RGBAFormat && texture.type === UnsignedByteType && texture.encoding === sRGBEncoding ) {
/* if ( this._renderer.capabilities.isWebGL2 === true && texture.format === RGBAFormat && texture.type === UnsignedByteType && texture.encoding === sRGBEncoding ) {
uniform.value = ENCODINGS[ LinearEncoding ];
} else {
uniform.value = ENCODINGS[ texture.encoding ];
}
} */

uniform.value = ENCODINGS[ texture.encoding ];

}

Expand Down
6 changes: 3 additions & 3 deletions src/renderers/webgl/WebGLPrograms.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BackSide, DoubleSide, CubeUVRefractionMapping, CubeUVReflectionMapping, LinearEncoding, sRGBEncoding, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping, RGBAFormat, UnsignedByteType } from '../../constants.js';
import { BackSide, DoubleSide, CubeUVRefractionMapping, CubeUVReflectionMapping, LinearEncoding, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping } from '../../constants.js';
import { Layers } from '../../core/Layers.js';
import { WebGLProgram } from './WebGLProgram.js';
import { WebGLShaderCache } from './WebGLShaderCache.js';
Expand Down Expand Up @@ -91,11 +91,11 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities

}

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

return encoding;

Expand Down
8 changes: 5 additions & 3 deletions src/renderers/webgl/WebGLTextures.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, sRGBEncoding } from '../../constants.js';
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping } from '../../constants.js';
import * as MathUtils from '../../math/MathUtils.js';
import { createElementNS } from '../../utils.js';

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

}

function getInternalFormat( internalFormatName, glFormat, glType, encoding ) {
function getInternalFormat( internalFormatName, glFormat, glType/*, encoding*/ ) {

if ( isWebGL2 === false ) return glFormat;

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

if ( glType === _gl.FLOAT ) internalFormat = _gl.RGBA32F;
if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGBA16F;
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( encoding === sRGBEncoding ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
//if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( encoding === sRGBEncoding ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGBA8;


}

Expand Down

0 comments on commit e884099

Please sign in to comment.