Cesium 自定义Material 系列 (十三)

  • 对于水泥纹理效果 我们先定义一下他的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;
posted @   haibalai  阅读(116)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示