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);
});