Skip to content

Commit

Permalink
Merge pull request #1046 from AnalyticalGraphicsInc/sunSize
Browse files Browse the repository at this point in the history
Sun Size
  • Loading branch information
pjcozzi committed Sep 10, 2013
2 parents 7ce2d8f + 33e841c commit d74ba6a
Show file tree
Hide file tree
Showing 11 changed files with 346 additions and 33 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Beta Releases
* Added `CorridorOutlineGeometry`.
* Improved runtime generation of GLSL shaders.
* Added new built-in GLSL functions `czm_getLambertDiffuse` and `czm_getSpecular`.
* Made sun size accurate.
* Added `Scene.sunBloom` to enable/disable the bloom filter on the sun. The bloom filter should be disabled for better frame rates on mobile devices.

### b20 - 2013-09-03

Expand Down
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 = false;
}

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

0 comments on commit d74ba6a

Please sign in to comment.