I’m trying to draw a LOT of boxes, so I am creating many Geometry Instances in a single Primitive.
I then want to update how some of the Geometry Instances look based on their position (height), so am trying to define a custom attribute altitude
on each Instance so that it can be fed to the shaders.
The goal is to compare a uniform maxAltitude
defined on the primitive.appearance
to calculate material.alpha
based on altitude < maxAltitude
.
I have created a basic Sandcastle here (based on Material with Custom GLSL) which has commented out lines 142 and 174. If you uncomment those lines to pass altitude
through the shaders, Cesium will throw an error:
Appearance/Geometry mismatch. The appearance requires vertex shader attribute input ‘altitude’, which was not computed as part of the Geometry. Use the appearance’s vertexFormat property when constructing the geometry.
I’ve found a few resources related to this topic, but haven’t found a satisfying answer. This GitHub thread talked about per-instance properties, but it got shut down.
I’m seeing that I could probably go down the path of building a Custom Primitive, but that sounds like overkill when this approach is so close.
Is it possible to feed custom data to shaders like this?
If not, what would be the most performant way to render and update tens of thousands of boxes in Cesium?
Thank you,
Tawm