Hi Dev-Team,
I want to use custom shaded geometries draped over terrain and 3d tiles.
I use GroundPrimitive to get geometries clamped to the ground, but the groundprimitives are not triggered to get rendered with provided shader code. (my GPU supports 8-bit Stencil buffering)
It simply works (yellow ellipse) when using Primitive itself, but that’s not clamped to the ground this way. GroundPrimitive just rendered as default red colored ellipse.
Simple Code Example:
var viewer = new Cesium.Viewer(‘cesiumContainer’, {
timeline: false,
shadows: true,
terrainShadows: Cesium.ShadowMode.ENABLED,
terrainProvider: Cesium.createWorldTerrain({
requestVertexNormals : true
})
});
var lon = -122.423;
var lat = 37.7728;
var instance = new Cesium.GeometryInstance({
geometry : new Cesium.EllipseGeometry({
center : Cesium.Cartesian3.fromDegrees(lon, lat),
semiMinorAxis : 120.0,
semiMajorAxis : 150.0,
rotation : 320,
vertexFormat : Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT
}),
});
var myAppearance = new Cesium.EllipsoidSurfaceAppearance({
fragmentShaderSource :
‘void main() { \n’+
‘gl_FragColor = vec4(1.0, 1.0, 0.0, 0.5); \n’+
‘} \n’,
});
var ellipse = viewer.scene.primitives.add(new Cesium.GroundPrimitive({
geometryInstances : instance,
shadows : Cesium.ShadowMode.ENABLED,
appearance : myAppearance,
debugShowBoundingVolume : true
}));
var center = Cesium.Cartesian3.fromDegrees(lon, lat);
viewer.camera.lookAt(center, new Cesium.Cartesian3(30.0, 0.0, 4200.0));
Context
At the end I want to have shaded geometries over terrain and 3d tiles based on a light source next to the geometry. Simple case would be to decide whether a fragment is in shadow to the light source or not.
As I need to display multiple geometries from different light sources, using Shadowmap is not an option.
Version is 1.60
Questions
So why are the GroundPrimitives are not triggered to get rendered with custom shader source?
Do I need to load the groundprimitives from a DataSource instead? If so, what’s the reason behind that?
Any other way to achieve what I want?
any help would be appreciated
Many Thanks
Karsten