Skip to content

Extend GroundPrimitive shadow volume based on screen space error #4751

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

Merged
merged 20 commits into from
Jan 6, 2017
Merged
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ Change Log
### 1.30 - 2017-02-01

* Updated the morph so the default view in Columbus View is now angled. [#3878](https://github.com/AnalyticalGraphicsInc/cesium/issues/3878)
* Fixed bug where `GroundPrimitives` where rendering incorrectly or disappearing at different zoom levels. [#4161](https://github.com/AnalyticalGraphicsInc/cesium/issues/4161) [#4326](https://github.com/AnalyticalGraphicsInc/cesium/issues/4326)
* Fixed sky atmosphere from causing incorrect picking and hanging drill picking. [#4783](https://github.com/AnalyticalGraphicsInc/cesium/issues/4783) and [#4784](https://github.com/AnalyticalGraphicsInc/cesium/issues/4784)

### 1.29 - 2017-01-02
10 changes: 7 additions & 3 deletions Source/Core/CircleGeometry.js
Original file line number Diff line number Diff line change
@@ -68,7 +68,8 @@ define([
extrudedHeight : options.extrudedHeight,
granularity : options.granularity,
vertexFormat : options.vertexFormat,
stRotation : options.stRotation
stRotation : options.stRotation,
shadowVolume: options.shadowVolume
};
this._ellipseGeometry = new EllipseGeometry(ellipseGeometryOptions);
this._workerName = 'createCircleGeometry';
@@ -113,7 +114,8 @@ define([
vertexFormat : new VertexFormat(),
stRotation : undefined,
semiMajorAxis : undefined,
semiMinorAxis : undefined
semiMinorAxis : undefined,
shadowVolume: undefined
};

/**
@@ -133,6 +135,7 @@ define([
scratchOptions.granularity = ellipseGeometry._granularity;
scratchOptions.vertexFormat = VertexFormat.clone(ellipseGeometry._vertexFormat, scratchOptions.vertexFormat);
scratchOptions.stRotation = ellipseGeometry._stRotation;
scratchOptions.shadowVolume = ellipseGeometry._shadowVolume;

if (!defined(result)) {
scratchOptions.radius = ellipseGeometry._semiMajorAxis;
@@ -173,7 +176,8 @@ define([
granularity : granularity,
extrudedHeight : minHeight,
height : maxHeight,
vertexFormat : VertexFormat.POSITION_ONLY
vertexFormat : VertexFormat.POSITION_ONLY,
shadowVolume: true
});
};

63 changes: 46 additions & 17 deletions Source/Core/CorridorGeometry.js
Original file line number Diff line number Diff line change
@@ -561,8 +561,8 @@ define([

function computePositionsExtruded(params, vertexFormat) {
var topVertexFormat = new VertexFormat({
position : vertexFormat.positon,
normal : (vertexFormat.normal || vertexFormat.binormal),
position : vertexFormat.position,
normal : (vertexFormat.normal || vertexFormat.binormal || params.shadowVolume),
tangent : vertexFormat.tangent,
binormal : (vertexFormat.normal || vertexFormat.binormal),
st : vertexFormat.st
@@ -590,28 +590,49 @@ define([
newPositions.set(wallPositions, length * 2);
attributes.position.values = newPositions;

length /= 3;
attributes = extrudedAttributes(attributes, vertexFormat);
var size = length / 3;
if (params.shadowVolume) {
var topNormals = attributes.normal.values;
length = topNormals.length;

var extrudeNormals = new Float32Array(length * 6);
for (i = 0; i < length; i ++) {
topNormals[i] = -topNormals[i];
}
//only get normals for bottom layer that's going to be pushed down
extrudeNormals.set(topNormals, length); //bottom face
extrudeNormals = addWallPositions(topNormals, length*4, extrudeNormals); //bottom wall
attributes.extrudeDirection = new GeometryAttribute({
componentDatatype : ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : extrudeNormals
});
if (!vertexFormat.normal) {
attributes.normal = undefined;
}
}

var i;
var iLength = indices.length;
var twoLength = length + length;
var newIndices = IndexDatatype.createTypedArray(newPositions.length / 3, iLength * 2 + twoLength * 3);
var twoSize = size + size;
var newIndices = IndexDatatype.createTypedArray(newPositions.length / 3, iLength * 2 + twoSize * 3);
newIndices.set(indices);
var index = iLength;
for (i = 0; i < iLength; i += 3) { // bottom indices
var v0 = indices[i];
var v1 = indices[i + 1];
var v2 = indices[i + 2];
newIndices[index++] = v2 + length;
newIndices[index++] = v1 + length;
newIndices[index++] = v0 + length;
newIndices[index++] = v2 + size;
newIndices[index++] = v1 + size;
newIndices[index++] = v0 + size;
}

attributes = extrudedAttributes(attributes, vertexFormat);
var UL, LL, UR, LR;

for (i = 0; i < twoLength; i += 2) { //wall indices
UL = i + twoLength;
LL = UL + twoLength;
for (i = 0; i < twoSize; i += 2) { //wall indices
UL = i + twoSize;
LL = UL + twoSize;
UR = UL + 1;
LR = LL + 1;
newIndices[index++] = UL;
@@ -793,14 +814,15 @@ define([
this._extrudedHeight = defaultValue(options.extrudedHeight, this._height);
this._cornerType = defaultValue(options.cornerType, CornerType.ROUNDED);
this._granularity = defaultValue(options.granularity, CesiumMath.RADIANS_PER_DEGREE);
this._shadowVolume = defaultValue(options.shadowVolume, false);
this._workerName = 'createCorridorGeometry';
this._rectangle = computeRectangle(positions, this._ellipsoid, width, this._cornerType);

/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
this.packedLength = 1 + positions.length * Cartesian3.packedLength + Ellipsoid.packedLength + VertexFormat.packedLength + Rectangle.packedLength + 5;
this.packedLength = 1 + positions.length * Cartesian3.packedLength + Ellipsoid.packedLength + VertexFormat.packedLength + Rectangle.packedLength + 6;
}

/**
@@ -845,7 +867,8 @@ define([
array[startingIndex++] = value._height;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._cornerType;
array[startingIndex] = value._granularity;
array[startingIndex++] = value._granularity;
array[startingIndex] = value._shadowVolume ? 1.0 : 0.0;

return array;
};
@@ -861,7 +884,8 @@ define([
height : undefined,
extrudedHeight : undefined,
cornerType : undefined,
granularity : undefined
granularity : undefined,
shadowVolume: undefined
};

/**
@@ -901,7 +925,8 @@ define([
var height = array[startingIndex++];
var extrudedHeight = array[startingIndex++];
var cornerType = array[startingIndex++];
var granularity = array[startingIndex];
var granularity = array[startingIndex++];
var shadowVolume = array[startingIndex] === 1.0;

if (!defined(result)) {
scratchOptions.positions = positions;
@@ -910,6 +935,7 @@ define([
scratchOptions.extrudedHeight = extrudedHeight;
scratchOptions.cornerType = cornerType;
scratchOptions.granularity = granularity;
scratchOptions.shadowVolume = shadowVolume;
return new CorridorGeometry(scratchOptions);
}

@@ -922,6 +948,7 @@ define([
result._cornerType = cornerType;
result._granularity = granularity;
result._rectangle = Rectangle.clone(rectangle);
result._shadowVolume = shadowVolume;

return result;
};
@@ -962,6 +989,7 @@ define([
height = h;
params.height = height;
params.extrudedHeight = extrudedHeight;
params.shadowVolume = corridorGeometry._shadowVolume;
attr = computePositionsExtruded(params, vertexFormat);
} else {
var computedPositions = CorridorGeometryLibrary.computePositions(params);
@@ -1000,7 +1028,8 @@ define([
granularity : granularity,
extrudedHeight : minHeight,
height : maxHeight,
vertexFormat : VertexFormat.POSITION_ONLY
vertexFormat : VertexFormat.POSITION_ONLY,
shadowVolume: true
});
};

Loading