CesiumGS / cesium-unity

Bringing the 3D geospatial ecosystem to Unity
https://cesium.com/platform/cesium-for-unity/
Apache License 2.0
319 stars 75 forks source link

`CesiumDefaultTilesetMaterial` not receiving proper directional lighting at certain angles #382

Open scaredskeleton opened 7 months ago

scaredskeleton commented 7 months ago

This might be an issue with the shader itself. As you can see below, lighting and shadows from a directional light are not properly received by the material at certain angles.

We are trying to a do a day and night cycle based on time, date and location so we are utilizing a wide range of rotations from a single directional light as if it is a real world sun light.

X > 140° X < 140°
MoreThan140 LessThan140

Note: "X" represents the angle value at X-Axis of rotation. Y and Z rotations on the preview is set to zero for simplicity.

kring commented 7 months ago

Can you elaborate on what's wrong in those screenshots? It's not completely obvious from a quick look.

Also, which tilesets are you using here?

scaredskeleton commented 7 months ago

In the left screenshot you can see that the platform that is using Unity's Standard material is well lit, but the Cesium tileset is not receiving any light or shadow. We are using a single directional light as a light source and this happens when the angle of the directional light at the X-Axis is greater than 140°.

On the right screenshot you can see that the platform and the tileset are both well lit when the angle is less than 140°.

We are using the the Google Photorealistic 3D Tiles.

kring commented 7 months ago

The Google Photorealistic Tiles are "unlit". Have you turned that off explicitly? Do you see the same behavior with Cesium World Terrain + Bing, or only with the Google tiles?

scaredskeleton commented 7 months ago

I tried turning the material type to Lit but it still has the same behavior. This issue is appearing in both Built-in and URP rendering pipelines. Also it is just weird that even thought it is explicitly "Unlit" it is still receiving lighting and shadows. One more thing, looking at the shader settings in Built-in it is specified as a Lit material.

This only happens with the Google tiles, the Bing tiles are working as intended. But, we really need the Google tiles since it is more detailed than the Bing tiles.

Is this really intended as a Unlit material? if so, do you have any suggestions or workarounds for it to receive lighting and shadows?

kring commented 7 months ago

Yes, the Google tiles are intended to be unlit. They don't include any normals.

One more thing, looking at the shader settings in Built-in it is specified as a Lit material.

Hmm I think this might be a bug. It's set to Unlit for URP. If you switch it to Unlit for built-in, too, does it help?

Ojayyy commented 5 months ago

I tried turning the material type to Lit but it still has the same behavior. This issue is appearing in both Built-in and URP rendering pipelines. Also it is just weird that even thought it is explicitly "Unlit" it is still receiving lighting and shadows. One more thing, looking at the shader settings in Built-in it is specified as a Lit material.

This only happens with the Google tiles, the Bing tiles are working as intended. But, we really need the Google tiles since it is more detailed than the Bing tiles.

Is this really intended as a Unlit material? if so, do you have any suggestions or workarounds for it to receive lighting and shadows?

Same here. Day Night cycle is not working properly with the Cesium shader. Once I turned on "Generate Smooth Normals" in the Cesium 3D Tileset settings it seems to work BUT unfortunately I get this padding effect: image