Skip to content

Commit

Permalink
Merge pull request #293 from CesiumGS/channel-mismatch-warning
Browse files Browse the repository at this point in the history
Only issue a warning for channel mismatches
  • Loading branch information
lilleyse authored Jan 2, 2024
2 parents 5656f67 + 6a88152 commit 05c710b
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Version ?.?.? - yyyy-mm-dd

- The maximum number of issues that are reported for a single glTF asset is now limited (via [#291](https://github.com/CesiumGS/3d-tiles-validator/pull/291)).
- When the number of bytes that are required for a certain property texture property did not match the number of `channels`, then the validator reported this as an `ERROR`, with the type `TEXTURE_CHANNELS_OUT_OF_RANGE`. This could cause errors to be reported for the case of 16-bit channels in textures, where these numbers do not have to match. Now, these cases are only reported as a `WARNING`, of the type `TEXTURE_CHANNELS_SIZE_MISMATCH`.

Version 0.5.0 - 2023-10-24

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
{
"extensions" : {
"EXT_structural_metadata" : {
"schema" : {
"id": "SimplePropertyTextureSchema",
"classes" : {
"buildingComponents" : {
"name" : "Building properties",
"properties" : {
"insideTemperature" : {
"name" : "Inside Temperature",
"type" : "SCALAR",
"componentType" : "UINT8"
},
"outsideTemperature" : {
"name" : "Outside Temperature",
"type" : "SCALAR",
"componentType" : "UINT8"
},
"insulation" : {
"name" : "Insulation Thickness",
"type" : "SCALAR",
"componentType" : "UINT16",
"normalized" : true
}
}
}
}
},
"propertyTextures" : [ {
"class" : "buildingComponents",
"properties" : {
"insideTemperature" : {
"index" : 1,
"texCoord" : 0,
"channels" : [ 0 ]
},
"outsideTemperature" : {
"index" : 1,
"texCoord" : 0,
"channels" : [ 1 ]
},
"insulation" : {
"index" : 1,
"texCoord" : 0,
"channels" : [ 2 ]
}
}
} ]
}
},
"extensionsUsed" : [ "EXT_structural_metadata" ],
"accessors" : [ {
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 6,
"type" : "SCALAR",
"max" : [ 3 ],
"min" : [ 0 ]
}, {
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 4,
"type" : "VEC3",
"max" : [ 1.0, 1.0, 0.0 ],
"min" : [ 0.0, 0.0, 0.0 ]
}, {
"bufferView" : 2,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 4,
"type" : "VEC3",
"max" : [ 0.0, 0.0, 1.0 ],
"min" : [ 0.0, 0.0, 1.0 ]
}, {
"bufferView" : 3,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 4,
"type" : "VEC2",
"max" : [ 1.0, 1.0 ],
"min" : [ 0.0, 0.0 ]
} ],
"asset" : {
"generator" : "JglTF from https://github.com/javagl/JglTF",
"version" : "2.0"
},
"buffers" : [ {
"uri" : "data:application/gltf-buffer;base64,AAABAAIAAQADAAIAAAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAgD8AAAAAAACAPwAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAgD8AAIA/AACAPwAAAAAAAAAAAACAPwAAAAA=",
"byteLength" : 140
} ],
"bufferViews" : [ {
"buffer" : 0,
"byteOffset" : 0,
"byteLength" : 12,
"target" : 34963
}, {
"buffer" : 0,
"byteOffset" : 12,
"byteLength" : 48,
"target" : 34962
}, {
"buffer" : 0,
"byteOffset" : 60,
"byteLength" : 48,
"target" : 34962
}, {
"buffer" : 0,
"byteOffset" : 108,
"byteLength" : 32,
"target" : 34962
} ],
"images" : [ {
"uri" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAIvklEQVR42u3csW5URxsG4BHBRRoklxROEQlSRCJCKShoXFJZiDSpQEqX2pYii8ZVlDZF7oNcAAURDREdpCEXQKoIlAKFEE3O4s0KoV17zxm8Z+Z8j6zvj6Nfj7Q663k968y8aXd3NxtjYk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8Jo7KKK8/uo4dxreHe0/HgF2/IqBen/za+Di69Sf8cZz5jmk+hcuhdd2tWLz8IE5MbFnRWT+yyU5vZJRtAOqlvq6MDeOrstu0UidsoO0Ak9xGwE+67+34salNEBSCxX7Bexg0rbq6TFvwAAAABJRU5ErkJggg==",
"mimeType" : "image/png"
} ],
"materials" : [ {
"pbrMetallicRoughness" : {
"baseColorFactor" : [ 1.0, 1.0, 1.0, 1.0 ],
"baseColorTexture" : {
"index" : 0,
"texCoord" : 0
},
"metallicFactor" : 0.0,
"roughnessFactor" : 1.0
},
"alphaMode" : "OPAQUE",
"doubleSided" : true
} ],
"meshes" : [ {
"primitives" : [ {
"extensions" : {
"EXT_structural_metadata" : {
"propertyTextures" : [ 0 ]
}
},
"attributes" : {
"POSITION" : 1,
"NORMAL" : 2,
"TEXCOORD_0" : 3
},
"indices" : 0,
"material" : 0,
"mode" : 4
} ]
} ],
"nodes" : [ {
"mesh" : 0
} ],
"samplers" : [ {
"magFilter" : 9728,
"minFilter" : 9728
} ],
"scene" : 0,
"scenes" : [ {
"nodes" : [ 0 ]
} ],
"textures" : [ {
"sampler" : 0,
"source" : 0
}, {
"sampler" : 0,
"source" : 1
} ]
}
8 changes: 8 additions & 0 deletions specs/gltfExtensions/ExtStructuralMetadataValidationSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ describe("EXT_structural_metadata extension validation", function () {
expect(result.get(0).type).toEqual("IDENTIFIER_NOT_FOUND");
});

it("detects issues in PropertyTexturePropertyChannelsSizeMismatch", async function () {
const result = await validateGltf(
"./specs/data/gltfExtensions/structuralMetadata/PropertyTexturePropertyChannelsSizeMismatch.gltf"
);
expect(result.length).toEqual(1);
expect(result.get(0).type).toEqual("TEXTURE_CHANNELS_SIZE_MISMATCH");
});

it("detects issues in PropertyTexturePropertyIndexInvalidType", async function () {
const result = await validateGltf(
"./specs/data/gltfExtensions/structuralMetadata/PropertyTexturePropertyIndexInvalidType.gltf"
Expand Down
26 changes: 21 additions & 5 deletions src/issues/GltfExtensionValidationIssues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ export class GltfExtensionValidationIssues {
}

/**
* Indicates that the feature ID texture 'channels' property
* had a structure that did not match the actual image data,
* meaning that the `channels` array contained an element
* that was not smaller than the number of actual channels
* in the image.
* Indicates that the feature ID texture or property texture 'channels'
* property had a structure that did not match the actual image data,
* meaning that the `channels` array contained an element* that was
* not smaller than the number of actual channels in the image.
*
* @param path - The path for the `ValidationIssue`
* @param message - The message for the `ValidationIssue`
Expand All @@ -57,6 +56,23 @@ export class GltfExtensionValidationIssues {
return issue;
}

/**
* Indicates that the feature ID texture or property texture 'channels'
* property had a structure that will likely not match the expected
* data type. For example, when a 16-bit value was represented with
* a single channel.
*
* @param path - The path for the `ValidationIssue`
* @param message - The message for the `ValidationIssue`
* @returns The `ValidationIssue`
*/
static TEXTURE_CHANNELS_SIZE_MISMATCH(path: string, message: string) {
const type = "TEXTURE_CHANNELS_SIZE_MISMATCH";
const severity = ValidationIssueSeverity.WARNING;
const issue = new ValidationIssue(type, path, message, severity);
return issue;
}

/**
* Indicates that the featureCount of a feature ID did not
* match the actual number of IDs
Expand Down
24 changes: 12 additions & 12 deletions src/validation/gltfExtensions/PropertyTexturePropertyValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,13 @@ export class PropertyTexturePropertyValidator {
* the type `STRING`, and has already been determined to be
* structurally valid.
*
* If the number is not valid, then a validation error will be added
* to the given context, and `false` will be returned.
* If the number is not valid, then a validation warning will be
* added to the given context.
*
* This makes the assumption that one channel of the image
* indeed consists of 8 bits. Since there is no reasonable
* way validate the bit depth of the image, any mismatch
* will only result in a WARNING (and not an error).
*
* @param path - The path for the `ValidationIssue` instances
* @param propertyName - The name of the property
Expand Down Expand Up @@ -239,12 +244,11 @@ export class PropertyTexturePropertyValidator {
`a total number of ${totalByteSize}, but the number of channels ` +
`in the property texture property was ${numberOfChannels}`;
const issue =
GltfExtensionValidationIssues.TEXTURE_CHANNELS_OUT_OF_RANGE(
GltfExtensionValidationIssues.TEXTURE_CHANNELS_SIZE_MISMATCH(
path,
message
);
context.addIssue(issue);
return false;
}
} else {
// Handle properties that are single enums
Expand All @@ -255,12 +259,11 @@ export class PropertyTexturePropertyValidator {
`consists of ${byteSize} bytes, but the number of channels ` +
`in the property texture property was ${numberOfChannels}`;
const issue =
GltfExtensionValidationIssues.TEXTURE_CHANNELS_OUT_OF_RANGE(
GltfExtensionValidationIssues.TEXTURE_CHANNELS_SIZE_MISMATCH(
path,
message
);
context.addIssue(issue);
return false;
}
}

Expand All @@ -282,12 +285,11 @@ export class PropertyTexturePropertyValidator {
`ceil(${count}/8) = ${totalByteSize} bytes, but the number of channels ` +
`in the property texture property was ${numberOfChannels}`;
const issue =
GltfExtensionValidationIssues.TEXTURE_CHANNELS_OUT_OF_RANGE(
GltfExtensionValidationIssues.TEXTURE_CHANNELS_SIZE_MISMATCH(
path,
message
);
context.addIssue(issue);
return false;
}
}
// For BOOLEAN properties that are not arrays, even a single
Expand Down Expand Up @@ -318,12 +320,11 @@ export class PropertyTexturePropertyValidator {
`a total number of ${totalByteSize}, but the number of channels ` +
`in the property texture property was ${numberOfChannels}`;
const issue =
GltfExtensionValidationIssues.TEXTURE_CHANNELS_OUT_OF_RANGE(
GltfExtensionValidationIssues.TEXTURE_CHANNELS_SIZE_MISMATCH(
path,
message
);
context.addIssue(issue);
return false;
}
} else {
// Handle properties that are not arrays
Expand All @@ -336,12 +337,11 @@ export class PropertyTexturePropertyValidator {
`the number of channels in the property texture property ` +
`was ${numberOfChannels}`;
const issue =
GltfExtensionValidationIssues.TEXTURE_CHANNELS_OUT_OF_RANGE(
GltfExtensionValidationIssues.TEXTURE_CHANNELS_SIZE_MISMATCH(
path,
message
);
context.addIssue(issue);
return false;
}
}
return true;
Expand Down

0 comments on commit 05c710b

Please sign in to comment.