-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Model lighting options #7025
Model lighting options #7025
Conversation
Thanks for the pull request @bagnell!
Reviewers, don't forget to make sure that:
I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome. 🌍 🌎 🌏 |
@@ -384,7 +384,9 @@ define([ | |||
uniformMapLoaded : batchTable.getUniformMapCallback(), | |||
pickIdLoaded : getPickIdCallback(content), | |||
addBatchIdToGeneratedShaders : (batchLength > 0), // If the batch table has values in it, generated shaders will need a batchId attribute | |||
pickObject : pickObject | |||
pickObject : pickObject, | |||
iblFactor : tileset.iblFactor, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is ibl
a common enough abbreviation for our users, or should this be imageBasedLightingFactor
?
That looks like a pretty awesome improvement. |
Have you tried this with PBR models? The second image here shows an intense amount of contrast for what is a pretty plain white material, which makes me wonder how full PBR materials might perform. Haven't had time to try this branch myself yet. Ideally, I would much rather see cities like this use AO instead of crazy amounts of diffuse contrast to visually separate the buildings. |
What prompted this PR? Are |
Is this stalled on IBL? |
I was going to add an option to enable/disable IBL, but I added a scale when I saw it in the glTF reference implementation: |
…the diffuse and specular separately.
@lilleyse can you please review to take this over the finish line? |
Source/Scene/Model.js
Outdated
@@ -282,6 +286,8 @@ define([ | |||
* @param {Number} [options.silhouetteSize=0.0] The size of the silhouette in pixels. | |||
* @param {ClippingPlaneCollection} [options.clippingPlanes] The {@link ClippingPlaneCollection} used to selectively disable rendering the model. | |||
* @param {Boolean} [options.dequantizeInShader=true] Determines if a {@link https://github.com/google/draco|Draco} encoded model is dequantized on the GPU. This decreases total memory usage for encoded models. | |||
* @param {Number} [options.imageBasedLightingFactor=1.0] Scales the IBL lighting from the earth, sky, atmosphere and star skybox. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc should be Cartesian2
instead of Number
.
Source/Scene/Model.js
Outdated
/** | ||
* The color and intensity of the sunlight used to shade the model. | ||
* <p> | ||
* For example, disabling additional light sources by setting <code>model.imageBasedLightingFactor = 0.0</code> will make the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same note here.
if (value === lightColor || Color.equals(value, lightColor)) { | ||
return; | ||
} | ||
this._regenerateShaders = this._regenerateShaders || (defined(lightColor) && !defined(value)) || (defined(value) && !defined(lightColor)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it also regenerate the shader if the previous color was not (0,0,0)
but the new color is (0,0,0)
(and the reverse)?
Some of the other documentation makes it seem as if setting lightColor
to undefined
would result in using the default sun color. Should that be the behavior here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meant to delete this comment. See #7025 (comment) instead.
fragmentShader += ' vec3 lightColor = vec3(1.5, 1.4, 1.2);\n'; | ||
fragmentShader += '#else \n'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default light color could also share the gltf_lightColor
uniform.
Then USE_CUSTOM_LIGHT_COLOR
might be just USE_LIGHT_COLOR
, and switched off if the user sets the color to (0,0,0).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at https://github.com/AnalyticalGraphicsInc/cesium/pull/7017/files#r216167338 and the Color doc, is this because colors are not allowed to have components greater than 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about that comment. Can you explain @ggetz? Colors aren't supposed to have values >1 but you can as long as you aren't converting the components to bytes. Perhaps this should be a Cartesian3
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also like to keep the uniform the way it is since the compiler could optimize out the uniform when not set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was because I was using a Color with components greater than 1. Cartesian3
would work. 👍
@@ -1,5 +1,6 @@ | |||
defineSuite([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should also be tests for Cesium3DTileset
(b3dm and i3dm) and Model
. It should be enough to check that the pixel color changed after setting the lighting values.
@lilleyse Updated. This is ready for another look. |
Thanks @bagnell. |
Model.iblFactor
which scales the IBLColor computed in the fragment shader.Model.lightColor
which changes the sunlight color and intensity. For example, settingiblFactor = 0.0
makes the model much darker so the light intensity could be increased.Cesium3DTileset