Cesium 自定义Material 系列 (十三)

2022-02-20  本文已影响0人  haibalai

对于水泥纹理效果 我们先定义一下他的interface, 方便使用的人知道他的调用参数

export interface PMaterialCement{

cementColor?: any,

grainScale?: number,

roughness?: number

}

对于水泥纹理纹理我们叫 MaterialCement

```javascript

import {MaterialProperty} from "./MaterialProperty";

const defaultOption: PMaterialCement = {

cementColor: new Cesium.Color(0.5, 0.5, 0.5, 1.0),

grainScale: 0.01,

roughness: 0.3

}

//水泥效果

export class MaterialCement extends MaterialProperty{

protected _getType(option: any): string {

return "MaterialCement"

}

constructor(option=defaultOption) {

super(MaterialCement.prototype, defaultOption, option);

}

protected _getTranslucent(material: any){

return material.uniforms.cementColor.alpha < 1.0

}

protected getSource(option: any): string {

return `

uniform vec4 cementColor;

uniform float grainScale;

uniform float roughness;

czm_material czm_getMaterial(czm_materialInput materialInput){

czm_material material = czm_getDefaultMaterial(materialInput);

float noise = czm_snoise(materialInput.st / grainScale);

noise = pow(noise, 5.0) * roughness;

vec4 color = cementColor;

 更多参考 https://xiaozhuanlan.com/topic/9217346085

上一篇下一篇

猜你喜欢

热点阅读