Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange 2D full map lighting #1825

Open
pjcozzi opened this issue Jun 11, 2014 · 23 comments · Fixed by #2515
Open

Strange 2D full map lighting #1825

pjcozzi opened this issue Jun 11, 2014 · 23 comments · Fixed by #2515

Comments

@pjcozzi
Copy link
Contributor

pjcozzi commented Jun 11, 2014

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
Copy link
Contributor Author

pjcozzi commented Jul 18, 2014

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

@kring
Copy link
Member

kring commented Jul 18, 2014

Not likely, sorry.

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Jul 18, 2014

No worries. Pushing.

@pjcozzi pjcozzi added 1.0 push and removed 1.0 labels Jul 18, 2014
@mramato
Copy link
Contributor

mramato commented Dec 1, 2014

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
Copy link
Contributor

mramato commented Jan 14, 2015

Another example of lighting issues in #2399

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Feb 25, 2015

forum post

@emackey
Copy link
Contributor

emackey commented Feb 26, 2015

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

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Jun 30, 2015

Another forum post

@mramato
Copy link
Contributor

mramato commented Aug 19, 2015

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
Copy link
Contributor

mramato commented Aug 19, 2015

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

@hpinkos
Copy link
Contributor

hpinkos commented Oct 14, 2015

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
Copy link
Contributor

mramato commented Oct 14, 2015

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

@hpinkos
Copy link
Contributor

hpinkos commented Nov 16, 2016

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

This lighting problem only happens with Primitive, not GroundPrimitive

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Jan 2, 2017

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Jan 2, 2017

CC #4122

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Jan 2, 2017

CC #4571

@lilleyse
Copy link
Contributor

lilleyse commented May 1, 2017

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
Copy link
Contributor

mramato commented May 9, 2017

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
Copy link

tomermoshe commented Aug 9, 2017

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
Copy link
Contributor

hpinkos commented Aug 9, 2017

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
Copy link

Created a possible fix #5736

@lilleyse
Copy link
Contributor

@ggetz
Copy link
Contributor

ggetz commented Dec 19, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants