根据太阳光对倾斜摄影的光照,计算出垂直地面的阴影面积所占比例
1、加载模型的阴影计算
const viewer = new Cesium.Viewer("cesiumContainer", {
...opts,
shadows: true,
timeline: true,
shouldAnimate: true,
animation: true,
//这句很重要
contextOptions: {
requestWebgl2: true,
msaa: true,
}
});
const shadowMap = viewer.shadowMap;
shadowMap.maximumDistance = 10000.0;
console.log(shadowMap);
viewer.terrainProvider = Cesium.createWorldTerrain({
requestWaterMask: true,
requestVertexNormals: true,
})
let entity=viewer.entities.add({
position: new Cesium.Cartesian3.fromDegrees(longitude, latitude, height),
name,
entityOptions: {
...options
},
model: {
uri: model,
shadows: Cesium.ShadowMode.ENABLED
}
})
2、思路
通过创建 先创建个区域,在区域内打点,然后计算出各个时间太阳位置,计算打点位置和太阳之前是否有遮挡,分析一天内,白天被遮挡的时间,比上白天时间,
还有网上说,“通过观察可以发现,上面的计算过程其实就是每个测试点都进行一次相同的操作,这种计算就非常适合放到 GPU
中进行。
因此我们其实可以创建一个 DrawCommand
,传入所有点的位置和当前的阴影信息,编写着色器完成上述计算,将结果输出成纹理,最后从纹理上读取结果即可。”
这个就不清楚怎么搞了,先简单后难吧,先计算一个点的阴影度