Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove handling of WebGL1 seamless cubemap sampling #6356

Merged
merged 3 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/framework/handlers/cubemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ class CubemapHandler extends ResourceHandler {
height: tex.height >> i,
format: tex.format,
levels: [tex._levels[i]],
fixCubemapSeams: true,
addressU: ADDRESS_CLAMP_TO_EDGE,
addressV: ADDRESS_CLAMP_TO_EDGE,
// generate cubemaps on the top level only
Expand Down Expand Up @@ -180,8 +179,7 @@ class CubemapHandler extends ResourceHandler {
magFilter: assetData.hasOwnProperty('magFilter') ? assetData.magFilter : faceTextures[0].magFilter,
anisotropy: assetData.hasOwnProperty('anisotropy') ? assetData.anisotropy : 1,
addressU: ADDRESS_CLAMP_TO_EDGE,
addressV: ADDRESS_CLAMP_TO_EDGE,
fixCubemapSeams: !!assets[0]
addressV: ADDRESS_CLAMP_TO_EDGE
});

resources[0] = faces;
Expand Down
3 changes: 0 additions & 3 deletions src/platform/graphics/texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ class Texture {
* - {@link TEXTURETYPE_SWIZZLEGGGR}
*
* Defaults to {@link TEXTURETYPE_DEFAULT}.
* @param {boolean} [options.fixCubemapSeams] - Specifies whether this cubemap texture requires
* special seam fixing shader code to look right. Defaults to false.
* @param {boolean} [options.flipY] - Specifies whether the texture should be flipped in the
* Y-direction. Only affects textures with a source that is an image, canvas or video element.
* Does not affect cubemaps, compressed textures or textures set from raw pixel data. Defaults
Expand Down Expand Up @@ -215,7 +213,6 @@ class Texture {

this._storage = options.storage ?? false;
this._cubemap = options.cubemap ?? false;
this.fixCubemapSeams = options.fixCubemapSeams ?? false;
this._flipY = options.flipY ?? false;
this._premultiplyAlpha = options.premultiplyAlpha ?? false;

Expand Down
4 changes: 0 additions & 4 deletions src/scene/graphics/env-lighting.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {
} from '../../platform/graphics/constants.js';
import { DebugGraphics } from '../../platform/graphics/debug-graphics.js';

const fixCubemapSeams = true;

// calculate the number of mipmap levels given texture dimensions
const calcLevels = (width, height = 0) => {
return 1 + Math.floor(Math.log2(Math.max(width, height)));
Expand Down Expand Up @@ -46,7 +44,6 @@ const createCubemap = (device, size, format, mipmaps) => {
type: format === PIXELFORMAT_RGBA8 ? RGBA8_TYPE : TEXTURETYPE_DEFAULT,
addressU: ADDRESS_CLAMP_TO_EDGE,
addressV: ADDRESS_CLAMP_TO_EDGE,
fixCubemapSeams: fixCubemapSeams,
mipmaps: !!mipmaps
});
};
Expand Down Expand Up @@ -108,7 +105,6 @@ class EnvLighting {
type: format === PIXELFORMAT_RGBA8 ? RGBA8_TYPE : TEXTURETYPE_DEFAULT,
addressU: ADDRESS_CLAMP_TO_EDGE,
addressV: ADDRESS_CLAMP_TO_EDGE,
fixCubemapSeams: false,
mipmaps: true
});

