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

Materials on Ground Primitives #6393

Merged
merged 44 commits into from
May 15, 2018
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
bdf302e
able to get world coordinates from depth tex
likangning93 Feb 13, 2018
4fe0397
texcoords from naive inverse trig
likangning93 Feb 20, 2018
956df6c
using cg ref approx to compute spherical coordinates on CPU and GPU
likangning93 Mar 2, 2018
529b5ab
add separate shader for shadow volume final pass, use a cubic instead…
likangning93 Mar 4, 2018
7af7d47
merged in master
likangning93 Mar 8, 2018
3e5c724
WIP material support for ground primitives w/normals from depth tex
likangning93 Mar 20, 2018
0433738
change ground primitive normal computation to EC for less noise
likangning93 Mar 21, 2018
2b47810
reduce multifrustum artifacts for EC normals from depth
likangning93 Mar 21, 2018
693f7e2
bespoke shadow volume appearance shaders
likangning93 Mar 22, 2018
f9ca260
switch spherical coordinates computation to atan
likangning93 Mar 23, 2018
d02346b
simplified spherical coordinates via atan
likangning93 Mar 26, 2018
71b6095
merged in master
likangning93 Mar 28, 2018
e7c4679
added plane-based texcoords, still has precision artifacts
likangning93 Mar 28, 2018
23d6dfb
changed texcoord planes to use a model matrix attribute, less inaccur…
likangning93 Mar 29, 2018
62ab0ba
using double-precision points for planes, added switching between pla…
likangning93 Mar 29, 2018
2cb5132
add batching for ground primitives
likangning93 Mar 29, 2018
9212796
PR feedback
likangning93 Apr 5, 2018
8e59e2d
add texture coordinate rotation for materials on GroundPrimitives
likangning93 Apr 11, 2018
5ee2f07
added GroundPrimitives material support for 2D/CV [ci skip]
likangning93 Apr 12, 2018
849c8a6
reduce batch table use for 2D texcoords on GroundPrimitives [ci skip]
likangning93 Apr 12, 2018
6b43300
add batched drawing for pick [ci skip]
likangning93 Apr 19, 2018
de2268a
cleanup for shadow volume material vertex shaders [ci skip]
likangning93 Apr 20, 2018
1d9cb79
merged in master, issues with log depth [ci skip]
likangning93 Apr 20, 2018
2aba8f0
fix log depth with GroundPrimitive materials [ci skip]
likangning93 Apr 24, 2018
0844b9d
cleanup for materials on GroundPrimitives [ci skip]
likangning93 Apr 24, 2018
d9ed5c5
unit tests
likangning93 Apr 27, 2018
5e4f46c
updates for planar texcoords in 3D
likangning93 Apr 27, 2018
4a00da4
factor height into GroundPrimitive texcoord planes
likangning93 Apr 29, 2018
d13d97f
PR comments
likangning93 May 2, 2018
5b0c259
add fallback for IE
likangning93 May 3, 2018
e35db9d
merged in master
likangning93 May 3, 2018
6061880
added development Sandcastles, fixed dynamic Entities, updated CHANGE…
likangning93 May 3, 2018
5300fda
fix headers in new development Sandcastle examples
likangning93 May 4, 2018
892b7db
add support for materials on dynamic terrain entities, fix texture co…
likangning93 May 7, 2018
ac71c04
compute tight rectangles for rotated texture coordinates [ci skip]
likangning93 May 9, 2018
41236c4
add specs for tight oriented rectangles for texture coordinates
likangning93 May 9, 2018
921a3db
fix fallback picking
likangning93 May 9, 2018
75dcb60
fix test failures with webgl stub for StaticGroundGeometryPerMaterial…
likangning93 May 10, 2018
fe8d1f7
compute texture coordinate rotation parameters in local ENU for Ellip…
likangning93 May 11, 2018
9643b2c
doc tweaks
likangning93 May 11, 2018
2aaf979
PR feedback and cleanup
likangning93 May 11, 2018
16c7305
handle ClassificationType BOTH and CESIUM_3D_TILE with materials on G…
likangning93 May 15, 2018
fbf05c8
format CHANGES.md entry with bullets
likangning93 May 15, 2018
4f580be
add textured terrain entity example to Ground Clamping Sandcastle
likangning93 May 15, 2018
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
70 changes: 70 additions & 0 deletions Apps/Sandcastle/gallery/Hello World.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,76 @@
'use strict';
//Sandcastle_Begin
var viewer = new Cesium.Viewer('cesiumContainer');

var instance = new Cesium.GeometryInstance({
Copy link
Contributor

Choose a reason for hiding this comment

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

For clean git history, please don't submit temp code to Sandcastle's Hello World (note that I use to do exactly this to the default Cesium app years ago)

geometry : new Cesium.EllipseGeometry({
center : Cesium.Cartesian3.fromDegrees(-100.0, 20.0),
semiMinorAxis : 500000.0,
semiMajorAxis : 1000000.0,
rotation : Cesium.Math.PI_OVER_FOUR,
vertexFormat : Cesium.VertexFormat.POSITION_AND_ST
}),
id : 'object returned when this instance is picked and to get/set per-instance attributes'
});

