CesiumGS / cesium-native

Apache License 2.0
402 stars 205 forks source link

Add options to upsampleGltfForRasterOverlays to specify the texture coordinate base name and whether to invert the V texture coordinate #846

Closed kring closed 4 months ago

kring commented 4 months ago

Previously, upsampleGltfForRasterOverlays assumed that raster overlay texture coordinates were found in attributes named _CESIUMOVERLAY_n, and that the origin of the V coordinate was at the Southern end of the tile. Both of these assumptions are fine in our game engine integrations where a custom shader does the overlay rendering. But they're problematic if we want to produce a standard glTF.

So this PR makes the base name of the texture coordinates a parameter, and defaults it to the standard glTF texture coordinate name (TEXCOORD_n). It also adds a hasInvertedVCoordinate parameter indicating that the model's V texture coordinate starts is 0.0 at the Northern end of the tile rather than the Southern end, consistent with a right-side-up map image.

Some other improvements in this PR:

kring commented 4 months ago

I added a tiny unrelated commit to this PR that improves a comment in RasterOverlayUtilities.cpp, for lack of a better place to put it.

kring commented 4 months ago

This is ready for another look. In addition to your suggestions, I moved upsampleGltfForRasterOverlays into RasterOverlayUtilities. I think it makes a lot more sense that way than as a global function in Cesium3DTilesContent.