Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
36 changes: 36 additions & 0 deletions Assets/Live2D/Cubism/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,41 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).


## [5-r.5-beta.3] - 2026-01-08

### Added

* Add scripts and assets for using the `Universal Render Pipeline` and custom render passes to `Assets/Live2D/Cubism/Rendering/URP`.
* Add a feature to allow rendering of arbitrary objects before and after the rendering of model draw objects.
* Add `CubismLookCenterTransform` and `CubismLookCenterArtMesh` to allow setting the look-at center using either a Transform or an ArtMesh.

### Changed

* Change to work based on the `Universal Render Pipeline`.
* `Built-in Render Pipeline` and `High Definition Render Pipeline` are not supported.
* `Cubism 5 SDK for Unity R4_1` and its derivative packages will be maintained as `Built-in Render Pipeline` compatible versions.
* Models and features from `Cubism 5.3` and later cannot be used.
* The use of custom render passes is required.

### Fixed

* Fix an issue where `ReleaseStaleRenderTextures()` could release `RenderTexture` in use depending on the timing of its invocation.
* Fix an issue where the texture settings were not as intended when imported.
* Fix an issue where look-at tracking was misaligned when using `CubismLookController`.
* Fix an issue where the Koharu model's .model3.json was missing references to .motion3.json.
* Fix Koharu's corrupted .motion3.json files.
* Fix an issue where Raycast was functional even when `CubismRaycastable` was inactive.

### Removed

* Remove unused shaders and materials.
* Remove `Assets/Live2D/Cubism/Rendering/CubismCommonRenderFrameBuffer.cs` and `Assets/Live2D/Cubism/Rendering/ArrayExtensionMethods.cs`.
* Remove `Assets/Live2D/Cubism/Rendering/Resources/Live2D/Cubism/Prefabs/ModelCanvas.prefab`.
* Remove scripts and related processes under `Assets/Live2D/Cubism/Rendering/Masking` and `Assets/Live2D/Cubism/Samples/Masking`.
* Remove `Assets/Live2D/Cubism/Editor/Inspectors/CubismMaskControllerInspector.cs`, `Assets/Live2D/Cubism/Editor/Inspectors/CubismMaskTextureInspector.cs`, and `Assets/Live2D/Cubism/Rendering/Resources/Live2D/Cubism/GlobalMaskTexture.asset` accordingly.
* Mask processing has been integrated into `CubismRenderer`.


## [5-r.5-beta.2] - 2025-10-14

### Changed
Expand Down Expand Up @@ -517,6 +552,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* Fix issue where Priority value was not reset after playing motion with CubismMotionController.


[5-r.5-beta.3]: https://github.com/Live2D/CubismUnityComponents/compare/5-r.5-beta.2...5-r.5-beta.3
[5-r.5-beta.2]: https://github.com/Live2D/CubismUnityComponents/compare/5-r.5-beta.1...5-r.5-beta.2
[5-r.5-beta.1]: https://github.com/Live2D/CubismUnityComponents/compare/5-r.4.1...5-r.5-beta.1
[5-r.4.1]: https://github.com/Live2D/CubismUnityComponents/compare/5-r.4...5-r.4.1
Expand Down
58 changes: 1 addition & 57 deletions Assets/Live2D/Cubism/Core/CubismModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Live2D.Cubism.Framework;
using System;
using UnityEngine;
using Live2D.Cubism.Rendering.Util;


#if UNITY_2019_3_OR_NEWER
Expand Down Expand Up @@ -309,44 +308,10 @@ private bool CanRevive
/// </summary>
private int LastTick { get; set; }

/// <summary>
/// Is the model's MOC version higher than Cubism 5.0?
/// </summary>
public bool IsOverMocVersion50
{
get
{
return CubismCoreDll.MocVersion_50 < Moc.Version;
}
}

/// <summary>
/// Is this model using blend mode.
/// </summary>
[SerializeField, HideInInspector]
private bool _isUsingBlendMode;


