Browse Source

webgl, ensure active attribute with divisor 0

- workaround for FF <85
- needed for `texture-mesh` geometry
Alexander Rose 4 years ago
parent
commit
77d013b775

+ 3 - 3
src/mol-gl/compute/marching-cubes/isosurface.ts

@@ -195,17 +195,17 @@ export function createIsosurfaceBuffers(ctx: WebGLContext, activeVoxelsBase: Tex
 export function extractIsosurface(ctx: WebGLContext, volumeData: Texture, gridDim: Vec3, gridTexDim: Vec3, gridTexScale: Vec2, transform: Mat4, isoValue: number, packedGroup: boolean, vertexTexture?: Texture, groupTexture?: Texture, normalTexture?: Texture) {
     // console.time('calcActiveVoxels');
     const activeVoxelsTex = calcActiveVoxels(ctx, volumeData, gridDim, gridTexDim, isoValue, gridTexScale);
-    // ctx.webgl.waitForGpuCommandsCompleteSync();
+    // ctx.waitForGpuCommandsCompleteSync();
     // console.timeEnd('calcActiveVoxels');
 
     // console.time('createHistogramPyramid');
     const compacted = createHistogramPyramid(ctx, activeVoxelsTex, gridTexScale, gridTexDim);
-    // ctx.webgl.waitForGpuCommandsCompleteSync();
+    // ctx.waitForGpuCommandsCompleteSync();
     // console.timeEnd('createHistogramPyramid');
 
     // console.time('createIsosurfaceBuffers');
     const gv = createIsosurfaceBuffers(ctx, activeVoxelsTex, volumeData, compacted, gridDim, gridTexDim, transform, isoValue, packedGroup, vertexTexture, groupTexture, normalTexture);
-    // ctx.webgl.waitForGpuCommandsCompleteSync();
+    // ctx.waitForGpuCommandsCompleteSync();
     // console.timeEnd('createIsosurfaceBuffers');
 
     return gv;

+ 7 - 1
src/mol-gl/shader/chunks/common-vert-params.glsl.ts

@@ -41,6 +41,12 @@ varying vec3 vViewPosition;
     attribute float aVertex;
     #define VertexID int(aVertex)
 #else
-    #define VertexID gl_VertexID
+    // not using gl_VertexID but aVertex to ensure there is an active attribute with divisor 0
+    // since FF 85 this is not needed anymore but lets keep it for backwards compatibility
+    // https://bugzilla.mozilla.org/show_bug.cgi?id=1679693
+    // see also note in src/mol-gl/webgl/render-item.ts
+    attribute float aVertex;
+    #define VertexID int(aVertex)
+    // #define VertexID gl_VertexID
 #endif
 `;

+ 6 - 1
src/mol-gl/webgl/render-item.ts

@@ -112,7 +112,12 @@ export function createRenderItem<T extends string>(ctx: WebGLContext, drawMode:
     const { instancedArrays, vertexArrayObject } = ctx.extensions;
 
     // emulate gl_VertexID when needed
-    if (!ctx.isWebGL2 && values.uVertexCount) {
+    // if (!ctx.isWebGL2 && values.uVertexCount) {
+    // not using gl_VertexID in WebGL2 but aVertex to ensure there is an active attribute with divisor 0
+    // since FF 85 this is not needed anymore but lets keep it for backwards compatibility
+    // https://bugzilla.mozilla.org/show_bug.cgi?id=1679693
+    // see also note in src/mol-gl/shader/chunks/common-vert-params.glsl.ts
+    if (values.uVertexCount) {
         const vertexCount = values.uVertexCount.ref.value;
         (values as any).aVertex = ValueCell.create(fillSerial(new Float32Array(vertexCount)));
         (schema as any).aVertex = AttributeSpec('float32', 1, 0);