I would like to render the ocean in Cesium using HDRP Water Surface within Unity’s Cesium integration. Since I couldn’t find a direct way to do this, I am currently using a custom mesh with water polygons. However, the Cesium sea imagery appears below the created water, making it look unnatural. Is there a way to make only the ocean parts of the imagery transparent?
Hi @kim1, welcome to the community!
Currently, no, we don’t have a built-in way to do this. Some terrain tilesets - Cesium World Terrain being the main example - include a “water mask”. In Cesium for Unreal, that water mask is accessible to the material so the shading can be done differently in areas that are land versus water. But this mask is not yet accessible from materials in Unity.
Probably your best bet right now is to use the Cartographic Polygon feature to manually clip away the ocean parts of the terrain in your area of interest.
Another option is to create your own rasterized water mask and then bring it into Unity as a raster overlay attached to the tileset. You’ll need raw data for a mask for the area you’re interested in, and some skill with GIS tools to turn it into a raster overlay. For example, you could host it as a WMS, or you could create a GeoTIFF and upload it to Cesium ion for tiling.
Thank you very much for your response! However, I still have some questions.
Could you explain in detail what it means to create a rasterized water mask manually? I have a water polygon image of the specific area I want, but it’s not an image of the entire globe.
Also, with a raster overlay, does it mean that the image of the sea area will disappear and be replaced with the HDRP Water System? Or does the image remain while the Water System is simply added on top?
Currently, I’ve tried customizing the HDRP Water System using TileSet Clipping and a custom mesh of the coastline for the specific area, but the boundary between the land and sea still looks unnatural.
I think the main reason is that the terrain in the area I want isn’t accurately representing elevation, which makes it appear unnatural. Are there other ways to represent the terrain more realistically?
Additionally, I encountered another issue: when I applied a Sky asset, the Cesium terrain completely disappeared. Do you have any suggestions to resolve this?
I am wondering if there is a way to invest in a separate database for water only. Like water polygons populate as a separate tileset. And they are slightly above the main terrain. Because you don’t want to just change the material, or mask it, especially in like Google Photorealistic Tiles, because there is height map data of the ocean floor. As well as color data. So you need like water polygons that are on top the main terrain. That way you can keep color data of the water if you make your water tiles materials semi transparent. And could apply any type of material for you water from the many all ready available Unity water assets. In the water dataset you could label different bodies of water as well. Like “Ocean”, “River” and “lakes”. Then could apply separate materials to those layers.
Could you explain in detail what it means to create a rasterized water mask manually?
Probably not in detail, sorry. As I mentioned, this is not something supported out of the box. We can provide ideas and hints and guidance, but not a step-by-step.
I have a water polygon image of the specific area I want, but it’s not an image of the entire globe.
That’s fine, it doesn’t need to cover the entire globe. The first step is to rasterize your vector polygons to a GeoTIFF. gdal_rasterize is one tool that can do it, though GIS software like QGIS can probably do it, too.
From there you can upload your GeoTIFF to Cesium ion, which can create a Imagery asset that you can load in Cesium for Unity as a raster overlay.
Also, with a raster overlay, does it mean that the image of the sea area will disappear and be replaced with the HDRP Water System? Or does the image remain while the Water System is simply added on top?
From here you have to get creative. It’s possible to create a custom material that renders your own water effect inside the masked area of the overlay. Or, if you need more sophisticated water that can’t be embedded in a custom material, then your custom material can simply “erase” all the water areas by setting the Opacity Mask to 0. Then you can create custom geometry to fill the space however you like (but you’ll need to do this manually).
but the boundary between the land and sea still looks unnatural.
This will be a challenge. I don’t have any quick solution for you.
I think the main reason is that the terrain in the area I want isn’t accurately representing elevation, which makes it appear unnatural. Are there other ways to represent the terrain more realistically?
Are you suggesting the heights are wrong? If so, and you have a better source of height data for the area, and you’re using Cesium World Terrain, you can upload your better data to Cesium ion and select Cesium World Terrain as the base. If you’re using Google Photorealistic 3D Tiles, options are unfortunately much more limited. The only possible solution I can think of is to try using the Unity transform on the tileset to adjust the height manually. That’s only going to have any hope of working if the area of interest is relatively small and the error is uniform.
Additionally, I encountered another issue: when I applied a Sky asset, the Cesium terrain completely disappeared. Do you have any suggestions to resolve this?
I haven’t used the Sky asset, so I don’t know why that would happen. First thing is to check the log for any messages that might provide a hint. The second, assuming Sky provides lighting in some fashion, is to see if your scene has simply gone completely dark.