对于扎染纹理效果 我们先定义一下他的interface, 方便使用的人知道他的调用参数
export interface PMaterialTieDye{
lightColor?: any,
darkColor?: any,
frequency?: number,
}
对于扎染墙纹理我们叫 MaterialTieDye
```javascript
import { MaterialProperty } from "../MaterialProperty";
const defaultOption: PMaterialTieDye = {
lightColor: new Cesium.Color(1.0, 0.0, 0.0, 0.75),
darkColor: new Cesium.Color(1.0, 1.0, 1.0, 0.75),
frequency: 50.0
}
//扎染效果
export class MaterialTieDye extends MaterialProperty {
protected _getType(option: any): string {
return "MaterialTieDye"
}
constructor(option = defaultOption) {
super(MaterialTieDye.prototype, defaultOption, option);
}
protected _getTranslucent(material: any) {
var uniforms = material.uniforms
return uniforms.lightColor.alpha < 1.0 || uniforms.darkColor.alpha < 0.0
}
protected getSource(option: any): string {
return `
uniform vec4 lightColor;
uniform vec4 darkColor;
uniform float frequency;
czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec3 scaled = materialInput.str * frequency;
float t = abs(czm_snoise(scaled));
更多参考 https://xiaozhuanlan.com/topic/2371509846
网友评论