cesium 实现雾霾效果

cesium 实现雾霾效果

效果

在这里插入图片描述


      FogStage = Cesium.PostProcessStageLibrary.createBrightnessStage();
      FogStage.uniforms.brightness = 2;//整个场景通过后期渲染变亮 1为保持不变 大于1变亮 0-1变暗 uniforms后面为对应glsl里面定义的uniform参数
      FogStage = new Cesium.PostProcessStage({
        "name": "self",
        //sampleMode:PostProcessStageSampleMode.LINEAR,
        fragmentShader: "  uniform sampler2D colorTexture;\n" +
          "  uniform sampler2D depthTexture;\n" +
          "  varying vec2 v_textureCoordinates;\n" +
          "  void main(void)\n" +
          "  {\n" +
          "      vec4 origcolor=texture2D(colorTexture, v_textureCoordinates);\n" +
          "      vec4 fogcolor=vec4(0.8,0.8,0.8,0.5);\n" +
          "\n" +
          "      float depth = czm_readDepth(depthTexture, v_textureCoordinates);\n" +
          "      vec4 depthcolor=texture2D(depthTexture, v_textureCoordinates);\n" +
          "\n" +
          "      float f=(depthcolor.r-0.22)/0.7;\n" +  //0.7 调节雾的可见度
          "      if(f<0.0) f=0.0;\n" +
          "      else if(f>1.0) f=1.0;\n" +
          "      gl_FragColor = mix(origcolor,fogcolor,f);\n" +
          "   }"
      });



      window.viewer.scene.postProcessStages.add(FogStage);
      FogStage.enabled = true;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
要在Cesium实现抛物线效果,可以使用贝塞尔曲线来模拟抛物线的路径。以下是实现抛物线效果的步骤: 1. 使用entity方式创建一个新的实体对象。 2. 设置实体的position为抛物线的起始点。 3. 使用polyline实例化一个新的PolylineGraphics对象。 4. 将PolylineGraphics对象的positions属性设置为一个包含抛物线路径上的点的数组。 5. 设置PolylineGraphics对象的material为所需的抛物线材质。 6. 将PolylineGraphics对象添加到viewer中。 下面是一个示例代码,展示了如何在Cesium实现抛物线效果: ```javascript // 创建起始点和终点 var start = Cesium.Cartesian3.fromDegrees(113.9236839, 22.528061); var end = Cesium.Cartesian3.fromDegrees(113.925, 22.53); // 计算控制点 var controlPoint = new Cesium.Cartesian3( (start.x + end.x) / 2, (start.y + end.y) / 2, (start.z + end.z) / 2 + 1000 ); // 计算抛物线路径上的点 var numberOfPoints = 100; var positions = []; for (var i = 0; i <= numberOfPoints; i++) { var t = i / numberOfPoints; var x = (1 - t) * (1 - t) * start.x + 2 * (1 - t) * t * controlPoint.x + t * t * end.x; var y = (1 - t) * (1 - t) * start.y + 2 * (1 - t) * t * controlPoint.y + t * t * end.y; var z = (1 - t) * (1 - t) * start.z + 2 * (1 - t) * t * controlPoint.z + t * t * end.z; positions.push(new Cesium.Cartesian3(x, y, z)); } // 创建实体对象 viewer.entities.add({ polyline: { positions: positions, width: 10, material: new Cesium.PolylineGlowMaterialProperty({ glowPower: 0.5, color: Cesium.Color.YELLOW }) } }); ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

LBY_XK

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值