var checkerboardMaterial = Cesium.Material.fromType('Checkerboard');

var ellipsoidSurfaceAppearance1 = new Cesium.EllipsoidSurfaceAppearance({
material : checkerboardMaterial
});

var stripeMaterial = Cesium.Material.fromType('Stripe');

var ellipsoidSurfaceAppearance2 = new Cesium.EllipsoidSurfaceAppearance({
material : stripeMaterial
});

var perInstanceColorAppearance = new Cesium.PerInstanceColorAppearance({
flat : true
});

var elPrimitive = viewer.scene.primitives.add(new Cesium.GroundPrimitive({
geometryInstances : instance,
appearance : ellipsoidSurfaceAppearance1
}));
/*
var greenRectangle = viewer.entities.add({
name : 'Green translucent, rotated, and extruded rectangle at height with outline',
rectangle : {
coordinates : Cesium.Rectangle.fromRadians(-1.8582078985933261, 0.23654029197299448, -1.6230525464414889, 0.4570541830085829),
material : Cesium.Color.GREEN.withAlpha(0.5),
height : 0,
outline : true, // height must be set for outline to display
outlineColor : Cesium.Color.BLACK
}
});
*/
Sandcastle.addToolbarButton('switch appearances to stripe material', function() {
ellipsoidSurfaceAppearance1.material = stripeMaterial;
ellipsoidSurfaceAppearance2.material = stripeMaterial;
});

Sandcastle.addToolbarButton('switch appearances to check material', function() {
ellipsoidSurfaceAppearance1.material = checkerboardMaterial;
ellipsoidSurfaceAppearance2.material = checkerboardMaterial;
});

Sandcastle.addToolbarButton('switch to appearance 1', function() {
elPrimitive.appearance = ellipsoidSurfaceAppearance1;
});

Sandcastle.addToolbarButton('switch to appearance 2', function() {
elPrimitive.appearance = ellipsoidSurfaceAppearance2;
});

Sandcastle.addToolbarButton('switch to color appearance', function() {
elPrimitive.appearance = perInstanceColorAppearance;
});

Sandcastle.addToolbarButton('switch to undefined appearance', function() {
elPrimitive.appearance = undefined;
});

//Sandcastle_End
Sandcastle.finishedLoading();
}
Expand Down
220 changes: 220 additions & 0 deletions Apps/Sandcastle/gallery/batchingGroundPrims.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="description" content="Use Viewer to start building new applications or easily embed Cesium into existing applications.">
<meta name="cesium-sandcastle-labels" content="Beginner, Showcases">
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a "developer" Sandcastle example?

Also do not use abbreviations in file names.

