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;

你可能感兴趣的:(服务器,运维)