Cesium 与 Babylon.js 可视化 glsl 特效篇(十八)
我决定不从Babylonjs 基础来讲了 直接整合cesium与babylonjs可视化来讲
我整合一个类库 后续不断更新中
- npm i @haibalai/cesium-babylonjs
初始化cesium -babylonjs 类库, map 是cesium 的viewer对象
- import { BabylonMapManager } from "@haibalai/cesium-babylonjs";
- BabylonMapManager.init(map);
添加特效
- import { BabylonMapManager } from "@haibalai/cesium-babylonjs";
- const fragmentShader = `
- precision highp float;
- uniform float iTime;
- const vec2 iResolution = vec2(1.0,1.0);
- varying vec2 vUv;
- const mat2 m = mat2( 0.80, 0.60, -0.60, 0.80 );
- floatnoise( in vec2 p )
- {
- return sin(p.x)*sin(p.y);
- }
- floatfbm4( vec2 p )
- {
- float f = 0.0;
- f += 0.5000*noise( p ); p = m*p*2.02;
- f += 0.2500*noise( p ); p = m*p*2.03;
- f += 0.1250*noise( p ); p = m*p*2.01;
- f += 0.0625*noise( p );
- return f/0.9375;
- }
- floatfbm6( vec2 p )
- {
- float f = 0.0;
- f += 0.500000*(0.5+0.5*noise( p )); p = m*p*2.02;
- f += 0.250000*(0.5+0.5*noise( p )); p = m*p*2.03;
- f += 0.125000*(0.5+0.5*noise( p )); p = m*p*2.01;
- f += 0.062500*(0.5+0.5*noise( p )); p = m*p*2.04;
- f += 0.031250*(0.5+0.5*noise( p )); p = m*p*2.01;
- f += 0.015625*(0.5+0.5*noise( p ));
- return f/0.96875;
- }
- vec2 fbm4_2( vec2 p )
- {
- return vec2(fbm4(p), fbm4(p+vec2(7.8)));
- }