MCPcopy
hub / github.com/sparkjsdev/spark / maybeLookupIndex

Function maybeLookupIndex

src/SplatMesh.ts:1197–1245  ·  view source on GitHub ↗
(
  lodIndices: DynoUsampler2D<"lodIndices", THREE.DataTexture>,
  index: DynoVal<"int">,
  numSplats: DynoVal<"int">,
  enableLod: DynoVal<"bool">,
  showLodPage: DynoVal<"int">,
)

Source from the content-addressed store, hash-verified

1195}
1196
1197export function maybeLookupIndex(
1198 lodIndices: DynoUsampler2D<"lodIndices", THREE.DataTexture>,
1199 index: DynoVal<"int">,
1200 numSplats: DynoVal<"int">,
1201 enableLod: DynoVal<"bool">,
1202 showLodPage: DynoVal<"int">,
1203) {
1204 return dyno({
1205 inTypes: {
1206 lodIndices: "usampler2D",
1207 index: "int",
1208 numSplats: "int",
1209 enableLod: "bool",
1210 showLodPage: "int",
1211 },
1212 outTypes: {
1213 index: "int",
1214 },
1215 inputs: {
1216 lodIndices,
1217 index,
1218 numSplats,
1219 enableLod,
1220 showLodPage,
1221 },
1222 statements: ({ inputs, outputs }) =>
1223 unindentLines(`
1224 int index = ${inputs.index};
1225 if (${inputs.showLodPage} < 0) {
1226 if (index >= ${inputs.numSplats}) {
1227 return;
1228 }
1229 if (${inputs.enableLod}) {
1230 ivec2 lodIndexCoord = ivec2((index >> 2) & 4095, index >> 14);
1231 uint splatIndex = texelFetch(${inputs.lodIndices}, lodIndexCoord, 0)[index & 3];
1232 ${outputs.index} = int(splatIndex);
1233 } else {
1234 ${outputs.index} = index;
1235 }
1236 } else {
1237 int start = ${inputs.showLodPage} << 16;
1238 if (index >= 65536) {
1239 return;
1240 }
1241 ${outputs.index} = start + index;
1242 }
1243 `),
1244 }).outputs.index;
1245}
1246
1247export function maybeInjectSplatRgba(
1248 gsplat: DynoVal<typeof Gsplat>,

Callers 2

constructGeneratorMethod · 0.85
constructCovGeneratorMethod · 0.85

Calls 2

dynoFunction · 0.90
unindentLinesFunction · 0.90

Tested by

no test coverage detected