我想在我的自定义流动线材质的基础上让这个材质有外发光的效果。是否可以通过编写修改其中的着色器语言来实现?
/**
* @Author: dongnan
* @Description: 流动线 连续循环 首尾相连
* @param color 线段颜色
* @param speed 频率
* @param image 流动线贴图 (不同的贴图效果不同)
* @Date: 2021-08-08 19:30:07
*/
class PolylineTrailMaterialProperty {
constructor(options) {
options = Cesium.defaultValue(options, Cesium.defaultValue.EMPTY_OBJECT);
this._definitionChanged = new Cesium.Event();
this._color = undefined;
this._colorSubscription = undefined;
this.color = options.color;
this.speed = options.speed;
this.image = options.image;
}
}
Object.defineProperties(PolylineTrailMaterialProperty.prototype, {
isConstant: {
get: function () {
return false;
},
},
definitionChanged: {
get: function () {
return this._definitionChanged;
},
},
color: Cesium.createPropertyDescriptor("color"),
});
PolylineTrailMaterialProperty.prototype.getType = function () {
return "PolylineTrail";
};
PolylineTrailMaterialProperty.prototype.getValue = function (time, result) {
if (!Cesium.defined(result)) {
result = {};
}
result.color = Cesium.Property.getValueOrClonedDefault(
this._color,
time,
Cesium.Color.WHITE,
result.color
);
result.speed = this.speed;
result.image = this.image;
return result;
};
PolylineTrailMaterialProperty.prototype.equals = function (other) {
return (
this === other ||
(other instanceof PolylineTrailMaterialProperty &&
Cesium.Property.equals(this._color, other._color))
);
};
//添加材质
Cesium.Material.PolylineTrailType = "PolylineTrail";
Cesium.Material.PolylineTrailSource =
`uniform float speed;` +
`czm_material czm_getMaterial(czm_materialInput materialInput){` +
`czm_material material = czm_getDefaultMaterial(materialInput);` +
`float t = clamp(fract(czm_frameNumber * speed / 1000.0),0.0,1.0);` +
"vec4 fragColor;" +
`fragColor.rgb = color.rgb / 1.0;` +
`fragColor = czm_gammaCorrect(fragColor);` +
`vec2 st = materialInput.st;` +
`vec4 colorImage = texture2D(image, vec2(fract(1.0 - st.s + t), st.t));` +
`material.alpha = color