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

Fog #3154

Merged
merged 47 commits into from
Nov 9, 2015
Merged

Fog #3154

Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e0efc3a
Initial fog. WIP.
bagnell Oct 22, 2015
7655844
Fog color WIP.
bagnell Oct 23, 2015
7e59d39
Clean up different fog equations and remove uniform fog color.
bagnell Oct 23, 2015
60e8bd5
More clean up.
bagnell Oct 23, 2015
b05a074
More fog color WIP.
bagnell Oct 23, 2015
9b690c7
Merge branch 'master' into fog
bagnell Oct 23, 2015
7894da3
Merge branch 'master' into fog
bagnell Oct 28, 2015
d397e32
Use atmosphere color for fog.
bagnell Oct 29, 2015
8fd263d
Merge branch 'master' into fog
bagnell Oct 29, 2015
41b9330
Minor shader clean up.
bagnell Oct 29, 2015
bebe65c
Add fog parameters to frame state. Cull globe tiles based on fog WIP.
bagnell Oct 29, 2015
01f6a6c
Update density from experimentation. Fog culling WIP.
bagnell Oct 29, 2015
9d3b07a
Interpolate fog density based on camera height.
bagnell Oct 30, 2015
ca742f9
Use preprocessor to enable fog.
bagnell Oct 30, 2015
9d6a8e6
Make scene.fog property. Factor out fog computations. When getting th…
bagnell Nov 2, 2015
80f3f28
Update Sandcastle example locations. Try new density function.
bagnell Nov 2, 2015
8a8c75d
Remove fog density function, use look up table.
bagnell Nov 3, 2015
d2df9a1
Remove fog after zooming out a certain distance.
bagnell Nov 3, 2015
d2c927b
Clean up unused code and Sandcastle example.
bagnell Nov 3, 2015
64a2be8
Increase SSE when tile is in fog.
bagnell Nov 3, 2015
95048fd
Swap shader when tile is in/out of fog.
bagnell Nov 3, 2015
582426a
Explicitly tag CesiumMath.fog private
pjcozzi Nov 4, 2015
dd54283
Doc tweak
pjcozzi Nov 4, 2015
1a194b7
Add comment
pjcozzi Nov 4, 2015
d84186f
Add comment
pjcozzi Nov 4, 2015
f07d538
Fix whitespace
pjcozzi Nov 4, 2015
c5d7341
Tweak density look up table.
bagnell Nov 4, 2015
325d393
Merge branch 'master' into fog
bagnell Nov 4, 2015
35295de
Exploit temporal coherence of zoom level in table look up.
bagnell Nov 4, 2015
ff61da5
Clean up searching for height interval.
bagnell Nov 4, 2015
d11c50b
Only compute distance to tile once. Tweak frame state.
bagnell Nov 4, 2015
85cc52b
Re-add ability to change the density by scaling the table.
bagnell Nov 5, 2015
7902c29
Fade fog in as the camera is tilted towards the horizon.
bagnell Nov 5, 2015
5420561
Fix tests.
bagnell Nov 5, 2015
64828bc
Add fog tests.
bagnell Nov 5, 2015
22de5d1
Add fog documentation.
bagnell Nov 5, 2015
6f8fb41
Merge branch 'master' into fog
bagnell Nov 5, 2015
403b049
Update fog Sandcastle example with positions that demonstrate perform…
bagnell Nov 5, 2015
10a3b97
Fix cracking between the globe and the atmosphere.
bagnell Nov 6, 2015
c6ce4c2
Fix fog for views with negative altitude.
bagnell Nov 6, 2015
333c8f0
Move fog code from scene to new Fog object.
bagnell Nov 6, 2015
186c63f
Enable fog in the tests.
bagnell Nov 6, 2015
7d7c3b2
Tweak CHANGES.md
pjcozzi Nov 7, 2015
ed30aa0
Merge branch 'master' into fog
bagnell Nov 9, 2015
28d15df
Fix shader compile in Firefox/IE.
bagnell Nov 9, 2015
4cccade
Only render atmosphere when terrain tiles are rendered.
bagnell Nov 9, 2015
3ba3717
Add checkbox to enable/disable fog in the terrain sandcastle example.
bagnell Nov 9, 2015
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
2 changes: 1 addition & 1 deletion Source/Renderer/UniformState.js
Original file line number Diff line number Diff line change
@@ -912,7 +912,7 @@ define([
this._entireFrustum.y = camera.frustum.far;
this.updateFrustum(camera.frustum);

this._fogDensity = frameState.fogDensity;
this._fogDensity = frameState.fog.density;

this._frameState = frameState;
this._temeToPseudoFixed = Transforms.computeTemeToPseudoFixedMatrix(frameState.time, this._temeToPseudoFixed);
8 changes: 5 additions & 3 deletions Source/Scene/FrameState.js
Original file line number Diff line number Diff line change
@@ -136,9 +136,11 @@ define([
*/
this.scene3DOnly = false;

this.fogEnabled = true;
this.fogDensity = undefined;
this.fogSSE = undefined;
this.fog = {
enabled : true,
density : undefined,
sse : undefined
};
};

/**
10 changes: 6 additions & 4 deletions Source/Scene/GlobeSurfaceTileProvider.js
Original file line number Diff line number Diff line change
@@ -440,9 +440,11 @@ define([
* @returns {Visibility} The visibility of the tile.
*/
GlobeSurfaceTileProvider.prototype.computeTileVisibility = function(tile, frameState, occluders) {
if (frameState.fogEnabled) {
var distance = this.computeDistanceToTile(tile, frameState);
if (CesiumMath.fog(distance, frameState.fogDensity) >= 1.0) {
var distance = this.computeDistanceToTile(tile, frameState);
tile._distance = distance;

if (frameState.fog.enabled) {
if (CesiumMath.fog(distance, frameState.fog.density) >= 1.0) {
// Tile is completely in fog so return that it is not visible.
return Visibility.NONE;
}
@@ -938,7 +940,7 @@ define([
var oceanNormalMap = tileProvider.oceanNormalMap;
var showOceanWaves = showReflectiveOcean && defined(oceanNormalMap);
var hasVertexNormals = tileProvider.terrainProvider.ready && tileProvider.terrainProvider.hasVertexNormals;
var enableFog = frameState.fogEnabled;
var enableFog = frameState.fog.enabled;

if (showReflectiveOcean) {
--maxTextures;
4 changes: 1 addition & 3 deletions Source/Scene/QuadtreePrimitive.js
Original file line number Diff line number Diff line change
@@ -442,9 +442,7 @@ define([

var maxGeometricError = primitive._tileProvider.getLevelMaximumGeometricError(tile.level);

var distance = primitive._tileProvider.computeDistanceToTile(tile, frameState);
tile._distance = distance;

var distance = tile._distance;
var height = frameState.context.drawingBufferHeight;

var camera = frameState.camera;
1 change: 1 addition & 0 deletions Source/Scene/Scene.js
Original file line number Diff line number Diff line change
@@ -963,6 +963,7 @@ define([

var heightsTable = [659.246, 1275.6501, 2151.1192, 3141.7763, 4777.5198, 6281.2493, 12364.307, 15900.765, 49889.0549, 78026.8259, 99260.7344, 120036.3873, 151011.0158, 156091.1953, 203849.3112, 274866.9803, 319916.3149, 493552.0528, 628733.5874, 1027505.709];
var densityTable = [2.0e-4, 1.0e-4, 7.0e-5, 5.0e-5, 4.0e-5, 3.0e-5, 1.9e-5, 1.0e-5, 8.5e-6, 6.2e-6, 5.8e-6, 5.3e-6, 5.2e-6, 5.1e-6, 4.2e-6, 4.0e-6, 3.4e-6, 2.6e-6, 2.2e-6, 1.6e-6];

var tableLastIndex = 0;

function findInterval(height) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is really similar to some spline code you wrote a few years ago. It's not reasonable/possible to reuse that?