Expand Down
4 changes: 2 additions & 2 deletions src/scene/graphics/reproject-texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,8 @@ function reprojectTexture(source, target, options = {}) {
const params = [
0,
specularPower,
source.fixCubemapSeams ? 1.0 / source.width : 0.0, // source seam scale
target.fixCubemapSeams ? 1.0 / target.width : 0.0 // target seam scale
0.0, // source seam scale
0.0 // target seam scale
mvaligursky marked this conversation as resolved.
Show resolved Hide resolved
];

const params2 = [
Expand Down
1 change: 0 additions & 1 deletion src/scene/materials/lit-material-options-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ class LitMaterialOptionsBuilder {
litOptions.fog = material.useFog ? scene.fog : 'none';
litOptions.gamma = material.useGammaTonemap ? scene.gammaCorrection : GAMMA_NONE;
litOptions.toneMap = material.useGammaTonemap ? scene.toneMapping : -1;
litOptions.fixSeams = false;

// source of reflections
if (material.useSkybox && scene.envAtlas && scene.skybox) {
Expand Down
1 change: 0 additions & 1 deletion src/scene/materials/standard-material-options-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ class StandardMaterialOptionsBuilder {
options.litOptions.fog = stdMat.useFog ? scene.fog : 'none';
options.litOptions.gamma = stdMat.useGammaTonemap ? scene.gammaCorrection : GAMMA_NONE;
options.litOptions.toneMap = stdMat.useGammaTonemap ? scene.toneMapping : -1;
options.litOptions.fixSeams = (stdMat.cubeMap ? stdMat.cubeMap.fixCubemapSeams : false);

const isPhong = stdMat.shadingModel === SPECULAR_PHONG;

Expand Down
4 changes: 1 addition & 3 deletions src/scene/materials/standard-material.js
Original file line number Diff line number Diff line change
Expand Up @@ -993,9 +993,7 @@ function _defineTex2D(name, channel = "rgb", vertexColor = true, uv = 0) {
defaultValue: null,
dirtyShaderFunc: (oldValue, newValue) => {
return !!oldValue !== !!newValue ||
oldValue && (oldValue.type !== newValue.type ||
oldValue.fixCubemapSeams !== newValue.fixCubemapSeams ||
oldValue.format !== newValue.format);
oldValue && (oldValue.type !== newValue.type || oldValue.format !== newValue.format);
}
});

Expand Down
4 changes: 0 additions & 4 deletions src/scene/shader-lib/chunks/chunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ import extensionPS from './lit/frag/extension.js';
import extensionVS from './lit/vert/extension.js';
import falloffInvSquaredPS from './lit/frag/falloffInvSquared.js';
import falloffLinearPS from './lit/frag/falloffLinear.js';
import fixCubemapSeamsNonePS from './common/frag/fixCubemapSeamsNone.js';
import fixCubemapSeamsStretchPS from './common/frag/fixCubemapSeamsStretch.js';
import floatUnpackingPS from './lit/frag/float-unpacking.js';
import fogExpPS from './lit/frag/fogExp.js';
import fogExp2PS from './lit/frag/fogExp2.js';
Expand Down Expand Up @@ -255,8 +253,6 @@ const shaderChunks = {
extensionVS,
falloffInvSquaredPS,
falloffLinearPS,
fixCubemapSeamsNonePS,
fixCubemapSeamsStretchPS,
floatUnpackingPS,
fogExpPS,
fogExp2PS,
Expand Down
21 changes: 0 additions & 21 deletions src/scene/shader-lib/chunks/common/frag/fixCubemapSeamsNone.js

This file was deleted.

43 changes: 0 additions & 43 deletions src/scene/shader-lib/chunks/common/frag/fixCubemapSeamsStretch.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/scene/shader-lib/chunks/lit/frag/reflectionCube.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uniform samplerCube texture_cubeMap;
uniform float material_reflectivity;

vec3 calcReflection(vec3 reflDir, float gloss) {
vec3 lookupVec = fixSeams(cubeMapProject(reflDir));
vec3 lookupVec = cubeMapProject(reflDir);
lookupVec.x *= -1.0;
return $DECODE(textureCube(texture_cubeMap, lookupVec));
}
Expand Down
2 changes: 1 addition & 1 deletion src/scene/shader-lib/chunks/lit/frag/reflectionEnvHQ.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ vec3 calcReflection(vec3 reflDir, float gloss) {
float ilevel = floor(level);
float flevel = level - ilevel;

vec3 sharp = $DECODE_CUBEMAP(textureCube(texture_cubeMap, fixSeams(dir)));
vec3 sharp = $DECODE_CUBEMAP(textureCube(texture_cubeMap, dir));
vec3 roughA = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel)));
vec3 roughB = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel + 1.0)));

