Skip to content

Commit

Permalink
Merge pull request #26 from Live2D/develop
Browse files Browse the repository at this point in the history
Update to Cubism SDK for Native R4
  • Loading branch information
itoh-at-live2d-com authored Dec 9, 2021
2 parents 1e373e4 + 15d57b4 commit 6587d62
Show file tree
Hide file tree
Showing 109 changed files with 11,115 additions and 9,518 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ 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/).

## [4-r.4] - 2021-12-09

### Added

* Add the rendering options on Metal:
* `USE_RENDER_TARGET`
* `USE_MODEL_RENDER_TARGET`
* Add a sample project for Mac Catalyst.

### Changed

* Update sample models. (Made with Cubism Editor 4.1.02)

### Fixed

* Fixed a graphics bug in Cocos2d-x sample with `USE_RENDER_TARGET` on iOS and macOS.
* Fix opacity was not being applied when using `USE_MODEL_RENDER_TARGET`.


## [4-r.4-beta.1] - 2021-10-07

### Added
Expand Down
6 changes: 6 additions & 0 deletions Core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ 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/).

## 2021-12-09

### Added

* Add static library(.a) for Mac Catalyst.


## 2021-10-07

Expand Down
4 changes: 3 additions & 1 deletion Core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Core
| Linux | x86_64 ||| linux/x86_64 | |
| macOS | ARM64 ||| macos/arm64 | |
| macOS | x86_64 ||| macos/x86_64 | |
| Mac Catalyst | ARM64 | || experimental/catalyst | Universal Binary |
| Mac Catalyst | x86_64 | || experimental/catalyst | Universal Binary |
| Raspberry Pi | ARM ||| experimental/rpi | |
| UWP | ARM || | experimental/uwp/arm | |
| UWP | ARM64 || | experimental/uwp/arm64 | |
Expand All @@ -45,7 +47,7 @@ Core

### Experimental Library

`Raspberry Pi` and `UWP` are experimental libraries.
`Raspberry Pi`, `UWP` and `catalyst` are experimental libraries.

### Windows Static Library

Expand Down
1 change: 1 addition & 0 deletions Core/RedistributableFiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ under the terms of the Live2D Proprietary Software License Agreement:
- lib/android/armeabi-v7a/libLive2DCubismCore.a
- lib/android/x86/libLive2DCubismCore.a
- lib/android/x86_64/libLive2DCubismCore.so
- lib/experimental/catalyst/libLive2DCubismCore.a
- lib/experimental/rpi/libLive2DCubismCore.a
- lib/ios/Debug-iphoneos/libLive2DCubismCore.a
- lib/ios/Debug-iphonesimulator/libLive2DCubismCore.a
Expand Down
20 changes: 13 additions & 7 deletions NOTICE.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
## [制限事項] Metal APIの対応状況について (2021-10-07)
## [注意事項] Metal及びCocos2d-x v4.0 の macOSサンプルビルドにおけるメモリリークについて (2021-12-09)

iOSのみの対応となっております。MacOSについては現在対応中となります。
レンダーターゲット機能及び異方性フィルタリング機能が未対応となっております。
Metal及びCocos2d-x v4.0 の macOSサンプルビルドにおいてメモリリークが発生いたします。
これはMetalフレームワーク内で発生するため、公式の対応をお待ち下さい。
本件のお問い合わせについて弊社ではお答えいたしかねますので、ご了承ください。

詳細については Apple Developer Forums をご確認ください。

