Browse Source

limit color smoothing to group-based themes

Alexander Rose 3 years ago
parent
commit
b7935de7af

+ 2 - 9
src/mol-geo/geometry/mesh/color-smoothing.ts

@@ -19,18 +19,13 @@ interface ColorSmoothingInput {
     positionBuffer: Float32Array
     groupBuffer: Float32Array
     colorData: TextureImage<Uint8Array>
-    colorType: 'group' | 'groupInstance' | 'vertex' | 'vertexInstance'
+    colorType: 'group' | 'groupInstance'
     boundingSphere: Sphere3D
     invariantBoundingSphere: Sphere3D
 }
 
 export function calcMeshColorSmoothing(webgl: WebGLContext, input: ColorSmoothingInput, resolution: number, stride: number) {
-    if (!input.colorType.startsWith('group') && !input.colorType.startsWith('vertex')) {
-        throw new Error('unsupported color type');
-    };
-
     const isInstanceType = input.colorType.endsWith('Instance');
-    const isVertexColor = input.colorType.startsWith('vertex');
     const box = Box3D.fromSphere3D(Box3D(), isInstanceType ? input.boundingSphere : input.invariantBoundingSphere);
 
     const scaleFactor = 1 / resolution;
@@ -84,9 +79,7 @@ export function calcMeshColorSmoothing(webgl: WebGLContext, input: ColorSmoothin
             const z = Math.floor(vz);
 
             // group colors
-            const ci = isVertexColor
-                ? i * vertexCount + j
-                : i * groupCount + groups[j];
+            const ci = i * groupCount + groups[j];
             const r = colors[ci * 3];
             const g = colors[ci * 3 + 1];
             const b = colors[ci * 3 + 2];

+ 1 - 5
src/mol-geo/geometry/texture-mesh/color-smoothing.ts

@@ -59,7 +59,7 @@ interface AccumulateInput {
     positionTexture: Texture
     groupTexture: Texture
     colorData: TextureImage<Uint8Array>
-    colorType: 'group' | 'groupInstance' | 'vertex' | 'vertexInstance'
+    colorType: 'group' | 'groupInstance'
 }
 
 function getSampleBuffer(sampleCount: number, stride: number) {
@@ -244,10 +244,6 @@ interface ColorSmoothingInput extends AccumulateInput {
 }
 
 export function calcTextureMeshColorSmoothing(webgl: WebGLContext, input: ColorSmoothingInput, resolution: number, stride: number, texture?: Texture) {
-    if (!input.colorType.startsWith('group') && !input.colorType.startsWith('vertex')) {
-        throw new Error('unsupported color type');
-    };
-
     const { gl, resources, state, extensions: { colorBufferHalfFloat, textureHalfFloat } } = webgl;
 
     const isInstanceType = input.colorType.endsWith('Instance');

+ 0 - 4
src/mol-gl/shader/compute/color-smoothing/accumulate.vert.ts

@@ -46,10 +46,6 @@ void main() {
         vColor = readFromTexture(tColor, group, uColorTexDim).rgb;
     #elif defined(dColorType_groupInstance)
         vColor = readFromTexture(tColor, aInstance * float(uGroupCount) + group, uColorTexDim).rgb;
-    #elif defined(dColorType_vertex)
-        vColor = readFromTexture(tColor, SampleID, uColorTexDim).rgb;
-    #elif defined(dColorType_vertexInstance)
-        vColor = readFromTexture(tColor, int(aInstance) * uTotalCount + SampleID, uColorTexDim).rgb;
     #endif
 }
 `;

+ 2 - 2
src/mol-repr/structure/visual/util/color.ts

@@ -12,8 +12,8 @@ import { WebGLContext } from '../../../../mol-gl/webgl/context';
 import { Texture } from '../../../../mol-gl/webgl/texture';
 import { ValueCell } from '../../../../mol-util';
 
-function isSupportedColorType(x: string): x is 'group' | 'groupInstance' | 'vertex' | 'vertexInstance' {
-    return x === 'group' || x === 'groupInstance' || x === 'vertex' || x === 'vertexInstance';
+function isSupportedColorType(x: string): x is 'group' | 'groupInstance' {
+    return x === 'group' || x === 'groupInstance';
 }
 
 export function applyMeshColorSmoothing(webgl: WebGLContext, values: MeshValues, resolution: number) {