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.74k stars 3.45k forks source link

Strange 2D full map lighting #1825

Open pjcozzi opened 10 years ago

pjcozzi commented 10 years ago

Probably due to the multiple sun and moon light sources.

image

Sandcastle code:

var viewer = new Cesium.Viewer('cesiumContainer', {
    sceneMode: Cesium.SceneMode.SCENE2D
});
var scene = viewer.scene;

var instances = [];

for (var lon = -175.0; lon < 175.0; lon += 5.0) {
  for (var lat = -85.0; lat < 85.0; lat += 5.0) {
    instances.push(new Cesium.GeometryInstance({
      geometry : new Cesium.RectangleGeometry({
        rectangle : Cesium.Rectangle.fromDegrees(lon, lat, lon + 5.0, lat + 5.0),
        vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT
      }),
      attributes : {
        color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.WHITE)
      }
    }));
  }
}

scene.primitives.add(new Cesium.Primitive({
  geometryInstances : instances,
  appearance : new Cesium.PerInstanceColorAppearance()
}));
pjcozzi commented 10 years ago

@kring any chance you are still game for this for 1.0? Two weeks...

kring commented 10 years ago

Not likely, sorry.

pjcozzi commented 10 years ago

No worries. Pushing.

mramato commented 9 years ago

This problem has gotten worse, and also now happens in all scene modes. It changes depending on if the geometry is closed or not, so @bagnell thinks it may be related to normal flipping. It's not a showstopper because it's bad in 1.3 as well, but we should look at this soon after 1.4 releases.

mramato commented 9 years ago

Another example of lighting issues in #2399

pjcozzi commented 9 years ago

forum post

emackey commented 9 years ago

I think this was auto-closed prematurely. #2515 is listed as only a partial fix.

pjcozzi commented 9 years ago

Another forum post

mramato commented 9 years ago

Just an FYI, something is severely wrong with lighting in master for the sample code in the original post. Hopefully this points to an obvious bug.

3D image

2D image

I also think this bug is probably intertwined with #1578

mramato commented 9 years ago

It's also been brought up on the forum twice recently: post1 post2

hpinkos commented 8 years ago

Just an FYI, something is severely wrong with lighting in master for the sample code

This is because the sample code doesn't supply the right vertex format to the rectangle vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT

But why the default vertexFormat (position/normal/st instead of just position/normal) makes it that weird is beyond me.

mramato commented 8 years ago

Thanks @hpinkos can you please update the original post with the correct code.

hpinkos commented 7 years ago

Came up again: https://groups.google.com/d/msg/cesium-dev/OzfwqMLOr60/BZUlltAfDgAJ

This lighting problem only happens with Primitive, not GroundPrimitive

pjcozzi commented 7 years ago

Related forum thread from https://github.com/AnalyticalGraphicsInc/cesium/issues/1578#issuecomment-41843903:

https://groups.google.com/forum/#!msg/cesium-dev/SZa3vf3Yk8c/5M_f2-eIW4gJ

pjcozzi commented 7 years ago

CC #4122

pjcozzi commented 7 years ago

CC #4571

lilleyse commented 7 years ago

This may be the same problem in this post: https://groups.google.com/forum/#!topic/cesium-dev/wb_dzC9Tjuw

Works fine if the height is left undefined.

const ellipse = {
      semiMinorAxis : 1000000.0,
      semiMajorAxis : 1000000.0,
      material : Cesium.Color.WHITE,
      shadows: Cesium.ShadowMode.DISABLED,
      numberOfVerticalLines: 3,
      outline: false,
      height: 10,
 };

3D: 3d

2D: 2d

mramato commented 7 years ago

The same post @lilleyse linked to above was updated to mention that his problem went away if he forced contextOptions to include the stencil buffer see: http://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=348403bd766c14f97d05bc59dc60e9cd I think this is just a happy accident, but figured I'd mention it here in case it sets off any light bulbs.

tomermoshe commented 7 years ago

Forcing contextOptions to include the stencil buffer doesn't seem to work if height is defined. Not defining height have a major hit on performance for some reason: http://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=e3ebdee8cf5db3192de145e9b2ad9063

hpinkos commented 7 years ago

Hello @tomermoshe, when using entities, if you define a height it uses a Primitive to draw the geometry. When you do not define a height, it is using a GroundPrimitive, which clamps the geometry to the terrain. GroundPrimitives are a little more complex to render, which is why you see a decrease in performance when you do not define height.

tomermoshe commented 7 years ago

Created a possible fix #5736

lilleyse commented 6 years ago

Also related: https://groups.google.com/forum/#!topic/cesium-dev/HsYgOawTCNI

ggetz commented 1 year ago

Reported on the forum: https://community.cesium.com/t/colors-appearing-different-between-3d-and-2d/21634/2