## [制限事項] Apple製品の対応状況について (2021-10-07 更新)
* [Apple Developer Forums - Memory leak in MTLCommandBuffer?](https://developer.apple.com/forums/thread/120931)

Cubism SDK for Native 4-r.4-beta.1 にてApple Sillicon版のmacに対応いたしました。ぜひご利用ください。
※Cubism Editorは現在対応しておりませんので、ご了承ください。

## [制限事項] Apple製品の対応状況について (2021-12-09 更新)

macOS Monterey v12.0につきまして、Cubism 4 SDK for Native R4 (4-r.4) にて対応いたしました。
また、Cubism 4 SDK for Native R4 Beta1 (4-r.4-beta.1) 以降のバージョンでApple Silicon版のmacに対応しております。
※Cubism Editorは現在Apple Silicon製のMacに対応しておりません、ご了承ください。


## [制限事項] Cocos2d-x v4.0 の Linux(Ubuntu)サンプルビルドについて (2021-04-15)
Expand Down Expand Up @@ -41,7 +47,7 @@ Cocos2d-x v4.0 は `Ubuntu 20.04` ビルドに対応しておりません。

## Cubism Core

### [注意事項] macOS Catalina での `.bundle``.dylib` の利用について
### [注意事項] macOS Catalina 以降のバージョンでの `.bundle``.dylib` の利用について

macOS Catalina 上で `.bundle``.dylib` を利用する際、公証の確認のためオンライン環境に接続している必要があります。

Expand Down
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,16 @@ Demo
| CMake | 3.21.3 |
| Visual Studio 2013 | Update 5 |
| Visual Studio 2015 | Update 3 |
| Visual Studio 2017 | 15.9.39 |
| Visual Studio 2019 | 16.11.3 |
| XCode | 13.0 |
| Visual Studio 2017 | 15.9.41 |
| Visual Studio 2019 | 16.11.7 |
| XCode | 13.1 |

### Android

| Android SDK tools | バージョン |
| --- | --- |
| Android NDK | 23.0.7599858 |
| Android SDK | 30.0.3 |
| Android NDK | 23.1.7779620 |
| Android SDK | 31.0.0 |
| CMake | 3.18.1 |

### Linux
Expand All @@ -117,7 +117,7 @@ Demo
| Red Hat | `centos:7` | 4.8.5 |
| Red Hat | `centos:8` | 8.4.2 |
| Debian | `ubuntu:16.04` | 5.4.0 |
| Debian | `ubuntu:18.04` | 7.4.0 |
| Debian | `ubuntu:18.04` | 7.5.0 |
| Debian | `ubuntu:20.04` | 9.3.0 |

#### Mesa ライブラリ
Expand All @@ -134,9 +134,10 @@ Demo

| プラットフォーム | バージョン |
| --- | --- |
| iOS / iPadOS | 15.0.1 |
| macOS | 11.6 |
| iOS / iPadOS | 15.1 |
| macOS | 12.0.1 |
| Windows 10 | 21H1 |
| Windows 11 | 21H2 |

### Android

Expand All @@ -152,3 +153,11 @@ Demo
| Red Hat | Amazon Linux | 2 |
| Red Hat | CentOS | 8 |
| Debian | Ubuntu | 20.04 |


## コミュニティ

ユーザー同士でCubism SDKの活用方法の提案や質問をしたい場合は、是非コミュニティをご活用ください。

- [Live2D 公式コミュニティ](https://creatorsforum.live2d.com/)
- [Live2D community(English)](http://community.live2d.com/)
2 changes: 1 addition & 1 deletion Samples/Cocos2d-x/Demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ if(APPLE)
set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "")
set_xcode_property(${APP_NAME} CODE_SIGN_IDENTITY "iPhone Developer")
set_xcode_property(${APP_NAME} PRODUCT_BUNDLE_IDENTIFIER "com.live2d.demo")
set_xcode_property(${APP_NAME} PRODUCT_BUNDLE_IDENTIFIER "com.live2d.demo-cocos2dx")
set_xcode_property(${APP_NAME} TARGETED_DEVICE_FAMILY "1,2")
set_xcode_property(${APP_NAME} ONLY_ACTIVE_ARCH "NO")
set_xcode_property(${APP_NAME} ARCHS "arm64")
Expand Down
7 changes: 4 additions & 3 deletions Samples/Cocos2d-x/Demo/Classes/LAppLive2DManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,15 @@ void LAppLive2DManager::CreateShader()
"attribute vec2 uv;"
"varying vec2 vuv;"
"void main(void){"
#if defined(CC_USE_METAL)
" gl_Position = vec4(position.x, -position.y, position.z, 1.0);"
#else
" gl_Position = vec4(position, 1.0);"
#endif
" vuv = uv;"
"}";

const char* fragmentShader =
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
"precision mediump float;"
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
"precision mediump float;"
#endif
Expand Down
2 changes: 1 addition & 1 deletion Samples/Cocos2d-x/Demo/Classes/LAppModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ void LAppModel::MakeRenderingTarget()
);

// レンダリングバッファの描画先をそのテクスチャにする
_renderBuffer->CreateOffscreenFrame(frameW, frameH, _renderSprite->getSprite()->getTexture());
_renderBuffer->CreateOffscreenFrame(frameW, frameH, _renderSprite);
}
}

