加入迷雾控制
This commit is contained in:
@@ -38,6 +38,7 @@ export default class LocalDiffusionCtrl extends cc.Component {
|
||||
this._localDiffusionUniform.centerColor = localDiffusionUniform.centerColor;
|
||||
this._localDiffusionUniform.radius = localDiffusionUniform.radius;
|
||||
this._localDiffusionUniform.cropAlpha = localDiffusionUniform.cropAlpha;
|
||||
this._localDiffusionUniform.enableFog = localDiffusionUniform.enableFog;
|
||||
this._updateMaterial();
|
||||
}
|
||||
|
||||
@@ -48,6 +49,7 @@ export default class LocalDiffusionCtrl extends cc.Component {
|
||||
material.setProperty("centerPoint", this._localDiffusionUniform.certerPoint);
|
||||
material.setProperty("radius", this._localDiffusionUniform.radius);
|
||||
material.setProperty("cropAlpha", this._localDiffusionUniform.cropAlpha);
|
||||
material.setProperty("enableFog", this._localDiffusionUniform.enableFog);
|
||||
renderComponent.setMaterial(0, material);
|
||||
});
|
||||
}
|
||||
@@ -73,4 +75,9 @@ export class LocalDiffusionUniform {
|
||||
* 是否裁剪掉透明区域上的点光
|
||||
*/
|
||||
cropAlpha: boolean = true;
|
||||
|
||||
/**
|
||||
* 是否开启战争迷雾效果
|
||||
*/
|
||||
enableFog: boolean = false;
|
||||
}
|
||||
|
@@ -6,20 +6,17 @@ const { ccclass, property } = cc._decorator;
|
||||
export default class LocalDiffusionEffectScene extends cc.Component {
|
||||
private _redSlider: cc.Slider = null;
|
||||
private _redSliderLabel: cc.Label = null;
|
||||
|
||||
private _greenSlider: cc.Slider = null;
|
||||
private _greenSliderLabel: cc.Label = null;
|
||||
|
||||
private _blueSlider: cc.Slider = null;
|
||||
private _blueSliderLabel: cc.Label = null;
|
||||
|
||||
private _alphaSlider: cc.Slider = null;
|
||||
private _alphaSliderLabel: cc.Label = null;
|
||||
|
||||
private _radiuSlider: cc.Slider = null;
|
||||
private _radiuSliderLabel: cc.Label = null;
|
||||
|
||||
private _cropAlphaToggle: cc.Toggle = null;
|
||||
private _enableFogToggle: cc.Toggle = null;
|
||||
|
||||
private _examplesParentNode: cc.Node = null;
|
||||
|
||||
@@ -28,20 +25,17 @@ export default class LocalDiffusionEffectScene extends cc.Component {
|
||||
|
||||
this._redSlider = cc.find("Canvas/Content/Controller/ColorRedSlider/Slider").getComponent(cc.Slider);
|
||||
this._redSliderLabel = cc.find("Canvas/Content/Controller/ColorRedSlider/ValueLabel").getComponent(cc.Label);
|
||||
|
||||
this._greenSlider = cc.find("Canvas/Content/Controller/ColorGreenSlider/Slider").getComponent(cc.Slider);
|
||||
this._greenSliderLabel = cc.find("Canvas/Content/Controller/ColorGreenSlider/ValueLabel").getComponent(cc.Label);
|
||||
|
||||
this._blueSlider = cc.find("Canvas/Content/Controller/ColorBlueSlider/Slider").getComponent(cc.Slider);
|
||||
this._blueSliderLabel = cc.find("Canvas/Content/Controller/ColorBlueSlider/ValueLabel").getComponent(cc.Label);
|
||||
|
||||
this._alphaSlider = cc.find("Canvas/Content/Controller/ColorAlphaSlider/Slider").getComponent(cc.Slider);
|
||||
this._alphaSliderLabel = cc.find("Canvas/Content/Controller/ColorAlphaSlider/ValueLabel").getComponent(cc.Label);
|
||||
|
||||
this._radiuSlider = cc.find("Canvas/Content/Controller/RadiuSlider/Slider").getComponent(cc.Slider);
|
||||
this._radiuSliderLabel = cc.find("Canvas/Content/Controller/RadiuSlider/ValueLabel").getComponent(cc.Label);
|
||||
|
||||
this._cropAlphaToggle = cc.find("Canvas/Content/Controller/CropAlphaToggle/Toggle").getComponent(cc.Toggle);
|
||||
this._enableFogToggle = cc.find("Canvas/Content/Controller/EnableFogToggle/Toggle").getComponent(cc.Toggle);
|
||||
|
||||
// 代码添加控制脚本
|
||||
this._examplesParentNode = cc.find("Canvas/Content/Examples");
|
||||
@@ -57,6 +51,7 @@ export default class LocalDiffusionEffectScene extends cc.Component {
|
||||
this._alphaSlider.node.on("slide", this._onPropertyChanged, this);
|
||||
this._radiuSlider.node.on("slide", this._onPropertyChanged, this);
|
||||
this._cropAlphaToggle.node.on("toggle", this._onPropertyChanged, this);
|
||||
this._enableFogToggle.node.on("toggle", this._onPropertyChanged, this);
|
||||
}
|
||||
|
||||
onDisable() {
|
||||
@@ -66,6 +61,7 @@ export default class LocalDiffusionEffectScene extends cc.Component {
|
||||
this._alphaSlider.node.off("slide", this._onPropertyChanged, this);
|
||||
this._radiuSlider.node.off("slide", this._onPropertyChanged, this);
|
||||
this._cropAlphaToggle.node.off("toggle", this._onPropertyChanged, this);
|
||||
this._enableFogToggle.node.off("toggle", this._onPropertyChanged, this);
|
||||
}
|
||||
|
||||
start() {
|
||||
@@ -90,7 +86,8 @@ export default class LocalDiffusionEffectScene extends cc.Component {
|
||||
Math.round(255 * this._alphaSlider.progress)
|
||||
),
|
||||
radius: this._radiuSlider.progress,
|
||||
cropAlpha: this._cropAlphaToggle.isChecked
|
||||
cropAlpha: this._cropAlphaToggle.isChecked,
|
||||
enableFog: this._enableFogToggle.isChecked
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user