/// <summary>
/// Get Flag is this model using blend mode.
/// </summary>
/// <returns>True if Is this model using blend mode; otherwise returns false.</returns>
public bool IsUsingBlendMode
{
get
{
return _isUsingBlendMode;
}
private set
{
_isUsingBlendMode = value;
}
}

/// <summary>
/// Revives instance.
/// </summary>
private void Revive()
internal void Revive()
{
// Return if already revive.
if (IsRevived)
Expand Down Expand Up @@ -423,7 +388,6 @@ private void Reset(CubismMoc moc)

if (0 < CubismCoreDll.GetOffscreenCount(TaskableModel.UnmanagedModel.Ptr))
{
IsUsingBlendMode = true;
Offscreens = GetComponentsInChildren<CubismOffscreen>();
if (Offscreens.Length < 1 && (transform.Find("Offscreens") == null))
{
Expand All @@ -438,26 +402,6 @@ private void Reset(CubismMoc moc)
}
}

if (IsOverMocVersion50 && !IsUsingBlendMode)
{
var drawableCount = Drawables.Length;
for (var i = 0; i < drawableCount; ++i)
{
var colorBlendType = Drawables[i].ColorBlend;
var alphaBlendType = Drawables[i].AlphaBlend;
if (colorBlendType == BlendTypes.ColorBlend.Normal &&
alphaBlendType == BlendTypes.AlphaBlend.Over ||
colorBlendType == BlendTypes.ColorBlend.Add ||
colorBlendType == BlendTypes.ColorBlend.Multiply)
{
continue;
}

IsUsingBlendMode = true;
break;
}
}

CanvasInformation = new CubismCanvasInformation(TaskableModel.UnmanagedModel);

RefreshParameterStore();
Expand Down
108 changes: 90 additions & 18 deletions Assets/Live2D/Cubism/Core/CubismPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,71 @@ public int OffscreenIndex
}
}

/// <summary>
/// <see cref="AllChildOffscreens"/>'s backing field.
/// </summary>
private CubismOffscreen[] _allChildOffscreens = null;

/// <summary>
/// All child drawables of this part, including children of children.
/// </summary>
public CubismOffscreen[] AllChildOffscreens
{
get
{
if (_allChildOffscreens == null)
{
var model = this.FindCubismModel(true);
if (!model)
{
return null;
}

if (model.Offscreens == null)
{
return null;
}

var parts = model.Parts;

var childrenParts = Array.Empty<CubismPart>();

for (var index = 0; index < parts.Length; index++)
{
if (parts[index].UnmanagedParentIndex == UnmanagedIndex)
{
Array.Resize(ref childrenParts, childrenParts.Length + 1);
childrenParts[^1] = parts[index];
}
}

// Initialize the array of all children drawables.
_allChildOffscreens = Array.Empty<CubismOffscreen>();

// Add the drawables of this part.
Array.Resize(ref _allChildOffscreens, ChildOffscreens.Length);
Array.Copy(ChildOffscreens, _allChildOffscreens, ChildOffscreens.Length);

// Collect all children drawables from child parts.
for (var index = 0; index < childrenParts.Length; index++)
{
Array.Resize(ref _allChildOffscreens, _allChildOffscreens.Length + childrenParts[index].AllChildOffscreens.Length);
Array.Copy(childrenParts[index].AllChildOffscreens,
0,
_allChildOffscreens,
_allChildOffscreens.Length - childrenParts[index].AllChildOffscreens.Length,
childrenParts[index].AllChildOffscreens.Length);
}
}

return _allChildOffscreens;
}
}

/// <summary>
/// <see cref="AllChildDrawables"/>'s backing field.
/// </summary>
[SerializeField, HideInInspector]
private CubismDrawable[] _allChildrenDrawables = null;
private CubismDrawable[] _allChildDrawables = null;

