Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
noridev committed Dec 11, 2024
2 parents bfa174c + 5d6d0ef commit c8675a2
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 21 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG_NRDV.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-->

## [1.1.3] - 2024-12-11
기반 LightLimitChanger 버전: <b>1.14.3</b>

### Changed
- 기반 LightLimitChanger 버전 업데이트 (<small>1.14.2</small> -> **1.14.3**)

---

## [1.1.2] - 2024-09-30
기반 LightLimitChanger 버전: <b>1.14.2</b>

Expand Down
5 changes: 4 additions & 1 deletion Editor/ControlAnimationParameters.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using UnityEngine;

namespace moe.noridev
{
Expand All @@ -14,8 +15,9 @@ public readonly struct ControlAnimationParameters
public readonly float DefaultMonochromeLightingValue;
public readonly float DefaultMonochromeAdditiveLightingValue;
public readonly float DefaultShadowEnvStrengthValue;
public readonly Material[] Materials;

public ControlAnimationParameters(string targetPath, Type targetType, float minLightValue, float maxLightValue, float defaultMinLightValue, float defaultMaxLightValue, float defaultMonochromeLightingValue, float defaultMonochromeAdditiveLightingValue, float defaultShadowEnvStrengthValue)
public ControlAnimationParameters(string targetPath, Type targetType, float minLightValue, float maxLightValue, float defaultMinLightValue, float defaultMaxLightValue, float defaultMonochromeLightingValue, float defaultMonochromeAdditiveLightingValue, float defaultShadowEnvStrengthValue, Material[] materials)
{
TargetPath = targetPath;
TargetType = targetType;
Expand All @@ -26,6 +28,7 @@ public ControlAnimationParameters(string targetPath, Type targetType, float minL
DefaultMonochromeLightingValue = defaultMonochromeLightingValue;
DefaultMonochromeAdditiveLightingValue = defaultMonochromeAdditiveLightingValue;
DefaultShadowEnvStrengthValue = defaultShadowEnvStrengthValue;
Materials = materials;
}
}
}
6 changes: 5 additions & 1 deletion Editor/NDMF/Passes.GenerateAnimationsPass.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using gomoru.su;
using nadena.dev.modular_avatar.core;
using nadena.dev.ndmf;
Expand Down Expand Up @@ -29,6 +30,9 @@ internal static void Run(Session session, LightLimitChangerObjectCache cache)

var relativePath = renderer.AvatarRootPath();
var type = renderer.GetType();
var materials = renderer.sharedMaterials;
if (materials == null)
materials = Array.Empty<Material>();

foreach (var x in ShaderInfo.RegisteredShaderInfos)
{
Expand Down Expand Up @@ -69,7 +73,7 @@ renderer.sharedMaterial is Material mat &&
}
}

