diff --git a/CHANGELOG.md b/CHANGELOG.md index e58412c8838d57cc0cff4d6ec439c9072a093555..5792f31a722426742b53f5790ed763bd0f6dc3b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Note that since we don't clearly distinguish between a public and private interf - Fix wrong offset when rendering text with orthographic projection - Update camera/handle helper when `devicePixelRatio` changes - Add various options to customize the axes camera-helper +- Fix issue with texture-mesh color smoothing when changing themes ## [v3.30.0] - 2023-01-29 diff --git a/src/mol-geo/geometry/texture-mesh/color-smoothing.ts b/src/mol-geo/geometry/texture-mesh/color-smoothing.ts index 8633a1a0577876f532dc4d7c5ae0efe8a8cac1b2..7cfc6b4e7d4e400bbed55f71b94ee4af18530963 100644 --- a/src/mol-geo/geometry/texture-mesh/color-smoothing.ts +++ b/src/mol-geo/geometry/texture-mesh/color-smoothing.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2021-2023 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -7,7 +7,7 @@ import { ValueCell } from '../../../mol-util'; import { createComputeRenderable, ComputeRenderable } from '../../../mol-gl/renderable'; import { WebGLContext } from '../../../mol-gl/webgl/context'; -import { Texture } from '../../../mol-gl/webgl/texture'; +import { isNullTexture, Texture } from '../../../mol-gl/webgl/texture'; import { ShaderCode } from '../../../mol-gl/shader-code'; import { createComputeRenderItem } from '../../../mol-gl/webgl/render-item'; import { ValueSpec, AttributeSpec, UniformSpec, TextureSpec, Values, DefineSpec } from '../../../mol-gl/renderable/schema'; @@ -267,7 +267,7 @@ export function calcTextureMeshColorSmoothing(input: ColorSmoothingInput, resolu const [dx, dy, dz] = gridDim; const { texDimX: width, texDimY: height, texCols } = getTexture2dSize(gridDim); - // console.log({ width, height, texCols, dim, resolution }); + // console.log({ width, height, texCols, gridDim, resolution }); if (!webgl.namedFramebuffers[ColorAccumulateName]) { webgl.namedFramebuffers[ColorAccumulateName] = webgl.resources.framebuffer(); @@ -363,7 +363,9 @@ export function calcTextureMeshColorSmoothing(input: ColorSmoothingInput, resolu // normalize if (isTimingMode) webgl.timer.mark('ColorNormalize.render'); - if (!texture) texture = resources.texture('image-uint8', 'rgba', 'ubyte', 'linear'); + if (!texture || isNullTexture(texture)) { + texture = resources.texture('image-uint8', 'rgba', 'ubyte', 'linear'); + } texture.define(width, height); const normalizeRenderable = getNormalizeRenderable(webgl, accumulateTexture, countTexture); diff --git a/src/mol-gl/webgl/texture.ts b/src/mol-gl/webgl/texture.ts index d12c95d1c5ad65d52202c3ca14470c8931ac8603..c0f6298e27b7ad0e0f1a148cf1f15588fa040568 100644 --- a/src/mol-gl/webgl/texture.ts +++ b/src/mol-gl/webgl/texture.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2023 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Gianluca Tomasello <giagitom@gmail.com> @@ -554,12 +554,18 @@ export function createCubeTexture(gl: GLRenderingContext, faces: CubeFaces, mipm // +const NullTextureFormat = -1; + +export function isNullTexture(texture: Texture) { + return texture.format === NullTextureFormat; +} + export function createNullTexture(gl?: GLRenderingContext): Texture { const target = gl?.TEXTURE_2D ?? 3553; return { id: getNextTextureId(), target, - format: 0, + format: NullTextureFormat, internalFormat: 0, type: 0, filter: 0, @@ -583,8 +589,12 @@ export function createNullTexture(gl?: GLRenderingContext): Texture { gl.bindTexture(target, null); } }, - attachFramebuffer: () => {}, - detachFramebuffer: () => {}, + attachFramebuffer: () => { + throw new Error('cannot attach null-texture to a framebuffer'); + }, + detachFramebuffer: () => { + throw new Error('cannot detach null-texture from a framebuffer'); + }, reset: () => {}, destroy: () => {},