How to access primitive_index with WebGPU TSL

Hello, is it possible to access primitive_index or declare builtin(primitive_index) with WEBGPU TSL ? I wanted to use this code without creating primitive index buffer or using non indexed geometry.

import {

Fn,

vec4,

float,

min

} from ‘three/tsl’;

const lineWidth = float(0.02);

const fragmentNode = Fn(() => {

const primID = primitiveIndex();

const mask = edgeMasks.element(primID);

const edgeDist = float(1.0);

let edge = edgeDist;

edge = min(edge, edgeDist).select(mask.bitAnd(uint(1)).notEqual(uint(0)));

edge = min(edge, edgeDist).select(mask.bitAnd(uint(2)).notEqual(uint(0)));

edge = min(edge, edgeDist).select(mask.bitAnd(uint(4)).notEqual(uint(0)));

const isEdge = edge.lessThan(lineWidth);

const surfaceColor = vec3(0.4, 0.6, 1.0);

const edgeColor = vec3(0.0, 0.0, 0.0);

const finalColor = surfaceColor.mix(edgeColor, isEdge);

return vec4(finalColor, 1.0);

});

If primitive_index is not represented as a node in TSL, you might be (or not be) able to access it via wgslFn, rather than Fn. However, wgslFn is brutally incompatible with WebGL2 backend.

Take this with a huge grain of salt.

Thanks for reply. For some reason I thought that primitive index is base line supported by WebGPU but that is not the case.