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

fixed shadowing on entity #5736

Closed
wants to merge 6 commits into from
Closed

Conversation

tomermoshe
Copy link

@tomermoshe tomermoshe commented Aug 10, 2017

Fixes #1825

@cesium-concierge
Copy link

@tomermoshe thanks for the pull request!

I noticed that CHANGES.md has not been updated. If this change updates the Cesium API in any way, fixes a bug, or makes any non-trivial update, please add a bullet point to CHANGES.md and bump this pull request so we know it was updated. For more info, see the Pull Request Guidelines.

I am a bot who helps you make Cesium awesome! Thanks again.

@tomermoshe
Copy link
Author

tomermoshe commented Aug 10, 2017

Fixing issue #1825
Updated CHANGES.md

@hpinkos
Copy link
Contributor

hpinkos commented Aug 10, 2017

Thanks for the pull request @tomermoshe!
Can you please send us a Contributor License Agreement so we can review and merge this?
Also merge master when you get a chance, there is a conflict with CHANGES.md

@tomermoshe
Copy link
Author

done and done :)

@hpinkos
Copy link
Contributor

hpinkos commented Aug 10, 2017

@tomermoshe this sample code from #1825 produces the same lighting problems that exist in master:

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()
}));

@tomermoshe
Copy link
Author

It's because the appearance is created without {flat:true} . Right now by default PerInstanceColorAppearance is using PerInstanceColorAppearanceFS which takes shadowing into account. If PerInstanceColorAppearance is created with {flat: true} the shader that will be used is PerInstanceColorAppearanceFlatFS (not 100% sure about the name of the shader as I'm not near a computer) which will draw the geometry without shadows.

@hpinkos
Copy link
Contributor

hpinkos commented Aug 10, 2017

Thanks for the explanation @tomermoshe, I forgot about that. We should make sure that the Entity API is passing the correct options to the appearance as well.

@bagnell do you want to review this?

@mramato
Copy link
Contributor

mramato commented Aug 10, 2017

While flat: true works around the issue, I don't think it's the actual fix for the issue. @bagnell may know more.

@pjcozzi
Copy link
Contributor

pjcozzi commented Aug 10, 2017

@tomermoshe thanks again for contributing, we received the CLA.

@pjcozzi pjcozzi requested a review from bagnell August 11, 2017 00:36
@tomermoshe
Copy link
Author

Hey guys :) How is the review going?
@mramato As of my understanding, Logically, If PerInstanceColorAppearance is created explicitly with no shadows, the coloring of the geometry should be flat regardless of the issue. Is that correct?

@hpinkos
Copy link
Contributor

hpinkos commented Aug 17, 2017

@tomermoshe sorry for the delay. A lot of the team is at the FOSS4G conference this week. We'll have more time to review your PR when we get back. Thanks!

@tomermoshe
Copy link
Author

any progress on the PR review?

@lilleyse
Copy link
Contributor

lilleyse commented Sep 1, 2017

I don't think this is the right fix either.

@mramato As of my understanding, Logically, If PerInstanceColorAppearance is created explicitly with no shadows, the coloring of the geometry should be flat regardless of the issue. Is that correct?

Shadows only affect whether the geometry receives shadows from itself or other objects in the scene, but does not affect the shading of the geometry. So you can have a geometry with flat shading that still receives shadows.

Basically shadows and flat/regular shading are separate concepts.

@hpinkos
Copy link
Contributor

hpinkos commented Sep 15, 2017

Thanks for taking the time to look into this @tomermoshe! However, it sounds like this isn't the way we want to go about fixing this. We're always happy to review pull requests if you want to submit a different fix =)

@lilleyse if you have any suggestions for a different approach, please make a comment in #1825

@hpinkos hpinkos closed this Sep 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants