我决定不从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 = `
- constfloat ratio = 1.0;
- float PI = 3.1415926;
- uniform float iTime;
- const vec2 iResolution = vec2(1.0,1.0);
- varying vec2 vUv;
- constfloat cloudscale = 1.1;
- constfloat speed = 0.03;
- constfloat clouddark = 0.5;
- constfloat cloudlight = 0.3;
- constfloat cloudcover = 0.2;
- constfloat cloudalpha = 8.0;
- constfloat skytint = 0.5;
- const vec3 skycolour1 = vec3(0.2, 0.4, 0.6);
- const vec3 skycolour2 = vec3(0.4, 0.7, 1.0);
- const mat2 m = mat2( 1.6, 1.2, -1.2, 1.6 );
- vec2 hash( vec2 p ) {
- p = vec2(dot(p,vec2(127.1,311.7)), dot(p,vec2(269.5,183.3)));
- return -1.0 + 2.0*fract(sin(p)*43758.5453123);
- }
- floatnoise( in vec2 p ) {
- constfloat K1 = 0.366025404; // (sqrt(3)-1)/2;
- constfloat K2 = 0.211324865; // (3-sqrt(3))/6;
- vec2 i = floor(p + (p.x+p.y)*K1);
- vec2 a = p - i + (i.x+i.y)*K2;
Cesium 与 Babylon.js 可视化 glsl 特效篇(九) - 小专栏
标签:glsl,1.0,constfloat,babylonjs,js,cesium,vec2,Cesium,const From: https://www.cnblogs.com/haibalai/p/17217416.html