美文网首页
Cesium 自定义Material 系列 (十六)

Cesium 自定义Material 系列 (十六)

作者: haibalai | 来源:发表于2022-02-22 10:58 被阅读0次

对于扎染纹理效果 我们先定义一下他的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

相关文章

网友评论

      本文标题:Cesium 自定义Material 系列 (十六)

      本文链接:https://www.haomeiwen.com/subject/tgqglrtx.html