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

Sun Size #1046

Merged
merged 26 commits into from
Sep 10, 2013
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d3ae6ca
Fix sun size.
bagnell Aug 20, 2013
5adf0cb
Merge branch 'master' into sunSize
bagnell Aug 23, 2013
4f8e0c8
Merge remote-tracking branch 'origin/master' into sunSize
emackey Aug 26, 2013
a068243
Add a sunburst.
emackey Aug 26, 2013
95f2b13
Get rid of sin() and cos() from sun shader.
emackey Aug 26, 2013
0969c55
Added get/setGlowFactor to address a feature request in #769.
emackey Aug 27, 2013
5d4410f
Merge pull request #1081 from AnalyticalGraphicsInc/sunburst
bagnell Aug 27, 2013
f882120
Fix whitespace.
emackey Aug 28, 2013
5301126
More whitespace.
emackey Aug 28, 2013
6bfaa62
Use Object.defineProperty for glowFactor.
emackey Aug 28, 2013
04fa8f6
Switch to Core/defineProperties.
emackey Aug 28, 2013
0e85d08
Merge branch 'master' into sunSize
bagnell Aug 29, 2013
16fe2a7
Merge branch 'master' into sunSize
bagnell Sep 4, 2013
83e8840
Fix tests.
bagnell Sep 4, 2013
e51b123
Make czm_solarRadius match CesiumMath.SOLAR_RADIUS
emackey Sep 5, 2013
261e79a
Render sun to texture then continue rendering the sun using texture l…
bagnell Sep 6, 2013
b98c7df
Update property definition per @mramato's review.
emackey Sep 6, 2013
d79c458
Fix build.
emackey Sep 6, 2013
41253b6
Fix sun glow.
bagnell Sep 6, 2013
70f7185
Merge branch 'master' into sunSize
bagnell Sep 6, 2013
bc21ad2
Fix after merge.
bagnell Sep 6, 2013
2843349
Remove unused code.
bagnell Sep 6, 2013
fb0d752
Tweak the glow to make the inner disc stand out more.
emackey Sep 6, 2013
3402c7e
Fix sun size jumps because of perspective.
bagnell Sep 6, 2013
f7e594a
Add property to enable/disable sun bloom filter.
bagnell Sep 6, 2013
33e841c
Updates based on review.
bagnell Sep 9, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Source/Core/Math.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ define([
CesiumMath.GRAVITATIONALPARAMETER = 3.986004418e14;

/**
* Radius of the sun in meters: 6.995e8
* Radius of the sun in meters: 6.955e8
* @type {Number}
* @constant
*/
CesiumMath.SOLAR_RADIUS = 6.995e8;
CesiumMath.SOLAR_RADIUS = 6.955e8;

/**
* 64 * 1024
Expand Down
10 changes: 7 additions & 3 deletions Source/Scene/Material.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ define([
'../Core/combine',
'../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties',
'../Core/destroyObject',
'../Core/Cartesian2',
'../Core/Matrix2',
Expand Down Expand Up @@ -50,6 +51,7 @@ define([
combine,
defaultValue,
defined,
defineProperties,
destroyObject,
Cartesian2,
Matrix2,
Expand Down Expand Up @@ -396,9 +398,11 @@ define([
this._count = undefined;

initializeMaterial(description, this);
Object.defineProperty(this, 'type', {
value : this.type,
writable : false
defineProperties(this, {
type : {
value : this.type,
writable : false
}
});

if (!defined(Material._uniformList[this.type])) {
Expand Down
13 changes: 11 additions & 2 deletions Source/Scene/Primitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
define([
'../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties',
'../Core/DeveloperError',
'../Core/destroyObject',
'../Core/Matrix4',
Expand Down Expand Up @@ -29,6 +30,7 @@ define([
], function(
defaultValue,
defined,
defineProperties,
DeveloperError,
destroyObject,
Matrix4,
Expand Down Expand Up @@ -878,16 +880,23 @@ define([

var perInstanceAttributes = this._perInstanceAttributeIndices[index];
var attributes = {};
var properties = {};
var hasProperties = false;

for (var name in perInstanceAttributes) {
if (perInstanceAttributes.hasOwnProperty(name)) {
Object.defineProperty(attributes, name, {
hasProperties = true;
properties[name] = {
get : createGetFunction(name, perInstanceAttributes),
set : createSetFunction(name, perInstanceAttributes, this._dirtyAttributes)
});
};
}
}

if (hasProperties) {
defineProperties(attributes, properties);
}

this._lastPerInstanceAttributeIndex = index;

return attributes;
Expand Down
35 changes: 30 additions & 5 deletions Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ define([

this._shaderFrameCount = 0;

this._sunPostProcess = new SunPostProcess();
this._sunPostProcess = undefined;

this._commandList = [];
this._frustumCommandsList = [];
Expand Down Expand Up @@ -168,6 +168,15 @@ define([
*/
this.sun = undefined;

/**
* Uses a bloom filter on the sun when enabled.
*
* @type {Boolean}
* @default true
*/
this.sunBloom = true;
this._sunBloom = undefined;

/**
* The background color, which is only visible if there is no sky box, i.e., {@link Scene#skyBox} is undefined.
*
Expand Down Expand Up @@ -657,20 +666,33 @@ define([
var context = scene._context;
var us = context.getUniformState();

if (defined(scene.sun) && scene.sunBloom !== scene._sunBloom) {
if (scene.sunBloom) {
scene._sunPostProcess = new SunPostProcess();
} else {
scene._sunPostProcess = scene._sunPostProcess.destroy();
}

scene._sunBloom = scene.sunBloom;
} else if (!defined(scene.sun) && defined(scene._sunPostProcess)) {
scene._sunPostProcess = scene._sunPostProcess.destroy();
scene._sunBloom = undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's cleaner to keep this as a boolean, i.e., false. I suspect we do that elsewhere.

}

var skyBoxCommand = (frameState.passes.color && defined(scene.skyBox)) ? scene.skyBox.update(context, frameState) : undefined;
var skyAtmosphereCommand = (frameState.passes.color && defined(scene.skyAtmosphere)) ? scene.skyAtmosphere.update(context, frameState) : undefined;
var sunCommand = (frameState.passes.color && defined(scene.sun)) ? scene.sun.update(context, frameState) : undefined;
var sunVisible = isSunVisible(sunCommand, frameState);

if (sunVisible) {
if (sunVisible && scene.sunBloom) {
passState.framebuffer = scene._sunPostProcess.update(context);
}

var clear = scene._clearColorCommand;
Color.clone(clearColor, clear.color);
clear.execute(context, passState);

if (sunVisible) {
if (sunVisible && scene.sunBloom) {
scene._sunPostProcess.clear(context, scene.backgroundColor);
}

Expand All @@ -690,8 +712,11 @@ define([

if (defined(sunCommand) && sunVisible) {
sunCommand.execute(context, passState);
scene._sunPostProcess.execute(context);
passState.framebuffer = undefined;

if (scene.sunBloom) {
scene._sunPostProcess.execute(context);
passState.framebuffer = undefined;
}
}

var clearDepthStencil = scene._clearDepthStencilCommand;
Expand Down
Loading