<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/require.js"></script>
<script type="text/javascript">
if(typeof require === "function") {
require.config({
baseUrl : '../../../Source',
waitSeconds : 120
});
}
</script>
</head>
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html">
<style>
@import url(../templates/bucket.css);
</style>
<div id="cesiumContainer" class="fullSize"></div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar"></div>
<script id="cesium_sandcastle_script">
function startup(Cesium) {
'use strict';
//Sandcastle_Begin

var worldTerrain = Cesium.createWorldTerrain({
requestWaterMask: true,
requestVertexNormals: true
});

var viewer = new Cesium.Viewer('cesiumContainer', {
selectionIndicator: false,
terrainProvider: worldTerrain
});
/*
viewer.extend(Cesium.viewerCesium3DTilesInspectorMixin);
var inspectorViewModel = viewer.cesium3DTilesInspector.viewModel;
*/
var scene = viewer.scene;

viewer.scene.globe.depthTestAgainstTerrain = true;
viewer.scene.copyGlobeDepth = true;

function offsetPositions(positions, degreeOffset) {
positions = scene.globe.ellipsoid.cartesianArrayToCartographicArray(positions);
var delta = Cesium.Math.toRadians(degreeOffset);
for (var i = 0; i < positions.length; ++i) {
var position = positions[i];
position.latitude += delta;
position.longitude += delta;
}
return scene.globe.ellipsoid.cartographicArrayToCartesianArray(positions);
}

var positions = [new Cesium.Cartesian3(-2358138.847340281, -3744072.459541374, 4581158.5714175375),
new Cesium.Cartesian3(-2357231.4925370603, -3745103.7886602185, 4580702.9757762635),
new Cesium.Cartesian3(-2355912.902205431, -3744249.029778454, 4582402.154378103),
new Cesium.Cartesian3(-2357208.0209552636, -3743553.4420488174, 4581961.863286629)];

var concavePositions = [
new Cesium.Cartesian3(-2353381.4891308164, -3747386.1222378365, 4577999.291515961),
new Cesium.Cartesian3(-2359513.937204245, -3743087.2343810294, 4578357.188560644),
new Cesium.Cartesian3(-2356102.0286082155, -3739921.552293276, 4582670.218770547),
new Cesium.Cartesian3(-2353889.0353209395, -3741183.2274413602, 4582776.909071608),
new Cesium.Cartesian3(-2355072.390487758, -3742865.615615464, 4580808.044684757),
new Cesium.Cartesian3(-2356109.6661414686, -3741994.0607898533, 4580985.489703348),
new Cesium.Cartesian3(-2357041.8328847606, -3743225.9693035223, 4579509.2148039425),
new Cesium.Cartesian3(-2354586.752280607, -3744890.9511893727, 4579411.591389144),
new Cesium.Cartesian3(-2353213.0268325945, -3743712.1202877173, 4581070.08828045),
new Cesium.Cartesian3(-2353637.930711704, -3743402.9513476435, 4581104.219550749),
new Cesium.Cartesian3(-2352875.095159641, -3742564.819171856, 4582173.540953957),
new Cesium.Cartesian3(-2350669.646050987, -3743751.6823160048, 4582334.8406995395)
];
/*
// concave polygon
var redPolygon1 = viewer.entities.add({
name : 'concave polygon on surface',
polygon : {
hierarchy : offsetPositions(concavePositions, 0.0),
material : '../images/Cesium_Logo_Color.jpg'
}
});
*/
// polygons with non-overlapping extents seem to be batchable without problems
/*
var redPolygon1 = viewer.entities.add({
name : 'Red polygon on surface',
polygon : {
hierarchy : offsetPositions(positions, 0.0),
material : Cesium.Color.RED.withAlpha(0.5)
}
});

var redPolygon2 = viewer.entities.add({
name : 'Red polygon on surface',
polygon : {
hierarchy : offsetPositions(positions, -0.01),
material : Cesium.Color.GREEN.withAlpha(0.5)
}
});

var redPolygon3 = viewer.entities.add({
name : 'Red polygon on surface',
polygon : {
hierarchy : offsetPositions(positions, 0.01),
material : Cesium.Color.BLUE.withAlpha(0.5)
}
});

var redPolygon4 = viewer.entities.add({
name : 'Red polygon on surface',
polygon : {
hierarchy : offsetPositions(positions, 0.02),
material : '../images/Cesium_Logo_Color.jpg'
}
});

var redPolygon5 = viewer.entities.add({
name : 'Red polygon on surface',
polygon : {
hierarchy : offsetPositions(positions, 0.03),
material :
new Cesium.CheckerboardMaterialProperty({
evenColor : Cesium.Color.WHITE,
oddColor : Cesium.Color.BLACK,
repeat : new Cesium.Cartesian2(4, 4)
})
}
});*/

// nearly overlapping rectangles over mt. st. helens

var latitude = 46.1922;
var longitude = -122.1934;

viewer.entities.add({
rectangle : {
coordinates : Cesium.Rectangle.fromDegrees(longitude + 0.001, latitude + 0.001, longitude + 0.2, latitude + 0.2),
material : Cesium.Color.BLUE.withAlpha(0.5)
}
});

viewer.entities.add({
rectangle : {
coordinates : Cesium.Rectangle.fromDegrees(longitude - 0.2, latitude + 0.001, longitude, latitude + 0.2),
material : Cesium.Color.GREEN.withAlpha(0.5)
}
});

viewer.entities.add({
rectangle : {
coordinates : Cesium.Rectangle.fromDegrees(longitude - 0.2, latitude - 0.2, longitude, latitude),
material : Cesium.Color.RED.withAlpha(0.5)
}
});

viewer.entities.add({
rectangle : {
coordinates : Cesium.Rectangle.fromDegrees(longitude + 0.001, latitude - 0.2, longitude + 0.2, latitude),
material : Cesium.Color.YELLOW.withAlpha(0.5)
}
});

var checkerboard = new Cesium.CheckerboardMaterialProperty({
evenColor : Cesium.Color.ORANGE,
oddColor : Cesium.Color.YELLOW,
repeat : new Cesium.Cartesian2(14, 14)
});

var rightHandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
rightHandler.setInputAction(function(movement) {
var cartesian = viewer.scene.pickPosition(movement.position);
//var cartesian = viewer.camera.pickEllipsoid(movement.position, scene.globe.ellipsoid);
if (cartesian) {
var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
var lat = Cesium.Math.toDegrees(cartographic.latitude);
var long = Cesium.Math.toDegrees(cartographic.longitude);

var normalized = Cesium.Cartesian3.normalize(cartesian, cartesian);
console.log(normalized);

//viewer.entities.removeAll();
viewer.entities.add({
name : lat + ' ' + long,
rectangle : {
coordinates : Cesium.Rectangle.fromDegrees(long - 0.0002, lat - 0.0001, long + 0.0002, lat + 0.0001),
material : checkerboard
}
});
}
}, Cesium.ScreenSpaceEventType.RIGHT_CLICK);

var leftHandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
leftHandler.setInputAction(function(movement) {
var cartesian = viewer.scene.pickPosition(movement.position);
if (cartesian) {
console.log('new Cesium.Cartesian3(' + cartesian.x + ', ' + cartesian.y + ', ' + cartesian.z + '),');
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);

viewer.zoomTo(viewer.entities);

//Sandcastle_End
Sandcastle.finishedLoading();
}
if (typeof Cesium !== "undefined") {
startup(Cesium);
} else if (typeof require === "function") {
require(["Cesium"], startup);
}
</script>
</body>
</html>
Loading