Expand Down
61 changes: 45 additions & 16 deletions Samples/Metal/Demo/proj.ios.cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ set(CMAKE_CXX_EXTENSIONS OFF)

# Detect platform.
if(PLATFORM STREQUAL "OS64")
set(PLATFORM_NAME iphoneos)
if(CSM_MAC_CATALYST)
set(PLATFORM_NAME maccatalyst)
else()
set(PLATFORM_NAME iphoneos)
endif()
elseif(PLATFORM STREQUAL "SIMULATOR64")
set(PLATFORM_NAME iphonesimulator)
else()
Expand All @@ -40,12 +44,31 @@ endif()
# Import as static library.
add_library(Live2DCubismCore STATIC IMPORTED)
# Set library path and inlude path.
if(CSM_MAC_CATALYST)
set_target_properties(Live2DCubismCore
PROPERTIES
IMPORTED_LOCATION_DEBUG
${CORE_PATH}/lib/experimental/catalyst/libLive2DCubismCore.a
IMPORTED_LOCATION_RELEASE
${CORE_PATH}/lib/experimental/catalyst/libLive2DCubismCore.a
INTERFACE_INCLUDE_DIRECTORIES ${CORE_PATH}/include
)
else()
set_target_properties(Live2DCubismCore
PROPERTIES
IMPORTED_LOCATION_DEBUG
${CORE_PATH}/lib/ios/Debug-${PLATFORM_NAME}/libLive2DCubismCore.a
IMPORTED_LOCATION_RELEASE
${CORE_PATH}/lib/ios/Release-${PLATFORM_NAME}/libLive2DCubismCore.a
INTERFACE_INCLUDE_DIRECTORIES ${CORE_PATH}/include
)
endif()
# Get architecture.
EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE )
# Set library path and inlude path.
set_target_properties(Live2DCubismCore
PROPERTIES
IMPORTED_LOCATION_DEBUG
${CORE_PATH}/lib/ios/Debug-${PLATFORM_NAME}/libLive2DCubismCore.a
IMPORTED_LOCATION_RELEASE
${CORE_PATH}/lib/ios/Release-${PLATFORM_NAME}/libLive2DCubismCore.a
IMPORTED_LOCATION ${CORE_PATH}/lib/macos/${ARCHITECTURE}/libLive2DCubismCore.a
INTERFACE_INCLUDE_DIRECTORIES ${CORE_PATH}/include
)

