fabric: {
uniforms: {
depthMap: './images/depth_6.png',//水深截图
baseWaterColor: new Cesium.Color(64 / 255.0, 157 / 255.0, 253 / 255.0, 0.5),
blendColor: new Cesium.Color(0.0, 1.0, 0.7, 0.5),
// specularMap: './images/water.jpg', // Change to your specular map
normalMap: './images/waterNormals.jpg', // Change to your normal map
frequency: 800.0,
animationSpeed: 0.01,
amplitude: 3,
specularIntensity: 10,
fadeFactor: 1,
specularMap: "czm_defaultImage"
},
source: `
uniform sampler2D specularMap;
uniform sampler2D normalMap;
uniform sampler2D depthMap;
uniform vec4 baseWaterColor;
uniform vec4 blendColor;
uniform float frequency;
uniform float animationSpeed;
uniform float amplitude;
uniform float specularIntensity;
uniform float fadeFactor;
czm_material czm_getMaterial(czm_materialInput materialInput)
{
czm_material material = czm_getDefaultMaterial(materialInput);
float time = czm_frameNumber * animationSpeed;
float fade = max(1.0, (length(materialInput.positionToEyeEC) / 10000000000.0) * frequency * fadeFactor);
float specularMapValue = texture2D(specularMap, materialInput.st).r;
vec4 noise = czm_getWaterNoise(normalMap, materialInput.st * frequency, time, 0.0);
vec3 normalTangentSpace = noise.xyz * vec3(1.0, 1.0, (1.0 / amplitude));
normalTangentSpace.xy /= fade;
normalTangentSpace = mix(vec3(0.0, 0.0, 50.0), normalTangentSpace, specularMapValue);
normalTangentSpace = normalize(normalTangentSpace);
float tsPerturbationRatio = clamp(dot(normalTangentSpace, vec3(0.0, 0.0, 1.0)), 0.0, 1.0);
material.alpha = mix(blendColor.a, baseWaterColor.a, specularMapValue) * specularMapValue;
material.diffuse = mix(blendColor.rgb, baseWaterColor.rgb, specularMapValue);
material.diffuse += (0.1 * tsPerturbationRatio);
material.diffuse = material.diffuse;
material.normal = normalize(materialInput.tangentToEyeMatrix * normalTangentSpace);
material.specular = specularIntensity;
material.shininess = 10.0;
// handle alpha to hidden other area
// made by dzm
float depthMapShow = texture2D(depthMap, materialInput.st).a;
if(depthMapShow < 0.5){
material.alpha = depthMapShow;
}
// set different color by depth
// you can edify code by yourself
float dep = texture2D(depthMap, materialInput.st).r;
if(dep > 0.3){
material.diffuse -= vec3(0.2);
}
if(dep > 0.5){
material.diffuse -= vec3(0.2);
}
if(dep > 0.7){
material.diffuse -= vec3(0.2);
}
if(dep > 0.9){
material.diffuse -= vec3(0.2);
}
return material;
}
`
},