var param = new ControlAnimationParameters(relativePath, type, min, max, defaultMinLight, defaultMaxLight, defaultMonochromeLighting, defaultMonochromeAdditiveLighting, defaultShadowEnvStrength);
var param = new ControlAnimationParameters(relativePath, type, min, max, defaultMinLight, defaultMaxLight, defaultMonochromeLighting, defaultMonochromeAdditiveLighting, defaultShadowEnvStrength, materials);
foreach (ref readonly var container in animationContainers)
{
x.SetControlAnimation(container, param, parameters);
Expand Down
50 changes: 33 additions & 17 deletions Editor/ShaderInfo/ShaderInfo.LilToon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,14 @@ public override bool TryNormalizeMaterial(Material material, LightLimitChangerOb

// MainTexture
bool bakeProcessed = false;
var skipOptions = material.GetTag("LLC_TEXTUREBAKE_SKIP_OPTIONS", false, "").Split(';');

bakeProcessed |= BakeMainTex(material, cache, textureBaker);
bakeProcessed |= Bake2ndOr3rdTex(material, cache, textureBaker, (PropertyIDs.Main2ndTex, PropertyIDs.Color2nd), DefaultParameters.Color2nd);
bakeProcessed |= Bake2ndOr3rdTex(material, cache, textureBaker, (PropertyIDs.Main3rdTex, PropertyIDs.Color3rd), DefaultParameters.Color3rd);
if (!skipOptions.Contains("lilMainTex", StringComparer.OrdinalIgnoreCase))
bakeProcessed |= BakeMainTex(material, cache, textureBaker);
if (!skipOptions.Contains("lil2ndTex", StringComparer.OrdinalIgnoreCase))
bakeProcessed |= Bake2ndOr3rdTex(material, cache, textureBaker, (PropertyIDs.Main2ndTex, PropertyIDs.Color2nd), DefaultParameters.Color2nd);
if (!skipOptions.Contains("lil3rdTex", StringComparer.OrdinalIgnoreCase))
bakeProcessed |= Bake2ndOr3rdTex(material, cache, textureBaker, (PropertyIDs.Main3rdTex, PropertyIDs.Color3rd), DefaultParameters.Color3rd);

return bakeProcessed;
}
Expand Down Expand Up @@ -181,19 +185,21 @@ public override bool IsTargetShader(Shader shader)

public override void SetControlAnimation(in ControlAnimationContainer container, in ControlAnimationParameters parameters, in LightLimitChangerParameters llc_parameters)
{
if (container.ControlType.HasFlag(LightLimitControlType.LightMin))
var skipOptions = parameters.Materials.Where(x => x != null).Select(x => x.GetTag("LLC_ANIMATION_SKIP_OPTIONS", false, null)).Where(x => !string.IsNullOrEmpty(x)).SelectMany(x => x.Split(';')).ToArray();

if (container.ControlType.HasFlag(LightLimitControlType.LightMin) && !skipOptions.Contains("lilLightMin", StringComparer.OrdinalIgnoreCase))
{
container.Default.SetParameterAnimation(parameters, _LightMinLimit, parameters.DefaultMinLightValue);
container.Control.SetParameterAnimation(parameters, _LightMinLimit, parameters.MinLightValue, parameters.MaxLightValue);
}

if (container.ControlType.HasFlag(LightLimitControlType.LightMax))
if (container.ControlType.HasFlag(LightLimitControlType.LightMax) && !skipOptions.Contains("lilLightMax", StringComparer.OrdinalIgnoreCase))
{
container.Default.SetParameterAnimation(parameters, _LightMaxLimit, parameters.DefaultMaxLightValue);
container.Control.SetParameterAnimation(parameters, _LightMaxLimit, parameters.MinLightValue, parameters.MaxLightValue);
}

if (container.ControlType.HasFlag(LightLimitControlType.Saturation))
if (container.ControlType.HasFlag(LightLimitControlType.Saturation) && !skipOptions.Contains("lilSaturation", StringComparer.OrdinalIgnoreCase))
{
container.Default.SetParameterAnimation(parameters, _MainTexHSVG, DefaultParameters.MainTexHSVG);

Expand All @@ -202,19 +208,19 @@ public override void SetControlAnimation(in ControlAnimationContainer container,
container.Control.SetParameterAnimation(parameters, $"{_MainTexHSVG}.z", 1, 1);
container.Control.SetParameterAnimation(parameters, $"{_MainTexHSVG}.w", 1, 1);
}
if (container.ControlType.HasFlag(LightLimitControlType.Monochrome))
if (container.ControlType.HasFlag(LightLimitControlType.Monochrome) && !skipOptions.Contains("lilMonochrome", StringComparer.OrdinalIgnoreCase))
{
container.Default.SetParameterAnimation(parameters, _MonochromeLighting, parameters.DefaultMonochromeLightingValue);
container.Control.SetParameterAnimation(parameters, _MonochromeLighting, 0, 1);
}

if (container.ControlType.HasFlag(LightLimitControlType.Unlit))
if (container.ControlType.HasFlag(LightLimitControlType.Unlit) && !skipOptions.Contains("lilUnlit", StringComparer.OrdinalIgnoreCase))
{
container.Default.SetParameterAnimation(parameters, _AsUnlit, 0);
container.Control.SetParameterAnimation(parameters, _AsUnlit, 0, 1);
}

if (container.ControlType.HasFlag(LightLimitControlType.Emission))
if (container.ControlType.HasFlag(LightLimitControlType.Emission) && !skipOptions.Contains("lilEmission", StringComparer.OrdinalIgnoreCase))
{
container.Default.SetParameterAnimation(parameters, _EmissionBlend, 1);
container.Default.SetParameterAnimation(parameters, _Emission2ndBlend, 1);
Expand All @@ -223,15 +229,25 @@ public override void SetControlAnimation(in ControlAnimationContainer container,
container.Control.SetParameterAnimation(parameters, _Emission2ndBlend, 0, 1);
}

if (container.ControlType.HasFlag(LightLimitControlType.ColorTemperature))
if (container.ControlType.HasFlag(LightLimitControlType.ColorTemperature) && !skipOptions.Contains("lilColorTemp", StringComparer.OrdinalIgnoreCase))
{
container.Default.SetParameterAnimation(parameters, _Color, DefaultParameters.Color);
container.Default.SetParameterAnimation(parameters, _Color2nd, DefaultParameters.Color2nd);
container.Default.SetParameterAnimation(parameters, _Color3rd, DefaultParameters.Color3rd);

container.Control.SetColorTempertureAnimation(parameters, _Color);
container.Control.SetColorTempertureAnimation(parameters, _Color2nd);
container.Control.SetColorTempertureAnimation(parameters, _Color3rd);
if (!skipOptions.Contains("lilColorTempMainTex", StringComparer.OrdinalIgnoreCase))
{
container.Default.SetParameterAnimation(parameters, _Color, DefaultParameters.Color);
container.Control.SetColorTempertureAnimation(parameters, _Color);
}

if (!skipOptions.Contains("lilColorTemp2ndTex", StringComparer.OrdinalIgnoreCase))
{
container.Default.SetParameterAnimation(parameters, _Color2nd, DefaultParameters.Color2nd);
container.Control.SetColorTempertureAnimation(parameters, _Color2nd);
}

if (!skipOptions.Contains("lilColorTemp3rdTex", StringComparer.OrdinalIgnoreCase))
{
container.Default.SetParameterAnimation(parameters, _Color3rd, DefaultParameters.Color3rd);
container.Control.SetColorTempertureAnimation(parameters, _Color3rd);
}
}

if (container.ControlType.HasFlag(LightLimitControlType.ShadowEnvStrength))
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "moe.noridev.light-limit-changer",
"version": "1.1.2",
"baseVersion": "1.14.2",
"version": "1.1.3",
"baseVersion": "1.14.3",
"unity": "2019.4",
"displayName": "NoriDev - LightLimitChanger",
"description": "Light Limit ChangerはModular-Avatar前提のVRChatアバター向けの明るさ変更ジェネレーターです。―――――――――――――――――― Light Limit Changer is a brightness change generator for VRChat avatars based on Modular-Avatar. ―――――――――――――――――― by Azukimochi25. Edit by NoriDev.",
Expand Down

0 comments on commit c8675a2

Please sign in to comment.