액체 쉐이더 테스트 중4
This commit is contained in:
parent
2330d6407b
commit
8bf142b2e5
@ -41,6 +41,9 @@ namespace BlueWater
|
|||||||
[SerializeField, Range(0f, 100f)]
|
[SerializeField, Range(0f, 100f)]
|
||||||
private float _currentLiquidAmount;
|
private float _currentLiquidAmount;
|
||||||
|
|
||||||
|
[SerializeField, Range(0f, 1f)]
|
||||||
|
private float _colorLerpSpeed = 0.5f;
|
||||||
|
|
||||||
private IObjectPool<Liquid> _objectPool;
|
private IObjectPool<Liquid> _objectPool;
|
||||||
private List<Liquid> _activeLiquids = new();
|
private List<Liquid> _activeLiquids = new();
|
||||||
private Dictionary<Color, float> _colorTimes = new();
|
private Dictionary<Color, float> _colorTimes = new();
|
||||||
@ -48,8 +51,11 @@ namespace BlueWater
|
|||||||
private Material _instanceMaterial;
|
private Material _instanceMaterial;
|
||||||
private bool _isPouring;
|
private bool _isPouring;
|
||||||
private float _startTime = float.PositiveInfinity;
|
private float _startTime = float.PositiveInfinity;
|
||||||
|
private float _endTime = float.PositiveInfinity;
|
||||||
private float _timeInterval;
|
private float _timeInterval;
|
||||||
private float _liquidPerObject;
|
private float _liquidPerObject;
|
||||||
|
private Color _currentMixedColor = Color.black;
|
||||||
|
private Color _targetColor;
|
||||||
|
|
||||||
// Hashes
|
// Hashes
|
||||||
private static readonly int _liquidAmountHash = Shader.PropertyToID("_LiquidAmount");
|
private static readonly int _liquidAmountHash = Shader.PropertyToID("_LiquidAmount");
|
||||||
@ -96,6 +102,18 @@ namespace BlueWater
|
|||||||
_startTime = Time.time;
|
_startTime = Time.time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_endTime + _colorLerpSpeed >= Time.time)
|
||||||
|
{
|
||||||
|
_currentMixedColor = Color.Lerp(_currentMixedColor, _targetColor, _colorLerpSpeed * Time.deltaTime);
|
||||||
|
_instanceMaterial.SetColor(_liquidColorHash, _currentMixedColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
_currentMixedColor = _liquidColor;
|
||||||
|
_instanceMaterial.SetColor(_liquidColorHash, _currentMixedColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Liquid CreateObject()
|
private Liquid CreateObject()
|
||||||
@ -103,6 +121,10 @@ namespace BlueWater
|
|||||||
var instance = Instantiate(_liquidObject, _spawnTransform.position, Quaternion.identity, _spawnLocation);
|
var instance = Instantiate(_liquidObject, _spawnTransform.position, Quaternion.identity, _spawnLocation);
|
||||||
instance.SetManagedPool(_objectPool);
|
instance.SetManagedPool(_objectPool);
|
||||||
instance.Initialize(this, _reachedCollider, _liquidColor);
|
instance.Initialize(this, _reachedCollider, _liquidColor);
|
||||||
|
if (_renderTexture && _renderTexture.material.GetColor("_Color") != _liquidColor)
|
||||||
|
{
|
||||||
|
_renderTexture.material.SetColor("_Color", _liquidColor);
|
||||||
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,12 +204,14 @@ namespace BlueWater
|
|||||||
|
|
||||||
public void OnLiquidReached()
|
public void OnLiquidReached()
|
||||||
{
|
{
|
||||||
|
_endTime = Time.time;
|
||||||
// 컵에 채워진 액체의 양을 증가시킴
|
// 컵에 채워진 액체의 양을 증가시킴
|
||||||
_currentLiquidAmount += _liquidPerObject;
|
_currentLiquidAmount += _liquidPerObject;
|
||||||
_currentLiquidAmount = Mathf.Clamp(_currentLiquidAmount, 0f, 100f);
|
_currentLiquidAmount = Mathf.Clamp(_currentLiquidAmount, 0f, 100f);
|
||||||
var liquidAmount = _currentLiquidAmount * 0.01f;
|
var liquidAmount = _currentLiquidAmount * 0.01f;
|
||||||
_instanceMaterial.SetFloat(_liquidAmountHash, liquidAmount);
|
_instanceMaterial.SetFloat(_liquidAmountHash, liquidAmount);
|
||||||
_instanceMaterial.SetColor(_liquidColorHash, MixColorsByTime());
|
_targetColor = MixColorsByTime();
|
||||||
|
//_instanceMaterial.SetColor(_liquidColorHash, MixColorsByTime());
|
||||||
|
|
||||||
// 액체가 100%에 도달하면 pouring을 멈춤
|
// 액체가 100%에 도달하면 pouring을 멈춤
|
||||||
if (_currentLiquidAmount >= 100f)
|
if (_currentLiquidAmount >= 100f)
|
||||||
|
@ -21,6 +21,8 @@ namespace BlueWater.Tycoons
|
|||||||
{
|
{
|
||||||
PlayerInputKeyManager.Instance.SwitchCurrentActionMap(InputActionMaps.Bar);
|
PlayerInputKeyManager.Instance.SwitchCurrentActionMap(InputActionMaps.Bar);
|
||||||
TycoonCameraManager.Instance.SetMainCamera(TycoonCameraType.Bar);
|
TycoonCameraManager.Instance.SetMainCamera(TycoonCameraType.Bar);
|
||||||
|
_liquidController.Initialize();
|
||||||
|
_liquidController2.Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Escape()
|
public void Escape()
|
||||||
|
@ -118,6 +118,10 @@ Material:
|
|||||||
- _GlossMapScale: 0
|
- _GlossMapScale: 0
|
||||||
- _Glossiness: 0
|
- _Glossiness: 0
|
||||||
- _GlossyReflections: 0
|
- _GlossyReflections: 0
|
||||||
|
- _LiquidAmount: 0.662
|
||||||
|
- _LiquidFrequency: 18
|
||||||
|
- _LiquidSpeed: 3
|
||||||
|
- _LiquidTopWidth: 5
|
||||||
- _Metallic: 0
|
- _Metallic: 0
|
||||||
- _OcclusionStrength: 1
|
- _OcclusionStrength: 1
|
||||||
- _Parallax: 0.005
|
- _Parallax: 0.005
|
||||||
@ -148,6 +152,8 @@ Material:
|
|||||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
- _FillAmount: {r: 0, g: 0, b: 0, a: 0}
|
- _FillAmount: {r: 0, g: 0, b: 0, a: 0}
|
||||||
- _FormColor: {r: 0.4078431, g: 1.317647, b: 1.4980392, a: 0}
|
- _FormColor: {r: 0.4078431, g: 1.317647, b: 1.4980392, a: 0}
|
||||||
|
- _LiquidColor: {r: 0, g: 0.3513453, b: 1, a: 0}
|
||||||
|
- _LiquidTopColor: {r: 1, g: 1, b: 1, a: 0}
|
||||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||||
- _WaterColor: {r: 0, g: 1.5319147, b: 2, a: 0}
|
- _WaterColor: {r: 0, g: 1.5319147, b: 2, a: 0}
|
||||||
- _WaterTopColor: {r: 1, g: 1, b: 1, a: 0}
|
- _WaterTopColor: {r: 1, g: 1, b: 1, a: 0}
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user