Skip to content

Commit

Permalink
WebGLRenderer: Disable usage of SRGB8_ALPHA8. (#22759)
Browse files Browse the repository at this point in the history
* WebGLRenderer: Disable usage of SRGB8_ALPHA8 .

* Update screenshot.

* Clean up.
  • Loading branch information
Mugen87 authored Nov 10, 2021
1 parent 78a5832 commit 9030827
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
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 @@ -10,7 +10,6 @@ import {
RGBDEncoding,
RGBEEncoding,
RGBEFormat,
RGBAFormat,
RGBM16Encoding,
RGBM7Encoding,
UnsignedByteType,
Expand Down Expand Up @@ -350,15 +349,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 { WebGLProgram } from './WebGLProgram.js';
import { ShaderLib } from '../shaders/ShaderLib.js';
import { UniformsUtils } from '../shaders/UniformsUtils.js';
Expand Down Expand Up @@ -108,11 +108,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 @@ -128,7 +128,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 @@ -162,7 +162,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 9030827

Please sign in to comment.