CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.94k stars 3.49k forks source link

Custom Shaders: Implicit Tile Coordinates as a built-in uniform? #9736

Open ptrgags opened 3 years ago

ptrgags commented 3 years ago

While working on #9725, I observed that it would be nice if the (level, x, y, [z]) coordinates from the 3DTILES_implicit_tiling implementation were available in custom shaders.

This should be easy to implement, if the ModelExperimental has a pointer to tile.implicitTileCoordinates, I think this would be implemented by creating an automatic uniform ivec4 with value ivec4(level, x, y, z). Actually... ivec4(x, y, z, level) would be better, then coordinates.x == x, and so on.

Based on the existing limitations with index sizes, the x, y, and z components are under 16 bits, so they could fit in either an ivec4 or vec4

@lilleyse @sanjeetsuhag any opinion on which data type to use for this?

sanjeetsuhag commented 3 years ago

16 bits is not a lot - could we pass these in as float and assemble a struct TileCoords in the shader that the user can access?