Skip to content

Commit

Permalink
added splat indexes to vertex attributes
Browse files Browse the repository at this point in the history
updates geometry pipeline stage to use modelutility to find attributes
  • Loading branch information
keyboardspecialist committed Jan 24, 2025
1 parent 8183132 commit 933c3e3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
29 changes: 19 additions & 10 deletions packages/engine/Source/Scene/Model/GeometryPipelineStage.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,27 @@ GeometryPipelineStage.process = function (
model?.style?.showGaussianSplatting ?? model.showGaussianSplatting;

if (gaussianSplatsEnabled === true) {
primitive.attributes.find((a) => a.name === "POSITION").instanceDivisor =
showSplats ? 1 : 0;
primitive.attributes.find((a) => a.name === "_SCALE").instanceDivisor =
showSplats ? 1 : 0;
primitive.attributes.find((a) => a.name === "_ROTATION").instanceDivisor =
showSplats ? 1 : 0;
primitive.attributes.find((a) => a.name === "COLOR_0").instanceDivisor =
showSplats ? 1 : 0;
ModelUtility.getAttributeBySemantic(
primitive,
VertexAttributeSemantic.POSITION,
).instanceDivisor = showSplats ? 1 : 0;
ModelUtility.getAttributeBySemantic(
primitive,
VertexAttributeSemantic.SCALE,
).instanceDivisor = showSplats ? 1 : 0;
ModelUtility.getAttributeBySemantic(
primitive,
VertexAttributeSemantic.ROTATION,
).instanceDivisor = showSplats ? 1 : 0;
ModelUtility.getAttributeBySemantic(
primitive,
VertexAttributeSemantic.COLOR,
).instanceDivisor = showSplats ? 1 : 0;

if (primitive.hasGaussianSplatTexture) {
primitive.attributes.find(
(a) => a.name === "_SPLAT_INDEXES",
ModelUtility.getAttributeBySemantic(
primitive,
VertexAttributeSemantic.SPLAT_INDEXES,
).instanceDivisor = showSplats ? 1 : 0;
}

Expand Down
14 changes: 14 additions & 0 deletions packages/engine/Source/Scene/VertexAttributeSemantic.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ const VertexAttributeSemantic = {
* @constant
*/
ROTATION: "_ROTATION",
/**
* Gaussian Splat Attribute Texture Index
*
* @type {string}
* @constant
*/
SPLAT_INDEXES: "_SPLAT_INDEXES",
};

function semanticToVariableName(semantic) {
Expand All @@ -111,6 +118,8 @@ function semanticToVariableName(semantic) {
return "scale";
case VertexAttributeSemantic.ROTATION:
return "rotation";
case VertexAttributeSemantic.SPLAT_INDEXES:
return "splatIndex";
//>>includeStart('debug', pragmas.debug);
default:
throw new DeveloperError("semantic is not a valid value.");
Expand Down Expand Up @@ -144,6 +153,7 @@ VertexAttributeSemantic.hasSetIndex = function (semantic) {
case VertexAttributeSemantic.FEATURE_ID:
case VertexAttributeSemantic.SCALE:
case VertexAttributeSemantic.ROTATION:
case VertexAttributeSemantic.SPLAT_INDEXES:
return true;
//>>includeStart('debug', pragmas.debug);
default:
Expand Down Expand Up @@ -196,6 +206,8 @@ VertexAttributeSemantic.fromGltfSemantic = function (gltfSemantic) {
return VertexAttributeSemantic.SCALE;
case "_ROTATION":
return VertexAttributeSemantic.ROTATION;
case "_SPLAT_INDEXES":
return VertexAttributeSemantic.SPLAT_INDEXES;
}

return undefined;
Expand Down Expand Up @@ -269,6 +281,8 @@ VertexAttributeSemantic.getGlslType = function (semantic) {
return "vec3";
case VertexAttributeSemantic.ROTATION:
return "vec4";
case VertexAttributeSemantic.SPLAT_INDEXES:
return "int";
//>>includeStart('debug', pragmas.debug);
default:
throw new DeveloperError("semantic is not a valid value.");
Expand Down

0 comments on commit 933c3e3

Please sign in to comment.