Expand Down Expand Up @@ -86,15 +109,15 @@ target_link_libraries(${APP_NAME}
target_include_directories(${APP_NAME} PRIVATE ${STB_PATH})

# Copy resource directory to build directory.
# NOTE: "Resources" is a reserved word of Xcode.
# NOTE: In iOS, "Resources" is a reserved word of Xcode.
# Therefore, copy destination directory name to "Res".
add_custom_command(
TARGET ${APP_NAME}
POST_BUILD
COMMAND
${CMAKE_COMMAND} -E
copy_directory ${RES_PATH} $<TARGET_FILE_DIR:${APP_NAME}>/Res
)
target_sources(${APP_NAME} PUBLIC ${RES_PATH})

if(CSM_MAC_CATALYST)
set_source_files_properties(${RES_PATH} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
else()
set_source_files_properties(${RES_PATH} PROPERTIES MACOSX_PACKAGE_LOCATION Res)
endif()

# Add information aboud XCode project.
set_xcode_property(${APP_NAME}
Expand All @@ -104,9 +127,15 @@ set_xcode_property(${APP_NAME}
)
set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "" "All")
set_xcode_property(${APP_NAME} CODE_SIGN_IDENTITY "iPhone Developer" "All")
set_xcode_property(${APP_NAME}
PRODUCT_BUNDLE_IDENTIFIER "com.live2d.demo" "All"
)
if(CSM_MAC_CATALYST)
set_xcode_property(${APP_NAME}
PRODUCT_BUNDLE_IDENTIFIER "com.live2d.demo-catalyst" "All"
)
else()
set_xcode_property(${APP_NAME}
PRODUCT_BUNDLE_IDENTIFIER "com.live2d.demo" "All"
)
endif()
set_xcode_property(${APP_NAME} TARGETED_DEVICE_FAMILY "1,2" "All")
if(PLATFORM STREQUAL "OS64")
set_xcode_property(${APP_NAME} ARCHS "arm64" "All")
Expand Down
5 changes: 4 additions & 1 deletion Samples/Metal/Demo/proj.ios.cmake/scripts/proj_xcode
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ THIRD_PARTY_PATH=$CMAKE_PATH/../../thirdParty/

PLATFORM=NONE
NAME=unknown
CSM_MAC_CATALYST=OFF
PS3="Select the platform number to use: "
select var in 'iphoneOS (arm64)' 'iphoneOS Simulator (x86_64)'
select var in 'iphoneOS (arm64)' 'iphoneOS Simulator (x86_64)' 'Mac Catalyst'
do
case "$var" in
'iphoneOS (arm64)' ) PLATFORM=OS64; NAME=iphoneos ;;
'iphoneOS Simulator (x86_64)' ) PLATFORM=SIMULATOR64; NAME=iphonesimulator ;;
'Mac Catalyst' ) PLATFORM=OS64; NAME=maccatalyst; CSM_MAC_CATALYST=ON ;;
* ) echo "Invalid option $REPLY." ;;
esac
break
Expand All @@ -29,4 +31,5 @@ cmake -S "$CMAKE_PATH" \
-B "${BUILD_PATH}_${NAME}" \
-D CMAKE_TOOLCHAIN_FILE="$THIRD_PARTY_PATH/ios-cmake/ios.toolchain.cmake" \
-D PLATFORM=$PLATFORM \
-D CSM_MAC_CATALYST=$CSM_MAC_CATALYST \
-G Xcode
5 changes: 0 additions & 5 deletions Samples/Metal/Demo/proj.ios.cmake/src/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -46,34 +46,29 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application
{
}


- (void)applicationDidEnterBackground:(UIApplication *)application
{
_textureManager = nil;

_sceneIndex = [[LAppLive2DManager getInstance] sceneIndex];
}


- (void)applicationWillEnterForeground:(UIApplication *)application
{
_textureManager = [[LAppTextureManager alloc]init];

[[LAppLive2DManager getInstance] changeScene:_sceneIndex];
}


- (void)applicationDidBecomeActive:(UIApplication *)application
{

}


- (void)applicationWillTerminate:(UIApplication *)application {
self.viewController = nil;
}
Expand Down
4 changes: 4 additions & 0 deletions Samples/Metal/Demo/proj.ios.cmake/src/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIcons</key>
<dict/>
<key>CFBundleIcons~ipad</key>
<dict/>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand Down
6 changes: 5 additions & 1 deletion Samples/Metal/Demo/proj.ios.cmake/src/LAppDefine.mm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
const csmFloat32 ViewLogicalMaxTop = 2.0f;

// 相対パス
const csmChar* ResourcesPath = "Res/";
#if !TARGET_OS_MACCATALYST
const csmChar* ResourcesPath = "Res/Resources/";
#else
const csmChar* ResourcesPath = "Resources/";
#endif

// モデルの後ろにある背景の画像ファイル
const csmChar* BackImageName = "back_class_normal.png";
Expand Down
Loading

0 comments on commit 6587d62

Please sign in to comment.