CesiumGS / cesium

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

New 1.123 Environment Map Rotates Together With Model #12310

Open xtassin opened 1 week ago

xtassin commented 1 week ago

What happened?

Testing the new 1.123 Environment Map implementation, I noticed that the env map is rotated along with the 3D model.

Reproduction steps

  1. Load PBR based GLTF2 model
  2. Rotate model
  3. Environment map (reflection) rotate together with the model (up side down at roll=3.14) ...

Sandcastle example

https://sandcastle.cesium.com/#c=tVkJbxu5Ff4rrFFg5UIazX04dtDYcY7WaQLb2wW2Lhx6hpK45pBTkmNHG+S/95FzaCQrsrJog2A0Q/J97358pHPBlUYPlDwSiU4QJ4/ojChal84/7djo5iC332eCa0w5kTcHY/T1hiOEOS2xpoIfoRlmiozNoKYlYbBsOFYrcirFoyLykuSiLAkvSHFJlGD1Ovm3wxc3/IbnVqavSOWEkzHKcUkkhl8m8nv0DaRsxLVr6QyN/mQXOqoiec2wPOcPVAoObPQHXKmruqqE1KQ4bMR+pLwQjw5mRGrQ7npBFbprxEOFIApxoZFqiFCHicgKFJWA6twcGGG/reRdEDpfaJDOdx33RT9abZj1HcEF5fNPVOeLS8HYCFaPkX0Ejhce9pRC0jnlQNwSnmFQQlHMA2cmRfmazCUhajTx/MBxkzCMvWyMwtBxIzdI3HjcCrQCLEVB2AesJf2yQr2WmKuZkKVyFhuSXYs39Asp3kiw/6iRZmz0aZzU2Jy1Og8UfE0lyY1fMbswsyNr9aIbPRquXek0MosQ2MEPo9BP0sB1o9D1Mm/cTaRp6McBTEZeFmSgbDcRZImfhannZVEYpakb2ZlD+6RcE66oXh5ZE/chNp0i6/gNt6JHrFAlBYS8IgUELtgD/X0BK4T6SaE5u36D3p9eoCtcVhA/DroW3XK0FLVE4pEfWXQPTdBr+GICF5ApBbqrKSuQXpAO7wkaGi20rtTRdDqnelHfOZAr03bxWynqamooJkAxaSkOHcvLB16XNUefc0bRhPKq1p+wXqBpBc+pFlPI0z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fJ97wYf8zkZtTKNG17jXgnTyjc1sP1bwcH44FjpJSMvO3v8lZb2Dw1QGUaOM9WkrBgEjZreQfNBtJMr1ZnmeDokPS7oA6LFyZa/z6CcYaVgZlYzdkV/h17y5fEU1j8hbTPu4wORDC/NsoX38qIZdBzneAqf2yl1V5x7TQaom737GsZw5UahX+c1eP8v

Environment

Browser: Chrome CesiumJS Version: 1.123 Operating System: Windows 10

xtassin commented 2 days ago

Just updated the sandcastle example to make the issue more obvious...

ggetz commented 2 days ago

Thanks for the report @xtassin!

@jjhembd Could you please triage this? Is this expected behavior or no?

xtassin commented 1 day ago

Just to add some info, the environnement map (reflections) orientation was fine before the overall in version 1.123 so it appears to be a regression bug.

jjhembd commented 1 day ago

@xtassin thanks for the Sandcastle! I agree that this behavior is not what we want. However, I re-labeled the issue as an enhancement rather than a bug, since the desired behavior is something we never implemented.

The environment map is referenced in the shader via model_iblReferenceFrameMatrix, which in most cases is simply the camera's viewMatrix multiplied by the model's modelMatrix. The only exceptions relate to tilesets, clipping planes, and height clamping, which I don't think are relevant here.

This means that the environment map will be oriented to the model, and when you rotate the model, the environment will rotate along with it. This works well for simplistic cases where the model is fixed along the local ENU axes. But it doesn't work for the (relatively common!) case where your model is moving.

I don't understand why the orientation would have been different before 1.123. That version introduced a new procedural environment map, but as far as I can see, it did not change the transforms for supplied environment maps like the one in your Sandcastle. Are you saying the procedural environment orientation changed?

xtassin commented 1 day ago

Here are three screenshots of the same GLB model (attached), exported with PBR material, from 3DS Max, using Babylon exporter.

Cesium version is mentioned on each one of them. Environment map (reflection) use to be static compared to earth frame.

Since version 1.123, the env map is rotated along with the model (in model frame).

image test.zip