jkuhlmann / cgltf

:diamond_shape_with_a_dot_inside: Single-file glTF 2.0 loader and writer written in C99
MIT License
1.44k stars 136 forks source link

KHR_texture_transform: how to check existence of texCoord? #161

Closed pezcode closed 3 years ago

pezcode commented 3 years ago

texCoord inside KHR_texture_transform is not mandatory and replaces the normal texCoord only if present. However, I don't see a way to check if it exists or not.

Problematic example scenario: the original texCoord is 3 and texCoord in KHR_texture_transform is unset, but it becomes 0 in cgltf_texture_transform. Setting the texture channel to 0 would be wrong.

Not sure what would be a good way to expose this. Default value of -1? Extra bool?

zeux commented 3 years ago

Thanks -- this was missed during the initial implementation of the extension. I would recommend adding bool has_texcoord -- this is more consistent with other areas of the spec where there's no default value for an optional parameter, such as accessor min/max or camera zfar or aspect ratio.

jkuhlmann commented 3 years ago

I've added the change here: a92412b6cd38aa19168691df8229b1fb6dc68d1f. Does that fix it for you @pezcode?

pezcode commented 3 years ago

Yep, that fixes it.

Thanks for these quick fixes, really appreciated 👍