From ea16c7d14f974a9c6fefb7e1a8241392d6017f19 Mon Sep 17 00:00:00 2001 From: liutao <821580467@qq.com> Date: Wed, 10 Jul 2024 19:51:24 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=88=98=E4=BA=89=E9=BB=91=E5=A4=9C?= =?UTF-8?q?=E3=80=91=E5=A2=9E=E5=8A=A0=E9=83=A8=E5=88=86=E9=BB=91=E5=A4=9C?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Framework/Constants/Constants.Path.cs | 2 + .../Code/Scripts/Framework/Event/Events.cs | 2 + .../Code/Scripts/Gameplay/Level/Level.cs | 5 +- .../Gameplay/Level/State/BattleState.cs | 1 + .../Gameplay/Level/State/PrepareState.cs | 7 +- .../PostProcess/BlackArea/BlackAreaManager.cs | 98 ++++++++++++++++++- .../PostProcess/BlackArea/BlackAreaRPF.cs | 5 +- .../PostProcess/BlackArea/LightPoint.cs | 52 +++++++++- .../Gameplay/Unit/Data/UnitFightData.cs | 5 + .../Gameplay/Unit/Data/UnitStatusData.cs | 8 ++ .../Gameplay/Unit/Data/UnitViewData.cs | 39 ++++++++ .../Gameplay/Unit/Data/UnitViewData.cs.meta | 3 + .../Code/Scripts/Gameplay/Unit/GameUnit.cs | 16 +++ .../Scripts/Gameplay/Unit/GameUnitManager.cs | 11 ++- .../Scripts/Gameplay/Weapon/ViewWeapon.cs | 6 ++ .../Code/Shaders/Others/BlackAreaBlit.shader | 6 +- .../Code/Shaders/Others/LightArea.shader | 4 + 17 files changed, 258 insertions(+), 12 deletions(-) create mode 100644 ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/Data/UnitViewData.cs create mode 100644 ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/Data/UnitViewData.cs.meta diff --git a/ProjectNLD/Assets/Code/Scripts/Framework/Constants/Constants.Path.cs b/ProjectNLD/Assets/Code/Scripts/Framework/Constants/Constants.Path.cs index c8efbc8adca..b13de0ae231 100644 --- a/ProjectNLD/Assets/Code/Scripts/Framework/Constants/Constants.Path.cs +++ b/ProjectNLD/Assets/Code/Scripts/Framework/Constants/Constants.Path.cs @@ -60,6 +60,8 @@ namespace Framework public const string STORY_HEAD_CAMERA_PATH = "Assets/Art/Other/head_camera_neck.prefab"; + public const string FIGHT_LIGHT_AREA_PATH = "Assets/Art/Other/light_point.prefab"; + // public const string UI_HEAD_PATH = "Assets/Art/UI/SplitTexture/Icon/HeadPic/Alive/"; // public const string UI_DEAD_HEAD_PATH = "Assets/Art/UI/Texture/Icon/HeadPic/Death/"; diff --git a/ProjectNLD/Assets/Code/Scripts/Framework/Event/Events.cs b/ProjectNLD/Assets/Code/Scripts/Framework/Event/Events.cs index 2f6b2d9c218..2dacb42c356 100644 --- a/ProjectNLD/Assets/Code/Scripts/Framework/Event/Events.cs +++ b/ProjectNLD/Assets/Code/Scripts/Framework/Event/Events.cs @@ -122,6 +122,8 @@ INFIGHT_BLACK_SCREEN_START, // 黑屏开始 INFIGHT_BLACK_SCREEN_END, // 黑屏结束 + + INFIGHT_UNIT_VISIBLE_CHANGE, // 单位可见性改变 //--------- AI ------------ INFIGHT_CHARACTER_AI_CHAIN, //连锁 AI索敌时发送 diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/Level.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/Level.cs index 592a19da8ba..051ede0a110 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/Level.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/Level.cs @@ -299,6 +299,7 @@ namespace Gameplay.Level AssetManager.Instance.Unload(Constants.FLAG_PICK_PATH); AssetManager.Instance.Unload(Constants.FLAG_RETURN_PATH); AssetManager.Instance.Unload(Constants.PROTECT_TARGET_POINT_PATH); + AssetManager.Instance.Unload(Constants.FIGHT_LIGHT_AREA_PATH); _UnloadOutlinePost(); @@ -361,7 +362,8 @@ namespace Gameplay.Level _stateMachine.ChangeState(new PrepareState(this)); SelecterView.Instance.Init(); - BlackAreaManager.instance.Init(false); + // todo: 这里后续修改为从关卡配置读取 + BlackAreaManager.instance.Init(true); } private void _CreateCapturePoints() @@ -427,6 +429,7 @@ namespace Gameplay.Level AssetManager.Instance.PostPreload(Constants.FLAG_PICK_PATH); AssetManager.Instance.PostPreload(Constants.FLAG_RETURN_PATH); AssetManager.Instance.PostPreload(Constants.PROTECT_TARGET_POINT_PATH); + AssetManager.Instance.PostPreload(Constants.FIGHT_LIGHT_AREA_PATH); await AssetManager.Instance.WaitAllPreloads(); } diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/State/BattleState.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/State/BattleState.cs index bd1c55b5312..65914ef6386 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/State/BattleState.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/State/BattleState.cs @@ -77,6 +77,7 @@ namespace Gameplay.Level PauseManager.instance.LogicUpdate(deltaTime); TireMarkManager.instance.LogicUpdate(deltaTime); CaptureManager.instance.LogicUpdate(deltaTime); + BlackAreaManager.instance.LogicUpdate(deltaTime); EventManager.Instance.Send(EventManager.EventName.LevelTimeIncrease,deltaTime); } diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/State/PrepareState.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/State/PrepareState.cs index 985b655cc5a..e11cc9aa1cc 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/State/PrepareState.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/State/PrepareState.cs @@ -5,6 +5,7 @@ using Framework; using Gameplay.Area; using Gameplay.Character; using Gameplay.Guide; +using Gameplay.PostProcess.BlackArea; using Gameplay.Unit; using Gameplay.Unit.Data; using Gameplay.Vehicle; @@ -29,8 +30,12 @@ namespace Gameplay.Level protected override void _OnUpdate(float deltaTime) { + if (BlackAreaManager.instance.enableBlackArea) + { + BlackAreaManager.instance.AutoLightUpReadyArea(); + } } - + protected override void _OnExit() { EventManager.Instance.Unregister(EventManager.EventName.ToFightModelDragEnd, (Action)_OnModelDragEnd); diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/PostProcess/BlackArea/BlackAreaManager.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/PostProcess/BlackArea/BlackAreaManager.cs index 80521a6a452..2d5384c9975 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/PostProcess/BlackArea/BlackAreaManager.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/PostProcess/BlackArea/BlackAreaManager.cs @@ -1,5 +1,13 @@ using System.Collections.Generic; +using Gameplay.Area; +using Gameplay.Character; +using Gameplay.Level; +using Gameplay.Unit; +using Gameplay.Unit.Data; +using Gameplay.Vehicle.Impl; +using PhxhSDK; using UnityEngine; +using Constants = Framework.Constants; namespace Gameplay.PostProcess.BlackArea { public class BlackAreaManager @@ -24,21 +32,109 @@ namespace Gameplay.PostProcess.BlackArea } private List _pointList; + private Dictionary _pointDic; + private GameObject _rootObj; public void Init(bool enable) { enableBlackArea = enable; if (!enableBlackArea) return; _pointList = new List(); + _pointDic = new Dictionary(); + _InitLightMap(); + } + + private void _InitLightMap() + { + _rootObj = new GameObject("[BlackAreaRoot]"); + var allCells = LevelManager.Instance.CurrentLevel.Map.TerrainGridSystem.cells; + var sampleObj = AssetManager.Instance.GetPreLoadResult(Constants.FIGHT_LIGHT_AREA_PATH); + for (int i = 0; i < allCells.Count; i++) + { + var cell = allCells[i]; + var cellIndex = cell.index; + var cellWorldPos = AreaManager.instance.GetCellPosByIndex(cellIndex); + var instObj = Object.Instantiate(sampleObj, cellWorldPos, Quaternion.identity, _rootObj.transform); + + var lightPoint = new LightPoint(cellIndex, instObj); + lightPoint.LightOff(); + _pointList.Add(lightPoint); + _pointDic.Add(cellIndex, lightPoint); + } + } + + public void AutoLightUpReadyArea() + { + var readyArea = AreaManager.instance.readyAreaManager.mapReadyCellIndexs; + for (int i = 0; i < readyArea.Count; i++) + { + LightUpCell(readyArea[i], 0.1f); + } + } + + public void LightUpCell(int cellIndex, float during) + { + if (_pointDic.TryGetValue(cellIndex, out var lightPoint)) + { + lightPoint.MarkLight(during); + } + else + { + DebugUtil.LogError("LightUpCell failed, cellIndex:{0} is invalid!", cellIndex); + } + } + + private void _AutoLightCharacterArea() + { + var allUnits = GameUnitManager.instance.infightUnits.unitList; + for (int i = 0; i < allUnits.Count; i++) + { + var unit = allUnits[i]; + if (!unit.isReady) continue; + if (unit.statusData.isDead) continue; + if (unit.commonData.troopId != ETroopsId.Self) continue; + var lightUpDistance = unit.fightData.lightUpArea; + var cellIndexs = AreaManager.instance.GetCellIndexsAround(unit.transData.cellIndex, lightUpDistance); + for (int j = 0; j < cellIndexs.Count; j++) + { + LightUpCell(cellIndexs[j], 0.1f); + } + } + } + + public bool CheckIsInLightArea(int cellIndex) + { + if (!enableBlackArea) + { + return true; + } + if (_pointDic.TryGetValue(cellIndex, out var lightPoint)) + { + return lightPoint.isLight; + } + return false; } public void LogicUpdate(float dt) { - + if (!enableBlackArea) + { + return; + } + _AutoLightCharacterArea(); + for (int i = 0; i < _pointList.Count; i++) + { + _pointList[i].LogicUpdate(dt); + } } public void Dispose() { + if (_rootObj != null) + { + Object.Destroy(_rootObj); + _rootObj = null; + } enableBlackArea = false; } } diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/PostProcess/BlackArea/BlackAreaRPF.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/PostProcess/BlackArea/BlackAreaRPF.cs index 7cc57000e20..17f498f9761 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/PostProcess/BlackArea/BlackAreaRPF.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/PostProcess/BlackArea/BlackAreaRPF.cs @@ -13,7 +13,6 @@ namespace Gameplay.PostProcess.BlackArea //渲染发生的阶段,具体信息可以在枚举类RenderPassEvent中查看 public RenderPassEvent renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; public LayerMask layerMask; - public Material drawMaterial; public Material blitMaterial; } @@ -71,7 +70,6 @@ namespace Gameplay.PostProcess.BlackArea renderingData.cameraData.camera); renderListDesc.renderQueueRange = RenderQueueRange.all; renderListDesc.layerMask = _settings.layerMask; - renderListDesc.overrideMaterial = _settings.drawMaterial; var renderList = context.CreateRendererList(renderListDesc); cmd.DrawRendererList(renderList); @@ -81,7 +79,7 @@ namespace Gameplay.PostProcess.BlackArea // 把这张图渲染到屏幕上 cmd = CommandBufferPool.Get("BlackArea-DrawMaskToScreen"); var cameraRt = renderingData.cameraData.renderer.cameraColorTargetHandle.nameID; - _blitMaterial.SetTexture("_MaskTex", _cachedTarget); + _blitMaterial.SetTexture(MaskTex, _cachedTarget); cmd.Blit(cameraRt, cameraRt, _blitMaterial); context.ExecuteCommandBuffer(cmd); CommandBufferPool.Release(cmd); @@ -91,6 +89,7 @@ namespace Gameplay.PostProcess.BlackArea public Settings settings; private CustomRenderPass _scriptablePass; private static readonly int MainTex = Shader.PropertyToID("_MainTex"); + private static readonly int MaskTex = Shader.PropertyToID("_MaskTex"); public override void Create() { diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/PostProcess/BlackArea/LightPoint.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/PostProcess/BlackArea/LightPoint.cs index e48ea9cebd2..8b19da5cb4a 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/PostProcess/BlackArea/LightPoint.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/PostProcess/BlackArea/LightPoint.cs @@ -1,9 +1,57 @@ using UnityEngine; + namespace Gameplay.PostProcess.BlackArea { public class LightPoint { - public Vector3 position; - public float lightStrength; + public bool isLight; + public int cellIndex; + public float remainTime; + + private MeshRenderer _meshRenderer; + private readonly GameObject _lightObj; + + public LightPoint(int cellIndex, GameObject lightObj) + { + this.cellIndex = cellIndex; + _lightObj = lightObj; + isLight = false; + remainTime = 0f; + + _meshRenderer = _lightObj.GetComponentInChildren(); + } + + public void LightUp() + { + isLight = true; + _lightObj.SetActive(true); + } + + public void LightOff() + { + isLight = false; + _lightObj.SetActive(false); + } + + public void MarkLight(float duringTime) + { + remainTime = Mathf.Max(duringTime, remainTime); + if (!isLight) + { + LightUp(); + } + } + + public void LogicUpdate(float dt) + { + if (isLight) + { + remainTime -= dt; + if (remainTime < 0) + { + LightOff(); + } + } + } } } diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/Data/UnitFightData.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/Data/UnitFightData.cs index db17e1d3cab..96839789e0b 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/Data/UnitFightData.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/Data/UnitFightData.cs @@ -6,6 +6,11 @@ namespace Gameplay.Unit.Data public GameUnit owner; + /// + /// 照亮区域 + /// + public ObscuredInt lightUpArea = 1; + /// /// 特殊普通逻辑id /// 为0表示没有特殊逻辑 diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/Data/UnitStatusData.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/Data/UnitStatusData.cs index e04716dc224..978e78d148b 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/Data/UnitStatusData.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/Data/UnitStatusData.cs @@ -1,4 +1,5 @@ using Gameplay.Character; +using Gameplay.PostProcess.BlackArea; namespace Gameplay.Unit.Data { public class UnitStatusData @@ -118,6 +119,13 @@ namespace Gameplay.Unit.Data if (isDead) return false; if (isOnVehicle) return false; if (isPretend) return false; + if (owner.commonData.troopId != ETroopsId.Self) + { + if (!BlackAreaManager.instance.CheckIsInLightArea(owner.transData.cellIndex)) + { + return false; + } + } return true; } diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/Data/UnitViewData.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/Data/UnitViewData.cs new file mode 100644 index 00000000000..cfe21909071 --- /dev/null +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/Data/UnitViewData.cs @@ -0,0 +1,39 @@ +using System.Collections.Generic; +using Framework; +using UnityEngine; +namespace Gameplay.Unit.Data +{ + public class UnitViewData + { + + public GameUnit owner; + + private List _renderers; + + public bool isShow; + + public UnitViewData(GameUnit owner) + { + this.owner = owner; + _renderers = new List(); + var renderers = owner.Node.GameObject.GetComponentsInChildren(); + foreach (var renderer in renderers) + { + _renderers.Add(renderer); + } + isShow = true; + } + + public void SetShow(bool setShow) + { + if (isShow == setShow) return; + isShow = setShow; + EventManager.Instance.Send(EventManager.EventName.INFIGHT_UNIT_VISIBLE_CHANGE, owner); + foreach (var renderer in _renderers) + { + renderer.enabled = isShow; + } + } + + } +} diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/Data/UnitViewData.cs.meta b/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/Data/UnitViewData.cs.meta new file mode 100644 index 00000000000..c9c8a8e27b4 --- /dev/null +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/Data/UnitViewData.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 89e18a060e934f368192fcc39eb72e6b +timeCreated: 1720611550 \ No newline at end of file diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/GameUnit.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/GameUnit.cs index 079ebc6dbe7..ba1b912f2f2 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/GameUnit.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/GameUnit.cs @@ -13,6 +13,7 @@ using Gameplay.Common.Attri; using Gameplay.Fight.Flag; using Gameplay.Performance; using Gameplay.Pool; +using Gameplay.PostProcess.BlackArea; using Gameplay.Skill; using Gameplay.Unit.AI; using Gameplay.Unit.Data; @@ -43,6 +44,8 @@ namespace Gameplay.Unit } } + public UnitViewData viewData; + /// /// 公用数据,或者其他一些不知道放哪的数据 /// @@ -150,6 +153,8 @@ namespace Gameplay.Unit /// public void EnterBattle() { + viewData = new UnitViewData(this); + _OnEnterBattle(); EventManager.Instance.Send(EventManager.EventName.INFIGHT_UNIT_READY, this); @@ -202,6 +207,17 @@ namespace Gameplay.Unit { aiManager.LogicUpdate(dt); } + _UpdateBlackArea(); + } + + private void _UpdateBlackArea() + { + if (commonData.troopId == ETroopsId.Self) + { + return; + } + var isInLightArea = BlackAreaManager.instance.CheckIsInLightArea(transData.cellIndex); + viewData.SetShow(isInLightArea); } protected virtual void _OnLogicUpdate(float dt) diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/GameUnitManager.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/GameUnitManager.cs index a37d3ba113d..1c975d7ed28 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/GameUnitManager.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Unit/GameUnitManager.cs @@ -92,6 +92,7 @@ namespace Gameplay.Unit EventManager.Instance.Register(EventManager.EventName.INFIGHT_UNIT_DEAD, (Action)_OnCharacterDead); EventManager.Instance.Register(EventManager.EventName.INFIGHT_UNIT_READY, (Action)_OnUnitEnterBattle); EventManager.Instance.Register(EventManager.EventName.INFIGHT_VEHICLE_DESTROY, (Action)_OnVehicleDestroyed); + EventManager.Instance.Register(EventManager.EventName.INFIGHT_UNIT_VISIBLE_CHANGE, (Action)_OnUnitVisibleChange); } private void _UnRegistEvents() @@ -100,8 +101,14 @@ namespace Gameplay.Unit EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_UP_VEHICLE, (Action)_OnAnyCharacterCellIndexChange); EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_DOWN_VEHICLE, (Action)_OnAnyCharacterCellIndexChange); EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_UNIT_DEAD, (Action)_OnCharacterDead); - EventManager.Instance.Register(EventManager.EventName.INFIGHT_UNIT_READY, (Action)_OnUnitEnterBattle); - EventManager.Instance.Register(EventManager.EventName.INFIGHT_VEHICLE_DESTROY, (Action)_OnVehicleDestroyed); + EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_UNIT_READY, (Action)_OnUnitEnterBattle); + EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_VEHICLE_DESTROY, (Action)_OnVehicleDestroyed); + EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_UNIT_VISIBLE_CHANGE, (Action)_OnUnitVisibleChange); + } + + private void _OnUnitVisibleChange(GameUnit unit) + { + _needUpdateTargets = true; } private void _OnVehicleDestroyed(NormalVehicle unit) diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Weapon/ViewWeapon.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Weapon/ViewWeapon.cs index b10900cef26..19702161953 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Weapon/ViewWeapon.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Weapon/ViewWeapon.cs @@ -2,6 +2,7 @@ using Cysharp.Threading.Tasks; using Gameplay.Performance; using Gameplay.Pool; +using Gameplay.PostProcess.BlackArea; using Gameplay.Unit; using Gameplay.Unit.Data; @@ -77,6 +78,11 @@ namespace Gameplay.Weapon public void OpenFire(GameUnit enemy) { + if (owner.commonData.troopId != ETroopsId.Self) + { + BlackAreaManager.instance.LightUpCell(owner.transData.cellIndex, 1f); + } + var groundEffectId = GLConfig.Inst.data.GroundFireEffectId; if (groundEffectId > 0) { diff --git a/ProjectNLD/Assets/Code/Shaders/Others/BlackAreaBlit.shader b/ProjectNLD/Assets/Code/Shaders/Others/BlackAreaBlit.shader index e677849d094..57f79a217a9 100644 --- a/ProjectNLD/Assets/Code/Shaders/Others/BlackAreaBlit.shader +++ b/ProjectNLD/Assets/Code/Shaders/Others/BlackAreaBlit.shader @@ -53,13 +53,15 @@ Shader "Unlit/BlackAreaBlit" fixed4 col = tex2D(_MainTex, i.uv); fixed4 mask = tex2D(_MaskTex, i.uv); fixed4 black = fixed4(0, 0, 0, 1); - if (mask.r > 0.01) + float minAlpha = 0.02; + if (mask.r > minAlpha) { float scale = mask.r * 1; scale = min(scale, 1); + scale = max(scale, minAlpha); return col * scale; } - return col * 0.01; + return col * minAlpha; } ENDCG } diff --git a/ProjectNLD/Assets/Code/Shaders/Others/LightArea.shader b/ProjectNLD/Assets/Code/Shaders/Others/LightArea.shader index 3737f392212..def8cd1c4ae 100644 --- a/ProjectNLD/Assets/Code/Shaders/Others/LightArea.shader +++ b/ProjectNLD/Assets/Code/Shaders/Others/LightArea.shader @@ -3,6 +3,7 @@ Shader "Unlit/LightArea" Properties { _MainTex ("Texture", 2D) = "white" {} + _Alpha ("Alpha", Range(0, 1)) = 1 } SubShader { @@ -55,6 +56,8 @@ Shader "Unlit/LightArea" sampler2D _MainTex; float4 _MainTex_ST; + float _Alpha; + v2f vert (appdata v) { v2f o; @@ -69,6 +72,7 @@ Shader "Unlit/LightArea" { // sample the texture fixed4 col = tex2D(_MainTex, i.uv); + col *= _Alpha; return col; } ENDCG