/// <summary>
/// All child drawables of this part, including children of children.
Expand All @@ -136,10 +196,10 @@ public CubismDrawable[] AllChildDrawables
{
get
{
if (_allChildrenDrawables == null)
if (_allChildDrawables == null)
{
var model = this.FindCubismModel(true);
if (!model)
if (!model || (model.Drawables?.Length ?? -1) < 1)
{
return null;
}
Expand All @@ -158,25 +218,30 @@ public CubismDrawable[] AllChildDrawables
}

// Initialize the array of all children drawables.
_allChildrenDrawables = Array.Empty<CubismDrawable>();
_allChildDrawables = Array.Empty<CubismDrawable>();

// Add the drawables of this part.
Array.Resize(ref _allChildrenDrawables, ChildDrawables.Length);
Array.Copy(ChildDrawables, _allChildrenDrawables, ChildDrawables.Length);
Array.Resize(ref _allChildDrawables, ChildDrawables.Length);
Array.Copy(ChildDrawables, _allChildDrawables, ChildDrawables.Length);

// Collect all children drawables from child parts.
for (var index = 0; index < childrenParts.Length; index++)
{
Array.Resize(ref _allChildrenDrawables, _allChildrenDrawables.Length + childrenParts[index].AllChildDrawables.Length);
if ((childrenParts[index]?.AllChildDrawables?.Length ?? -1) < 1)
{
continue;
}

Array.Resize(ref _allChildDrawables, _allChildDrawables.Length + childrenParts[index].AllChildDrawables.Length);
Array.Copy(childrenParts[index].AllChildDrawables,
0,
_allChildrenDrawables,
_allChildrenDrawables.Length - childrenParts[index].AllChildDrawables.Length,
_allChildDrawables,
_allChildDrawables.Length - childrenParts[index].AllChildDrawables.Length,
childrenParts[index].AllChildDrawables.Length);
}
}

return _allChildrenDrawables;
return _allChildDrawables;
}
}

Expand Down Expand Up @@ -261,7 +326,7 @@ public CubismDrawable[] ChildDrawables
private CubismOffscreen[] _childOffscreens;

/// <summary>
/// Child offscreens of this part.
/// Array of offscreen from child parts;
/// </summary>
public CubismOffscreen[] ChildOffscreens
{
Expand All @@ -282,14 +347,21 @@ public CubismOffscreen[] ChildOffscreens
return null;
}

_childOffscreens = Array.Empty<CubismOffscreen>();

for (var index = 0; index < offscreens.Length; index++)
{
var part = model.Parts[offscreens[index].OwnerIndex];

// When this object is the parent part.
if (offscreens[index].OwnerIndex == UnmanagedIndex)
if (part.UnmanagedParentIndex < 0
|| part.UnmanagedParentIndex != UnmanagedIndex)
{
Array.Resize(ref _childOffscreens, _childOffscreens?.Length ?? 0 + 1);
_childOffscreens[^1] = offscreens[index];
continue;
}

Array.Resize(ref _childOffscreens, _childOffscreens.Length + 1);
_childOffscreens[^1] = offscreens[index];
}
}
return _childOffscreens;
Expand Down Expand Up @@ -331,15 +403,14 @@ private void InitializePartInfo()
}

var childObjectCount = ChildDrawables.Length + ChildParts.Length;

_partInfo = new CubismModelTypes.PartInfo
{
PartUnmanagedIndex = UnmanagedIndex,
ChildObjects = new CubismModelTypes.PartChildObjectInfo[childObjectCount],
DrawObjects = new CubismModelTypes.PartDrawObjectInfo
{
Drawables = AllChildDrawables,
Offscreens = ChildOffscreens
Offscreens = AllChildOffscreens
}
};

Expand Down Expand Up @@ -394,7 +465,8 @@ private void Reset(CubismUnmanagedModel unmanagedModel, int unmanagedIndex)
name = Id;
Opacity = UnmanagedParts.Opacities[unmanagedIndex];

_allChildrenDrawables = null;
_allChildDrawables = null;
_allChildOffscreens = null;
_childParts = null;
_childDrawables = null;
_childOffscreens = null;
Expand Down
Loading