CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.92k stars 3.48k forks source link

3D models rendering is wrong with `minimumPixelSize` and `Scene.verticalExaggeration` above 1 #11936

Open Jean-Dum opened 6 months ago

Jean-Dum commented 6 months ago

What happened?

When setting viewer.scene.verticalExaggeration to a value above 1, all 3D models rendering become wrong.

Reproduction steps

  1. Display a 3D model
  2. Set viewer.scene.verticalExaggeration to a value above 1

Sandcastle example

https://sandcastle.cesium.com/#c=tVbbbhs3EP0VVk9rQKUutpJUVYzactoErdE0UoICVRHQu7NawlxyQXJtuYH/PcPLSqtLHwRDehE5HJ5zZjhcTqqkseSBwyNo8pZIeCRTMLwu6RdvSxad1M+nSlrGJehFp0u+LSQhXObqWq3GJGfCQNeZDAhILVfyg8x4yqzSW6sFy9SjGROr68aiapFdSV4yC2v789nPC7mQQRQ1KUigD6AtIop3K7ZcgmaOBPUOvWdeS89KUg0IdKsyEEmtRZcUwJeFPQuCIyBIyy0HQzWU6gGuhEgCISGpz0alDI/4MRdTpi2OmDynuVblDSw1gEncFkJ+HAzPaf/1xcWrwU/dYLq4oP1R//x1/1U0BB1u7KgaogJYxuVyw3PLbEGt+oRmJk0yOB+13Stu0wKd+y2bVkLsmIpq5yTfB5qPbvsn9E8ibzcgdj1Im0hpjkli2zmYa5SUK10aWuwA/lVj1rVE95iSJoNN9JVuQt+Q+GN4QvzdY2FZlnwLGyUrsSzcSW7jjncZWorH7UlcLl1FjElEJYjI27DowLEG6/IjX4GY8f+QdDB8s1llK7c6w/rDlWEff3Ht2f8/h+TFQKxm6T1k75r4QqDo8ezCjxmunDqDq/+4nVGYhZUdk0XniutUs9ziVYvhyXCz8DY1pZ6cbcJpl31jI4hDaW/GykrADbOs55NgeuE4kSKOvuKQLsXdmsz9Rhgi7TfzEN462u4ByTdaSTihXo/fHu9JHoyOU/ybVrXMyBcoeCpOIz1QRIbt2Z78Y6S/V5bgqZFrJoRS8oRpjwzbs/3UH1stt1zck7mu0/sTancknmN3/qLcz+65lJCRacHwnlv/Hp4sAtZk/isOXyT7sxTcEnyuTyIXcT3BeoBabb5TI0d+T1iqyFSVlQZjMN9eyUnEe6oN04Fq2QnlmDh+n/89bIdx5JXlOUl+iA/wrxhTreEGbOixqKmrSmlrrpnhJmm3S2ctCEIeucS+i+LjpW0rHS4h84IbcqexK8P2L1NgiMRvSwQmHph8lhy7L8MEPtzrOFx8KMYsOhvAJh2Yipd/clzi9i0v//R8wOeXydQdxekuw5pka3LgUoz+X/m/vluaMZmlzFh8MbAvmisl7pi+BVknsYUITVWn25kY+yTgsgH8hZf+DLHLSVCmBZSJMZjeHdY0WJoa03BOeu2tk4w/EJ69PdD4k1QwY3Alr4Vvkxady0kP/fe2CuU7xD+xcAR7cm7F4PKPYKSUTno4PbzThhB3kL8D

Environment

Browser: opera for android and Chrome 114.0 CesiumJS Version: 1.116.0 Operating System: Windows 10

ggetz commented 6 months ago

@jjhembd Could you please take a look at what may be causing this?

jjhembd commented 6 months ago

Hi @Jean-Dum, can you clarify what you mean by "wrong" rendering? The Sandcastle link works ok for me.

One thing to keep in mind: for a model that is far away from the reference height, exaggeration may move it out of view. In your Sandcastle, the airplane model is far above the viewport. But the Milk Truck model looks ok.

If your model is up in the air, one option is to set the reference height to the center of the model. Here is a modified Sandcastle showing this approach.

image

Let me know if this doesn't fix things on your end.

Jean-Dum commented 6 months ago

Thank you for your answer @jjhembd !

On your sandcastle, when modifying vertical exaggeration and zooming out, here is what I see: image

Jean-Dum commented 6 months ago

Furthermore, model entities are systematically vertically scaled by verticalExageration, which deform them. I would want the verticalExaggeration to only modify terrain (as it was done by terrainExaggeration), but it's not possible anymore (or at least only move up the entity model without distorting it).

jjhembd commented 6 months ago

Thanks for that clarification @Jean-Dum! I think there are 2 things going on here:

  1. When zoomed out, vertical exaggeration is not accounting for the "minimumPixelSize" of the model, so the rendering is wrong (your screenshot makes it very obvious--thanks!). This is a bug.
  2. All models are scaled by verticalExaggeration. This was an intentional choice in https://github.com/CesiumGS/cesium/pull/11655. However, users may want to turn exaggeration off for some of the models in the Scene.

To keep the discussion cleaner, I think the second item could be its own issue. I opened one here: https://github.com/CesiumGS/cesium/issues/11940. @Jean-Dum can you add more details about your use case in that issue? More context will help us prioritize it.

We can continue to discuss the buggy behavior (when zoomed out) in this issue.

Jean-Dum commented 6 months ago

Thank you very much @jjhembd !

Jean-Dum commented 3 months ago

I tried to find the cause of this issue but couldn't find it, I unfortunately do not have the skills to fix it. Does this issue has been prioritized yet?

mengqiuzl commented 3 months ago

@jjhembd If I just want to exaggerate the terrain, how should I use this feature?

timeichfeld-msa commented 2 months ago

@jjhembd Hi Jeshurun +1 for me as well, I am in the 'However' case for item number 2 :)