Color randomization of Polygon Style affected by Alpha in CesiumVectorStyle

Hi, Dear Cesium Team,

I am using Unreal 5.6 with Cesium for Unreal V2.21.0.

1.If the CesiumGeoJsonDocumentRasterOverlay loads a LineString GeoJSON file, the color randomization of Line Style is not affected by Alpha, which is correct, I think.

(1)Set the Line Color to full red value and full Alpha value, and the result is as follows.

(2)Set the Line Color to full red value and half Alpha value, and the result is as follows

2.However, if the CesiumGeoJsonDocumentRasterOverlay loads a MultiPolygon GeoJSON file , the color randomization of Polygon Style is affected by Alpha, which is not correct.

(1)Set the Fill Color to full red value and full Alpha value, and the result is as follows.

(2)Set the Fill Color to full red value and half Alpha value, and the result is as follows.

You can see that the value of Alpha has affected the random color, and the output result is not translucent.

3.Additionally, in the documentation,Cesium for Unreal: Source/CesiumRuntime/Public/CesiumVectorStyle.h File Reference ,the description of the example is incorrect.

It is likely that the byte order is mixed up, and the correct description should be as follows:

For example, If the color was 0x007700ff (only 0x77 in the green component), the resulting randomized value could be 0x004100ff, or 0x007600ff, but never 0x00aa00ff.

Hi @pjiang9, sorry for the delayed response! This post fell through the cracks.

@azrogers, could you chime in here about whether this is a bug or intended behavior?

@pjiang9 You are definitely right that the documentation is incorrect! However, I am unable to reproduce your issue with a MultiPolygon dataset using the same color values. The transparency works correctly, and the alpha value does not affect the random color. This is with a bing maps raster overlay set up as Overlay0, and a GeoJSON raster overlay set up as Overlay1. If you are still experiencing this issue, could you share a sample project that I can use to reproduce it? Thank you!

Thank you, janine. Thank you,azrogers.

The project is attached.

The code is all in the Level Blueprint.

I also found that if I limit the Object Type to the Feature Collection level, the result seems to be as expected. But this is somewhat illogical. Logically speaking, with 16 Features, each Feature should be able to have a different random Polygon color set independently.

Right now I’m not sure if it’s a bug.

PolygonRandomTest.zip (27.8 MB)

It turns out the source of the issue is that the GeoJsonDocumentRasterOverlay was incorrectly including both the FeatureCollection and the polygons it contained within the list of geometry to be rendered. This means it would render the feature collection, which in turn would render all the contained polygons using the FeatureCollection’s style, and would then rendere each polygon individually, which would use the Polygon’s style. This is why you got correct results setting it on the Feature Collection level. I’ve included the fix for this in this pull request to improve GeoJSON rasterizing in general, which I’m hoping will make it into the release at the end of the month!

That makes sense. Thank you! Looking forward to the new GeoJsonDocumentRasterOverlay.