Skip to content

Commit

Permalink
Cleanup now that shader defines are managed elsewhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
shunter committed Nov 6, 2014
1 parent 7acade9 commit 4f80225
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions Source/Scene/Globe.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ define([
*/
this.oceanNormalMapUrl = buildModuleUrl('Assets/Textures/waterNormalsSmall.jpg');
this._oceanNormalMapUrl = undefined;
this._oceanNormalMapChanged = false;

/**
* True if primitives such as billboards, polylines, labels, etc. should be depth-tested
Expand Down Expand Up @@ -273,7 +272,6 @@ define([

this._oceanNormalMap = undefined;
this._zoomedOutOceanSpecularIntensity = 0.5;
this._hasWaterMask = false;
this._hasVertexNormals = false;
this._lightingFadeDistance = new Cartesian2(this.lightingFadeOutDistance, this.lightingFadeInDistance);

Expand Down Expand Up @@ -845,19 +843,22 @@ define([
var oceanNormalMapUrl = this.oceanNormalMapUrl;
this._oceanNormalMapUrl = oceanNormalMapUrl;

var that = this;
when(loadImage(oceanNormalMapUrl), function(image) {
if (oceanNormalMapUrl !== that.oceanNormalMapUrl) {
// url changed while we were loading
return;
}
if (defined(oceanNormalMapUrl)) {
var that = this;
when(loadImage(oceanNormalMapUrl), function(image) {
if (oceanNormalMapUrl !== that.oceanNormalMapUrl) {
// url changed while we were loading
return;
}

that._oceanNormalMap = that._oceanNormalMap && that._oceanNormalMap.destroy();
that._oceanNormalMap = context.createTexture2D({
source : image
that._oceanNormalMap = that._oceanNormalMap && that._oceanNormalMap.destroy();
that._oceanNormalMap = context.createTexture2D({
source : image
});
});
that._oceanNormalMapChanged = true;
});
} else {
this._oceanNormalMap = this._oceanNormalMap && this._oceanNormalMap.destroy();
}
}

// Initial compile or re-compile if uber-shader parameters changed
Expand All @@ -867,8 +868,6 @@ define([
if (!defined(northPoleCommand.shaderProgram) ||
!defined(southPoleCommand.shaderProgram) ||
modeChanged ||
this._oceanNormalMapChanged ||
this._hasWaterMask !== hasWaterMask ||
this._hasVertexNormals !== hasVertexNormals ||
this._enableLighting !== enableLighting) {

Expand Down Expand Up @@ -943,10 +942,8 @@ define([
northPoleCommand.shaderProgram = poleShaderProgram;
southPoleCommand.shaderProgram = poleShaderProgram;

this._hasWaterMask = hasWaterMask;
this._hasVertexNormals = hasVertexNormals;
this._enableLighting = enableLighting;
this._oceanNormalMapChanged = false;
}

this._occluder.cameraPosition = frameState.camera.positionWC;
Expand Down Expand Up @@ -980,7 +977,7 @@ define([
tileProvider.lightingFadeOutDistance = this.lightingFadeOutDistance;
tileProvider.lightingFadeInDistance = this.lightingFadeInDistance;
tileProvider.zoomedOutOceanSpecularIntensity = this._zoomedOutOceanSpecularIntensity;
tileProvider.hasWaterMask = this._hasWaterMask;
tileProvider.hasWaterMask = hasWaterMask;
tileProvider.oceanNormalMap = this._oceanNormalMap;

surface.update(context, frameState, commandList);
Expand Down

0 comments on commit 4f80225

Please sign in to comment.