How to pass user defined uniform arrays to custom fragment shader in MaterialAppearance?

1. A concise explanation of the problem you're experiencing.

Hi,

we are researching and developing a model for pollution distribution in an affected geographical area depending, as of now, on weather conditions (mainly wind and rain), but later maybe on geographical natural barriers, due to ground elevation, too.
We'd like to display such computed model as heatmaps on Cesium (we already do it on 2D maps).

After a pretty extensive search on this forum and Cesium documentation I figured out that a Rectangle primitive with a custom MaterialAppeareance would probably suffice.
That would be probably ok if there was any way to pass to its, customized by me, fragment shader a few uniforms as a couple of vec2 arrays and optionally (if possible) a two channel float texture (representing a, quite small, vector field used for the computations) to be bilinearly sampled in the shader.
I succeded passing simple uniforms via Fabric, but it looks like it not supporting arrays yet.
On the other end I saw there's a Uniform class which might do the trick but I don't know how to couple it with the fragment shader in the material.

Is that the right way to go?
And if yes, how to do it ?

I played a bit with the idea of writing a custom primitive, exploring its source code, but I could not really come out to anything meaningful because of lack documentation (I didn't even understand if it may have been the right way for passing such kind of custom uniforms to the shader).

Thanks in advance for any help, code examples or hints you may give to me.

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

None

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

Display a heat map real time-computed in a rectangle's material fragment shader.

4. The Cesium version you're using, your operating system and browser.
Cesium 1.57, Windows 10 64bit, Google Chrome 74.0.3729.157 official build 64bit

It looks I didn't search thoroughly enough (used the wrong keywords probably).
I found some good info here (for others who might be interested too):

https://groups.google.com/forum/#!topic/cesium-dev/t1huyGykzO4
https://groups.google.com/forum/#!searchin/cesium-dev/How$20to$20draw$20the$20trails$20of$20particles|sort:date/cesium-dev/gjjd9TNeY2A/6GJqswuaAgAJ

and I'm getting ahead with it.

I consider the question as answered except for uniform arrays which look as still on the cesium team roadmap and require some Cesium engine source code's modifications as hinted here https://groups.google.com/forum/#!searchin/cesium-dev/shader|sort:date/cesium-dev/TYWfyZno21Q/fPgit8chBwAJ .

Thanks for your time and feel free to hint or point out some other resources/examples which may be relevant and helpful.
I'd greatly appreciate.

Best regards

Thanks for posting the resources you’ve found! This is definitely an area of CesiumJS I’d love to see improved, both in terms of documentation and in terms of ease of use.

I did just post some thoughts and a link to a blog post you may find helpful in this thread:

https://groups.google.com/d/msg/cesium-dev/oLr4sqJIzeM/UsVCy5F8AAAJ

Best of luck, and definitely please post back here if you find any useful tips you can share with the community! This sounds like a super cool application - is it for an academic kind of work? I’m curious if you’re finding things you’re able to do in 3D with Cesium that the other 2D maps aren’t able to achieve? I imagine the goal of this visualization is gaining insight into the model more than anything.

Hi Omar,

thanks and sorry for late reply, and thanks again for adding some new useful resources.

That visualization is part of an Italian government-funded research project for civilian large area territory monitoring and control (we get the raw data measurements, which feed our predictive pollution model, from the Italian ARPA network).

The 3D visualization of the pollution model integrates with other kinds of monitoring visualizations which are better suited for 3D than 2D (real-time drone positions, and their geolocalized cam video streaming, on planned paths and geofence monitoring is one use case for example, high risk material transport monitoring is another, etc) so to have an homogeneous whole situational awareness picture at a glance.

Best regards