Skip to content

Commit

Permalink
Merge pull request #57 from AnalyticalGraphicsInc/sensortweak
Browse files Browse the repository at this point in the history
Added showThroughEllipsoid to CustomSensorVolume and RectangularPyramidS...
  • Loading branch information
bagnell committed Jun 5, 2012
2 parents a3db29c + 24f524f commit 8ab7cf2
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Beta Releases
* Changed `Tipsify.tipsify` and `Tipsify.calculateACMR` to accept an object literal instead of three separate arguments. Supplying a maximum index and cache size is now optional.
* Added `CentralBody.northPoleColor` and `CentralBody.southPoleColor` to fill in the poles if they are not covered by a texture.
* Added `Polygon.configureExtent` to create a polygon defined by west, south, east, and north values.
* Added `showThroughEllipsoid` to `CustomSensorVolume` and `RectangularPyramidSensorVolume` to allow sensors to draw through Earth.

### b5 - 05/15/2012

Expand Down
24 changes: 20 additions & 4 deletions Source/Scene/CustomSensorVolume.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,29 @@ define([
* <code>true</code> if this sensor will be shown; otherwise, <code>false</code>
*
* @type Boolean
*
* @see CustomSensorVolume#showIntersection
*/
this.show = (typeof t.show === "undefined") ? true : t.show;

/**
* DOC_TBA
*
* @type Boolean
*
* @see CustomSensorVolume#show
*/
this.showIntersection = (typeof t.showIntersection === "undefined") ? true : t.showIntersection;

/**
* <p>
* Determines if a sensor intersecting the ellipsoid is drawn through the ellipsoid and potentially out
* to the other side, or if the part of the sensor intersecting the ellipsoid stops at the ellipsoid.
* </p>
* <p>
* The default is <code>false</code>, meaning the sensor will not go through the ellipsoid.
* </p>
*
* @type Boolean
*/
this.showThroughEllipsoid = (typeof t.showThroughEllipsoid === "undefined") ? false : t.showThroughEllipsoid;

/**
* The 4x4 transformation matrix that transforms this sensor from model to world coordinates. In it's model
* coordinates, the sensor's principal direction is along the positive z-axis. The clock angle, sometimes
Expand Down Expand Up @@ -153,6 +162,9 @@ define([
u_model : function() {
return that.modelMatrix;
},
u_showThroughEllipsoid : function() {
return that.showThroughEllipsoid;
},
u_showIntersection : function() {
return that.showIntersection;
},
Expand Down Expand Up @@ -319,6 +331,10 @@ define([
depthMask : false
});
}
// This would be better served by depth testing with a depth buffer that does not
// include the ellipsoid depth - or a g-buffer containing an ellipsoid mask
// so we can selectively depth test.
this._rs.depthTest.enabled = !this.showThroughEllipsoid;

// Recompile shader when material changes
if (!this._material || (this._material !== this.material)) {
Expand Down
18 changes: 14 additions & 4 deletions Source/Scene/RectangularPyramidSensorVolume.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,29 @@ define([
* <code>true</code> if this sensor will be shown; otherwise, <code>false</code>
*
* @type Boolean
*
* @see RectangularPyramidSensorVolume#showIntersection
*/
this.show = (typeof t.show === "undefined") ? true : t.show;

/**
* DOC_TBA
*
* @type Boolean
*
* @see RectangularPyramidSensorVolume#show
*/
this.showIntersection = (typeof t.showIntersection === "undefined") ? true : t.showIntersection;

/**
* <p>
* Determines if a sensor intersecting the ellipsoid is drawn through the ellipsoid and potentially out
* to the other side, or if the part of the sensor intersecting the ellipsoid stops at the ellipsoid.
* </p>
* <p>
* The default is <code>false</code>, meaning the sensor will not go through the ellipsoid.
* </p>
*
* @type Boolean
*/
this.showThroughEllipsoid = (typeof t.showThroughEllipsoid === "undefined") ? false : t.showThroughEllipsoid;

/**
* The 4x4 transformation matrix that transforms this sensor from model to world coordinates. In it's model
* coordinates, the sensor's principal direction is along the positive z-axis. Half angles measured from the
Expand Down Expand Up @@ -147,6 +156,7 @@ define([

s.show = this.show;
s.showIntersection = this.showIntersection;
s.showThroughEllipsoid = this.showThroughEllipsoid;
s.modelMatrix = this.modelMatrix;
s.bufferUsage = this.bufferUsage;
s.radius = this.radius;
Expand Down
30 changes: 18 additions & 12 deletions Source/Shaders/CustomSensorVolumeFS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#endif

uniform bool u_showIntersection;
uniform bool u_showThroughEllipsoid;

uniform float u_sensorRadius;
uniform vec4 u_pickColor;

Expand Down Expand Up @@ -92,19 +94,23 @@ void main()
{
agi_ellipsoid ellipsoid = agi_getWgs84EllipsoidEC();

// Discard if in the ellipsoid
// PERFORMANCE_IDEA: A coarse check for ellipsoid intersection could be done on the CPU first.
if (agi_pointInEllipsoid(ellipsoid, v_positionWC))
{
discard;
}

// Discard if in the sensor's shadow
if (inSensorShadow(v_sensorVertexWC, ellipsoid, v_positionEC))
{
discard;
// Occluded by the ellipsoid?
if (!u_showThroughEllipsoid)
{
// Discard if in the ellipsoid
// PERFORMANCE_IDEA: A coarse check for ellipsoid intersection could be done on the CPU first.
if (agi_pointInEllipsoid(ellipsoid, v_positionWC))
{
discard;
}

// Discard if in the sensor's shadow
if (inSensorShadow(v_sensorVertexWC, ellipsoid, v_positionEC))
{
discard;
}
}

// Discard if not in the sensor's sphere
// PERFORMANCE_IDEA: We can omit this check if the radius is Number.POSITIVE_INFINITY.
if (distance(v_positionEC, v_sensorVertexEC) > u_sensorRadius)
Expand Down

0 comments on commit 8ab7cf2

Please sign in to comment.