-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
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 4fe0397
texcoords from naive inverse trig
likangning93 956df6c
using cg ref approx to compute spherical coordinates on CPU and GPU
likangning93 529b5ab
add separate shader for shadow volume final pass, use a cubic instead…
likangning93 7af7d47
merged in master
likangning93 3e5c724
WIP material support for ground primitives w/normals from depth tex
likangning93 0433738
change ground primitive normal computation to EC for less noise
likangning93 2b47810
reduce multifrustum artifacts for EC normals from depth
likangning93 693f7e2
bespoke shadow volume appearance shaders
likangning93 f9ca260
switch spherical coordinates computation to atan
likangning93 d02346b
simplified spherical coordinates via atan
likangning93 71b6095
merged in master
likangning93 e7c4679
added plane-based texcoords, still has precision artifacts
likangning93 23d6dfb
changed texcoord planes to use a model matrix attribute, less inaccur…
likangning93 62ab0ba
using double-precision points for planes, added switching between pla…
likangning93 2cb5132
add batching for ground primitives
likangning93 9212796
PR feedback
likangning93 8e59e2d
add texture coordinate rotation for materials on GroundPrimitives
likangning93 5ee2f07
added GroundPrimitives material support for 2D/CV [ci skip]
likangning93 849c8a6
reduce batch table use for 2D texcoords on GroundPrimitives [ci skip]
likangning93 6b43300
add batched drawing for pick [ci skip]
likangning93 de2268a
cleanup for shadow volume material vertex shaders [ci skip]
likangning93 1d9cb79
merged in master, issues with log depth [ci skip]
likangning93 2aba8f0
fix log depth with GroundPrimitive materials [ci skip]
likangning93 0844b9d
cleanup for materials on GroundPrimitives [ci skip]
likangning93 d9ed5c5
unit tests
likangning93 5e4f46c
updates for planar texcoords in 3D
likangning93 4a00da4
factor height into GroundPrimitive texcoord planes
likangning93 d13d97f
PR comments
likangning93 5b0c259
add fallback for IE
likangning93 e35db9d
merged in master
likangning93 6061880
added development Sandcastles, fixed dynamic Entities, updated CHANGE…
likangning93 5300fda
fix headers in new development Sandcastle examples
likangning93 892b7db
add support for materials on dynamic terrain entities, fix texture co…
likangning93 ac71c04
compute tight rectangles for rotated texture coordinates [ci skip]
likangning93 41236c4
add specs for tight oriented rectangles for texture coordinates
likangning93 921a3db
fix fallback picking
likangning93 75dcb60
fix test failures with webgl stub for StaticGroundGeometryPerMaterial…
likangning93 fe8d1f7
compute texture coordinate rotation parameters in local ENU for Ellip…
likangning93 9643b2c
doc tweaks
likangning93 2aaf979
PR feedback and cleanup
likangning93 16c7305
handle ClassificationType BOTH and CESIUM_3D_TILE with materials on G…
likangning93 fbf05c8
format CHANGES.md entry with bullets
likangning93 4f580be
add textured terrain entity example to Ground Clamping Sandcastle
likangning93 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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)