-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Making ShadowMap constructor private #4890
Changes from 4 commits
f410631
7bd60d3
c6c9229
8c3acf9
3c18a73
a143d82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,37 +107,28 @@ define([ | |
|
||
/** | ||
* Creates a shadow map from the provided light camera. | ||
* <p> | ||
* Use {@link Viewer#shadowMap} | ||
* </p> | ||
* | ||
* The normalOffset bias pushes the shadows forward slightly, and may be disabled | ||
* for applications that require ultra precise shadows. | ||
* | ||
* @alias ShadowMap | ||
* @constructor | ||
* | ||
* @param {Object} options An object containing the following properties: | ||
* @param {Context} options.context The context in which to create the shadow map. | ||
* @param {Camera} options.lightCamera A camera representing the light source. | ||
* @param {Boolean} [options.enabled=true] Whether the shadow map is enabled. | ||
* @param {Boolean} [options.isPointLight=false] Whether the light source is a point light. Point light shadows do not use cascades. | ||
* @param {Boolean} [options.pointLightRadius=100.0] Radius of the point light. | ||
* @param {Boolean} [options.cascadesEnabled=true] Use multiple shadow maps to cover different partitions of the view frustum. | ||
* @param {Number} [options.numberOfCascades=4] The number of cascades to use for the shadow map. Supported values are one and four. | ||
* @param {Number} [options.maximumDistance=5000.0] The maximum distance used for generating cascaded shadows. Lower values improve shadow quality. | ||
* @param {Number} [options.size=2048] The width and height, in pixels, of each shadow map. | ||
* @param {Boolean} [options.softShadows=false] Whether percentage-closer-filtering is enabled for producing softer shadows. | ||
* @param {Number} [options.darkness=0.3] The shadow darkness. | ||
* @internalConstructor | ||
* | ||
* @exception {DeveloperError} Only one or four cascades are supported. | ||
* | ||
* @demo {@link http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Shadows.html|Cesium Sandcastle Shadows Demo} | ||
* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove empty line. |
||
*/ | ||
function ShadowMap(options) { | ||
options = defaultValue(options, defaultValue.EMPTY_OBJECT); | ||
var context = options.context; | ||
var scene = options.scene; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's still nice to keep these parameter descriptions even if the shadow map isn't meant to be constructed directly. |
||
//>>includeStart('debug', pragmas.debug); | ||
if (!defined(context)) { | ||
throw new DeveloperError('context is required.'); | ||
if (!defined(scene)) { | ||
throw new DeveloperError('scene is required.'); | ||
} | ||
if (!defined(options.lightCamera)) { | ||
throw new DeveloperError('lightCamera is required.'); | ||
|
@@ -149,6 +140,8 @@ define([ | |
|
||
this._enabled = defaultValue(options.enabled, true); | ||
this._softShadows = defaultValue(options.softShadows, false); | ||
this._normalOffset = defaultValue(options.normalOffset, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When the parameters are added back to the doc, include |
||
this._normalOffsetScale = defaultValue(options.normalOffsetScale, 0.1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would not expose this right now as an option or a getter/setter. The default values used before are tuned for the different bias modes. |
||
this.dirty = true; | ||
|
||
/** | ||
|
@@ -183,6 +176,7 @@ define([ | |
// In IE11 and Edge polygon offset is not functional. | ||
// TODO : Also disabled for instances of Firefox and Chrome running ANGLE that do not support depth textures. | ||
// Re-enable once https://github.com/AnalyticalGraphicsInc/cesium/issues/4560 is resolved. | ||
var context = scene._context; | ||
var polygonOffsetSupported = true; | ||
if (FeatureDetection.isInternetExplorer() || FeatureDetection.isEdge() || ((FeatureDetection.isChrome() || FeatureDetection.isFirefox()) && FeatureDetection.isWindows() && !context.depthTexture)) { | ||
polygonOffsetSupported = false; | ||
|
@@ -193,8 +187,8 @@ define([ | |
polygonOffset : polygonOffsetSupported, | ||
polygonOffsetFactor : 1.1, | ||
polygonOffsetUnits : 4.0, | ||
normalOffset : true, | ||
normalOffsetScale : 0.5, | ||
normalOffset : this._normalOffset, | ||
normalOffsetScale : this._normalOffsetScale, | ||
normalShading : true, | ||
normalShadingSmooth : 0.3, | ||
depthBias : 0.0001 | ||
|
@@ -204,8 +198,8 @@ define([ | |
polygonOffset : polygonOffsetSupported, | ||
polygonOffsetFactor : 1.1, | ||
polygonOffsetUnits : 4.0, | ||
normalOffset : true, | ||
normalOffsetScale : 0.1, | ||
normalOffset : this._normalOffset, | ||
normalOffsetScale : this._normalOffsetScale, | ||
normalShading : true, | ||
normalShadingSmooth : 0.05, | ||
depthBias : 0.00002 | ||
|
@@ -215,8 +209,8 @@ define([ | |
polygonOffset : false, | ||
polygonOffsetFactor : 1.1, | ||
polygonOffsetUnits : 4.0, | ||
normalOffset : false, | ||
normalOffsetScale : 0.0, | ||
normalOffset : this._normalOffset, | ||
normalOffsetScale : this._normalOffsetScale, | ||
normalShading : true, | ||
normalShadingSmooth : 0.1, | ||
depthBias : 0.0005 | ||
|
@@ -384,6 +378,40 @@ define([ | |
} | ||
}, | ||
|
||
/** | ||
* Determines if a normal bias will be applied to shadows. | ||
* | ||
* @memberof ShadowMap.prototype | ||
* @type {Boolean} | ||
* @default true | ||
*/ | ||
normalOffset : { | ||
get : function() { | ||
return this._normalOffset; | ||
}, | ||
set : function(value) { | ||
this.dirty = this._normalOffset !== value; | ||
this._normalOffset = value; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This setter should also set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also add a test for this. It should be fine to set |
||
} | ||
}, | ||
|
||
/** | ||
* Amount to offset shadows by along the normal. Addresses shadow acne problems. | ||
* | ||
* @memberof ShadowMap.prototype | ||
* @type {Number} | ||
* @default 0.1 | ||
*/ | ||
normalOffsetScale : { | ||
get : function() { | ||
return this._normalOffsetScale; | ||
}, | ||
set : function(value) { | ||
this.dirty = this._normalOffsetScale !== value; | ||
this._normalOffsetScale = value; | ||
} | ||
}, | ||
|
||
/** | ||
* Determines if soft shadows are enabled. Uses pcf filtering which requires more texture reads and may hurt performance. | ||
* | ||
|
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's fine to remove the indentation for this line.
Expand on the description a bit. Maybe
Use {@link Viewer#shadowMap} to get the scene's shadow map originating from the sun. In general do not construct directly.