Hey guys,
I am messing around with the sandcastle demo titled ‘Polyline’, trying to incorporate a time attribute for each vertex. The idea being that each vertex can then be conditionally drawn depending upon the current time, which would passed in as a uniform to the fragment shader. This would allow for the polyline to be drawn over time.
Using the PolylineGeometry ‘colors’ option, I am trying to hijack the alpha variable for each vertex to use a time value. I can then customise the fragment shader source to assign an actual alpha based on the value of the hijacked value. I hope that makes sense. Let me know if I haven’t made much sense. My copied code is here http://pastebin.com/hrcjer4y.
The trouble I am having is the ‘colors’ option seems to limit the alpha value to [0,1], setting the alpha value to zero if the hijacked value was greater than one. I was just wondering where it might be happening within Cesium? I have had a look through but can’t seem to identify where this is happening.
If anyone has any suggestions how this could be differently that would also be really appreciated.
Thanks,
Craig
Hi Craig,
In PolylineGeometry.js around line 250, it creates the color attribute for the polyline. You can see that the type in unsigned byte and the values are normalized. This means the the color values in the buffer are unsigned bytes and the normalize flags means that they will be converted to floats in the range from 0 to 1. To change this, simply set normalize to false. If I understand what you are trying to do correctly, you probably also want to change the data type of the colors to floating point instead of unsigned byte.
Dan
Hi Dan,
Thanks for your response. That definitely helped me identify what was going on within Cesium. Changing the data type and the normalisation flag did the trick. After doing this, however, I was wondering if it might be better to allow customisation of the s and t parameters within PolylineGeometry.js, these values could be passed in as options in a similar way to positions and colors. Is this something that could be considered for Cesium? I have made some modifications to PolylineGeometry.js and this seems to do the trick without affecting existing functionality.
This is working for our use case. If you like we could look at contributing it along with an example use.
https://github.com/craigsketchley/cesium/commit/e95d7dd292b27d4ce912b8be3e731bdc654b04b7#diff-ec50d4a7b6930ed2e032ea9604af3a9b
Cheers,
Craig
Hey Dan,
I was wondering if you’d had a chance to consider these changes to Polyline Geometry regarding the ability to set custom s and t values, or even better, to allow the option to allow for an additional parameter?
Cheers,
Craig