Cesium 自定义Material 系列 (十三)
作者:互联网
对于水泥纹理效果 我们先定义一下他的interface, 方便使用的人知道他的调用参数
export interface PMaterialCement{
cementColor?: any,
grainScale?: number,
roughness?: number
}
对于水泥纹理纹理我们叫 MaterialCement
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
标签:Material,自定义,material,MaterialCement,roughness,czm,Cesium,any,cementColor 来源: https://blog.csdn.net/haibalai2009/article/details/122650054