Expand Down
2 changes: 1 addition & 1 deletion src/scene/shader-lib/chunks/skybox/frag/skyboxHDR.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void main(void) {
#endif

dir.x *= -1.0;
vec3 linear = SKYBOX_DECODE_FNC(textureCube(texture_cubeMap, fixSeamsStatic(dir, SKYBOX_MIP)));
vec3 linear = SKYBOX_DECODE_FNC(textureCube(texture_cubeMap, dir));
gl_FragColor = vec4(gammaCorrectOutput(toneMap(processEnvironment(linear))), 1.0);
}
`;
8 changes: 0 additions & 8 deletions src/scene/shader-lib/programs/lit-shader-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,6 @@ class LitShaderOptions {
*/
toneMap = -1;

/**
* If cubemaps require seam fixing (see the `fixCubemapSeams` property of the options object
* passed to the {@link Texture} constructor).
*
* @type {boolean}
*/
fixSeams = false;

/**
* One of "envAtlasHQ", "envAtlas", "cubeMap", "sphereMap".
*
Expand Down
2 changes: 0 additions & 2 deletions src/scene/shader-lib/programs/lit-shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,6 @@ class LitShader {
}

if (options.reflectionSource === 'envAtlasHQ') {
func.append(options.fixSeams ? chunks.fixCubemapSeamsStretchPS : chunks.fixCubemapSeamsNonePS);
func.append(chunks.envAtlasPS);
func.append(chunks.reflectionEnvHQPS
.replace(/\$DECODE_CUBEMAP/g, ChunkUtils.decodeFunc(options.reflectionCubemapEncoding))
Expand All @@ -790,7 +789,6 @@ class LitShader {
func.append(chunks.envAtlasPS);
func.append(chunks.reflectionEnvPS.replace(/\$DECODE/g, ChunkUtils.decodeFunc(options.reflectionEncoding)));
} else if (options.reflectionSource === 'cubeMap') {
func.append(options.fixSeams ? chunks.fixCubemapSeamsStretchPS : chunks.fixCubemapSeamsNonePS);
func.append(chunks.reflectionCubePS.replace(/\$DECODE/g, ChunkUtils.decodeFunc(options.reflectionEncoding)));
} else if (options.reflectionSource === 'sphereMap') {
func.append(chunks.reflectionSpherePS.replace(/\$DECODE/g, ChunkUtils.decodeFunc(options.reflectionEncoding)));
Expand Down
3 changes: 0 additions & 3 deletions src/scene/shader-lib/programs/skybox.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { ShaderGenerator } from './shader-generator.js';
import { SKYTYPE_INFINITE } from '../../constants.js';

const mip2size = [128, 64, /* 32 */ 16, 8, 4, 2];

Check failure on line 9 in src/scene/shader-lib/programs/skybox.js

View workflow job for this annotation

GitHub Actions / Lint

'mip2size' is assigned a value but never used

const fShader = `
#include "decodePS"
Expand All @@ -15,7 +15,6 @@
#include "envMultiplyPS"

#ifdef SKY_CUBEMAP
#include "cubemapSeams"
#include "skyboxHDRPS"
#else
#include "sphericalPS"
Expand All @@ -38,7 +37,6 @@
if (options.skymesh !== SKYTYPE_INFINITE) defines.set('SKYMESH', '');
if (options.type === 'cubemap') {
defines.set('SKY_CUBEMAP', '');
defines.set('SKYBOX_MIP', (1 - 1 / mip2size[options.mip]).toString());
}

// includes
Expand All @@ -49,7 +47,6 @@
includes.set('envMultiplyPS', shaderChunks.envMultiplyPS);

if (options.type === 'cubemap') {
includes.set('cubemapSeams', options.mip ? shaderChunks.fixCubemapSeamsStretchPS : shaderChunks.fixCubemapSeamsNonePS);
includes.set('skyboxHDRPS', shaderChunks.skyboxHDRPS);
} else {
includes.set('sphericalPS', shaderChunks.sphericalPS);
Expand Down
3 changes: 1 addition & 2 deletions src/scene/skybox/sky-mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ class SkyMesh {

if (texture.cubemap) {
options.type = 'cubemap';
options.mip = texture.fixCubemapSeams ? scene.skyboxMip : 0;
options.fixSeams = texture.fixCubemapSeams;
options.mip = scene.skyboxMip;
} else {
options.type = 'envAtlas';
}
Expand Down
Loading