public static DecalState Lerp(DecalState a, DecalState b, DecalStateCurves curves, float progress) { return(new DecalState( Mathf.Lerp(a.Saturation, b.Saturation, curves.Saturation.Evaluate(progress)), ChannelValues.Lerp(a.Red, b.Red, curves.Red, progress), ChannelValues.Lerp(a.Green, b.Green, curves.Green, progress), ChannelValues.Lerp(a.Blue, b.Blue, curves.Blue, progress), ChannelValues.Lerp(a.Alpha, b.Alpha, curves.Alpha, progress) )); }
public void Rain(float initialProgress = 0) { _baseState = _rain.DryState; _state = _baseState; _progress = initialProgress; _rateScale = 1; _mode = RainDecalState.Raining; _state.Apply(_decal); _decal.gameObject.SetActive(true); }
public void Dry() { if (_progress > float.Epsilon) { _baseState = _state; _rateScale = 1 / _progress; _progress = 0; } else { _rateScale = 1; _progress = 1; } _mode = RainDecalState.Drying; }
private void updateDecal(Texture2D texture2D, DecalState decalType, Renderer chosenRenderer = null) { decalLayer.OriginalRenderer = chosenRenderer; if (texture2D == null) { currentDecalState = DecalState.NO_DECAL; } else { currentDecalState = decalType; } decalLayer.Decal = texture2D; CustomizationContext.EventBus.DispatchEvent(new CustomizerModelEvents.DecalChangedEvent(decalLayer.Decal, this, decalLayer, chosenRenderer)); if (texture2D != null && currentDecalState == DecalState.CUSTOM_DECAL) { decalLayer.Tint = Color.white; CustomizationContext.EventBus.DispatchEvent(new CustomizerModelEvents.DecalTintChangedEvent(decalLayer.Tint, this, decalLayer)); } }
public bool Update() { if (_decal == null) { return(false); } _progress = Mathf.Clamp01(_progress + _rain.Rate * Time.deltaTime * _rateScale); if (_mode == RainDecalState.Raining) { _state = DecalState.Lerp(_baseState, _rain.WetState, _rain.Raining, _progress); } else { _state = DecalState.Lerp(_baseState, _rain.DryState, _rain.Drying, _progress); } if (_mode == RainDecalState.Retired) { var alpha = (_progress - _retiredAge) / (1 - _retiredAge); if (float.IsNaN(alpha)) { alpha = 1; } _state.Saturation *= _rain.RetireFadeout.Evaluate(alpha); } _state.Apply(_decal); if (IsDead) { _decal.gameObject.SetActive(false); } return(!IsDead); }
public DCustomizationChannel(ChannelMask channelColor) { customizationOptions = new Dictionary <CustomizationOption, bool>(); customizationOptions[CustomizationOption.FABRIC] = false; customizationOptions[CustomizationOption.DECAL] = false; channelName = channelColor.ToString(); channelMask = channelColor; currentFabricState = FabricState.NO_FABRIC; fabricLayer = new DCustomizerLayer(); fabricLayer.Type = DecalType.FABRIC; fabricLayer.Scale = DEFAULT_SCALE; fabricLayer.IsTiled = true; currentDecalState = DecalState.NO_DECAL; decalLayer = new DCustomizerLayer(); decalLayer.Type = DecalType.DECAL; decalLayer.Scale = DEFAULT_SCALE_DECAL; decalLayer.IsTiled = false; DecalRenderer = null; switch (channelMask) { case ChannelMask.RED: fabricLayer.ShaderChannel = DecalColorChannel.RED_1; decalLayer.ShaderChannel = DecalColorChannel.RED_4; break; case ChannelMask.GREEN: fabricLayer.ShaderChannel = DecalColorChannel.GREEN_2; decalLayer.ShaderChannel = DecalColorChannel.GREEN_5; break; case ChannelMask.BLUE: fabricLayer.ShaderChannel = DecalColorChannel.BLUE_3; decalLayer.ShaderChannel = DecalColorChannel.BLUE_6; break; } }