diff --git a/CHANGELOG.md b/CHANGELOG.md index c7fbefa..1316308 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Change Log +## [2.5.22] - 2024-11-04 + +- Features + - The following Particle System modules are now available. + - `TextureSheetAnimation` + - `CustomData` + - NOVA shader version 2.4.0 is now supported. + - `jp.co.cyberagent.novas` + - `com.izayoi.nova.shader.utility` + - However, `Texture2DAarray` and `Texture3D` are not supported. + ## [2.5.21] - 2024-10-01 - Features diff --git a/Documentation~/UniVGO/Installation.ja.md b/Documentation~/UniVGO/Installation.ja.md index 0f72128..f325d8b 100644 --- a/Documentation~/UniVGO/Installation.ja.md +++ b/Documentation~/UniVGO/Installation.ja.md @@ -44,7 +44,7 @@ Unity 2021.1 以下のバージョンを使用する場合 |com.unity.nuget.newtonsoft-json|Unity Technologies|Nuget|13.0.2|3.2.1|2023年5月2日| |com.izayoi.unishaders|IzayoiJiichan|GitHub||1.6.1|2023年8月1日| |com.izayoi.vgospringbone|IzayoiJiichan|GitHub||1.1.2|2022年8月24日| -|com.izayoi.univgo|IzayoiJiichan|GitHub|VGO 2.5|2.5.21|2024年10月1日| +|com.izayoi.univgo|IzayoiJiichan|GitHub|VGO 2.5|2.5.22|2024年11月4日| #### 追加パッケージ @@ -53,6 +53,8 @@ Unity 2021.1 以下のバージョンを使用する場合 |パッケージ名|所有者|リポジトリー|仕様バージョン|プログラム バージョン|リリース日|備考| |:---|:---:|:---:|:---:|:---:|:---:|:---:| |com.izayoi.liltoon.shader.utility|IzayoiJiichan|GitHub||1.7.0|2024年1月18日|| +|com.izayoi.nova.shader.utility|IzayoiJiichan|GitHub||2.4.0|2024年11月4日|| +|jp.co.cyberagent.nova|Cyber Agent|GitHub||2.4.0|2024年10月11日|| |jp.lilxyzw.liltoon|lilxyzw|GitHub||1.7.3|2024年8月8日|| |com.vrmc.vrmshaders|vrm-c|GitHub||0.124.2|2024年7月23日|| |org.nuget.sixlabors.imagesharp|SixLabors|Unity NuGet||2.1.5|2023年8月14日|for WebP| @@ -144,7 +146,7 @@ UniVGOを使用するために、以下の設定を追加してください。 { "dependencies": { "com.izayoi.unishaders": "https://github.com/izayoijiichan/UniShaders.git#v1.6.1", - "com.izayoi.univgo": "https://github.com/izayoijiican/VGO.git#v2.5.21", + "com.izayoi.univgo": "https://github.com/izayoijiican/VGO.git#v2.5.22", "com.izayoi.vgospringbone": "https://github.com/izayoijiichan/VgoSpringBone.git#v1.1.2", "com.unity.nuget.newtonsoft-json": "3.2.1", } @@ -164,6 +166,17 @@ lilToon を使用する場合、以下の行を追加してください。 } ``` +NOVA shader を使用する場合、以下の行を追加してください。 + +```json +{ + "dependencies": { + "com.izayoi.nova.shader.utility": "https://github.com/izayoijiichan/NovaShaderUtility.git#v2.4.0", + "jp.co.cyberagent.nova": "https://github.com/CyberAgentGameEntertainment/NovaShader.git?path=Assets/Nova#2.4.0", + } +} +``` + UniUnlit を使用する場合、以下の行を追加してください。 ```json @@ -224,7 +237,7 @@ UniVRM 0.125 以上の場合は上記の代わりに以下を追加してくだ } ``` -WUnity 2021.2 以上のバージョンを使用していて、WebPを使用する場合、"org.nuget.sixlabors.imagesharp" の行を追加してください。 +Unity 2021.2 以上のバージョンを使用していて、WebPを使用する場合、"org.nuget.sixlabors.imagesharp" の行を追加してください。 ```json { @@ -311,6 +324,8 @@ ___ |MToon|MToon シェーダー ユーティリティー|*|*| |MToon.Editor|MToon シェーダー ユーティリティー|-|-| |NewtonVgo|Newton.JSON向け VGOプログラム|*|*| +|NOVA|NOVA シェーダー ユーティリティー|*|*| +|NOVA.Editor|NOVA シェーダー ユーティリティー|-|-| |ShaderProperty.Runtime|シェーダーのプロパティー情報|*|*| |UniShader.Hdrp.Utility|HDRP シェーダー ユーティリティー|*|*| |UniShader.Shared|Unity シェーダー 共有 ユーティリティー|*|*| @@ -337,32 +352,32 @@ ___ |UniVRM|UniVGO|min Unity| |:---:|:---:|:---:| -|0.100.0|2.5.21|2020.3| -|0.101.0|2.5.21|2020.3| -|0.102.0|2.5.21|2020.3| -|0.103.2|2.5.21|2020.3| -|0.104.2|2.5.21|2020.3| -|0.105.0|2.5.21|2020.3| -|0.106.0|2.5.21|2020.3| -|0.107.2|2.5.21|2020.3| -|0.108.0|2.5.21|2020.3| -|0.109.0|2.5.21|2020.3| -|0.110.0|2.5.21|2020.3| -|0.111.0|2.5.21|2020.3| -|0.112.0|2.5.21|2021.3| -|0.113.0|2.5.21|2021.3| -|0.114.0|2.5.21|2021.3| -|0.115.0|2.5.21|2021.3| -|0.116.0|2.5.21|2021.3| -|0.117.0|2.5.21|2021.3| -|0.118.0|2.5.21|2021.3| -|0.119.0|2.5.21|2021.3| -|0.120.0|2.5.21|2021.3| -|0.121.0|2.5.21|2021.3| -|0.122.0|2.5.21|2021.3| -|0.123.0|2.5.21|2021.3| -|0.124.2|2.5.21|2021.3| -|0.125.0|2.5.21|2021.3| +|0.100.0|2.5.22|2020.3| +|0.101.0|2.5.22|2020.3| +|0.102.0|2.5.22|2020.3| +|0.103.2|2.5.22|2020.3| +|0.104.2|2.5.22|2020.3| +|0.105.0|2.5.22|2020.3| +|0.106.0|2.5.22|2020.3| +|0.107.2|2.5.22|2020.3| +|0.108.0|2.5.22|2020.3| +|0.109.0|2.5.22|2020.3| +|0.110.0|2.5.22|2020.3| +|0.111.0|2.5.22|2020.3| +|0.112.0|2.5.22|2021.3| +|0.113.0|2.5.22|2021.3| +|0.114.0|2.5.22|2021.3| +|0.115.0|2.5.22|2021.3| +|0.116.0|2.5.22|2021.3| +|0.117.0|2.5.22|2021.3| +|0.118.0|2.5.22|2021.3| +|0.119.0|2.5.22|2021.3| +|0.120.0|2.5.22|2021.3| +|0.121.0|2.5.22|2021.3| +|0.122.0|2.5.22|2021.3| +|0.123.0|2.5.22|2021.3| +|0.124.2|2.5.22|2021.3| +|0.125.0|2.5.22|2021.3| `/Packages/package.json` に以下の記述を行います。 @@ -406,7 +421,7 @@ https://github.com/izayoijiichan/VGO/wiki/How-to-use-UniVRM-and-UniVGO-together |2022.3.0f1|BRP|UniVGO + UniVRM|[Link](https://github.com/izayoijiichan/univgo2.sample.unity.project/tree/unity2022.3.brp.univrm)| ___ -最終更新日:2024年10月1日 +最終更新日:2024年11月4日 編集者:十六夜おじいちゃん *Copyright (C) 2020 Izayoi Jiichan. All Rights Reserved.* diff --git a/Documentation~/UniVGO/Installation.md b/Documentation~/UniVGO/Installation.md index 4974ef9..cb7c232 100644 --- a/Documentation~/UniVGO/Installation.md +++ b/Documentation~/UniVGO/Installation.md @@ -44,7 +44,7 @@ This package is required for any Unity version. |com.unity.nuget.newtonsoft-json|Unity Technologies|Nuget|13.0.2|3.2.1|2 May, 2023| |com.izayoi.unishaders|IzayoiJiichan|GitHub||1.6.1|1 Aug, 2023| |com.izayoi.vgospringbone|IzayoiJiichan|GitHub||1.1.2|24 Aug, 2022| -|com.izayoi.univgo|IzayoiJiichan|GitHub|VGO 2.5|2.5.1|1 Oct, 2024| +|com.izayoi.univgo|IzayoiJiichan|GitHub|VGO 2.5|2.5.22|4 Nov, 2024| #### Additional Packages @@ -53,6 +53,8 @@ Add if necessary. |package name|owner|Repository|specification version|program version|release date|remarks| |:---|:---:|:---:|:---:|:---:|:---:|:---:| |com.izayoi.liltoon.shader.utility|IzayoiJiichan|GitHub||1.7.0|18 Jan, 2024|| +|com.izayoi.nova.shader.utility|IzayoiJiichan|GitHub||2.4.0|4 Nov, 2024|| +|jp.co.cyberagent.nova|Cyber Agent|GitHub||2.4.0|11, Oct, 2024|| |jp.lilxyzw.liltoon|lilxyzw|GitHub||1.7.3|8 Aug, 2024|| |com.vrmc.vrmshaders|vrm-c|GitHub||0.124.2|23 Jul, 2024|| |org.nuget.sixlabors.imagesharp|SixLabors|Unity NuGet||2.1.5|14 Aug, 2023|for WebP| @@ -143,7 +145,7 @@ To use UniVGO, add the following settings. { "dependencies": { "com.izayoi.unishaders": "https://github.com/izayoijiichan/UniShaders.git#v1.6.1", - "com.izayoi.univgo": "https://github.com/izayoijiican/VGO.git#v2.5.21", + "com.izayoi.univgo": "https://github.com/izayoijiican/VGO.git#v2.5.22", "com.izayoi.vgospringbone": "https://github.com/izayoijiichan/VgoSpringBone.git#v1.1.2", "com.unity.nuget.newtonsoft-json": "3.2.1", } @@ -152,7 +154,7 @@ To use UniVGO, add the following settings. #### 2-3. Addtional Packages -If you want to use lilToon, append the line "jp.lilxyzw.liltoon". +If you want to use lilToon, add the following line. ```json { @@ -163,6 +165,17 @@ If you want to use lilToon, append the line "jp.lilxyzw.liltoon". } ``` +If you want to use NOVA shader, add the following line. + +```json +{ + "dependencies": { + "com.izayoi.nova.shader.utility": "https://github.com/izayoijiichan/NovaShaderUtility.git#v2.4.0", + "jp.co.cyberagent.nova": "https://github.com/CyberAgentGameEntertainment/NovaShader.git?path=Assets/Nova#2.4.0", + } +} +``` + If you use UniUnlit, add the following line. ```json @@ -309,6 +322,8 @@ When the package is installed in the project, the script is automatically compil |MToon|MToon shader utility|*|*| |MToon.Editor|MToon shader utility|-|*| |NewtonVgo|for Newton.JSON vgo program|*|*| +|NOVA|NOVA shader utility|*|*| +|NOVA.Editor|NOVA shader utility|-|*| |ShaderProperty.Runtime|Shader property information|*|*| |UniShader.Hdrp.Utility|HDRP shader utility|*|*| |UniShader.Shared|Unity shader shared utility|*|*| @@ -335,32 +350,32 @@ The version combinations are as follows. |UniVRM|UniVGO|min Unity| |:---:|:---:|:---:| -|0.100.0|2.5.21|2020.3| -|0.101.0|2.5.21|2020.3| -|0.102.0|2.5.21|2020.3| -|0.103.2|2.5.21|2020.3| -|0.104.2|2.5.21|2020.3| -|0.105.0|2.5.21|2020.3| -|0.106.0|2.5.21|2020.3| -|0.107.2|2.5.21|2020.3| -|0.108.0|2.5.21|2020.3| -|0.109.0|2.5.21|2020.3| -|0.110.0|2.5.21|2020.3| -|0.111.0|2.5.21|2020.3| -|0.112.0|2.5.21|2021.3| -|0.113.0|2.5.21|2021.3| -|0.114.0|2.5.21|2021.3| -|0.115.0|2.5.21|2021.3| -|0.116.0|2.5.21|2021.3| -|0.117.0|2.5.21|2021.3| -|0.118.0|2.5.21|2021.3| -|0.119.0|2.5.21|2021.3| -|0.120.0|2.5.21|2021.3| -|0.121.0|2.5.21|2021.3| -|0.122.0|2.5.21|2021.3| -|0.123.0|2.5.21|2021.3| -|0.124.2|2.5.21|2021.3| -|0.125.0|2.5.21|2021.3| +|0.100.0|2.5.22|2020.3| +|0.101.0|2.5.22|2020.3| +|0.102.0|2.5.22|2020.3| +|0.103.2|2.5.22|2020.3| +|0.104.2|2.5.22|2020.3| +|0.105.0|2.5.22|2020.3| +|0.106.0|2.5.22|2020.3| +|0.107.2|2.5.22|2020.3| +|0.108.0|2.5.22|2020.3| +|0.109.0|2.5.22|2020.3| +|0.110.0|2.5.22|2020.3| +|0.111.0|2.5.22|2020.3| +|0.112.0|2.5.22|2021.3| +|0.113.0|2.5.22|2021.3| +|0.114.0|2.5.22|2021.3| +|0.115.0|2.5.22|2021.3| +|0.116.0|2.5.22|2021.3| +|0.117.0|2.5.22|2021.3| +|0.118.0|2.5.22|2021.3| +|0.119.0|2.5.22|2021.3| +|0.120.0|2.5.22|2021.3| +|0.121.0|2.5.22|2021.3| +|0.122.0|2.5.22|2021.3| +|0.123.0|2.5.22|2021.3| +|0.124.2|2.5.22|2021.3| +|0.125.0|2.5.22|2021.3| Write the following in ` /Packages/package.json`. @@ -404,7 +419,7 @@ https://github.com/izayoijiichan/VGO/wiki/How-to-use-UniVRM-and-UniVGO-together |2022.3.0f1|BRP|UniVGO + UniVRM|[Link](https://github.com/izayoijiichan/univgo2.sample.unity.project/tree/unity2022.3.brp.univrm)| ___ -Last updated: 1 October, 2024 +Last updated: 4 November, 2024 Editor: Izayoi Jiichan *Copyright (C) 2020 Izayoi Jiichan. All Rights Reserved.* diff --git a/Documentation~/VGO/specification/2.5/schema/vgo.ps.customData.schema.json b/Documentation~/VGO/specification/2.5/schema/vgo.ps.customData.schema.json new file mode 100644 index 0000000..f4fb842 --- /dev/null +++ b/Documentation~/VGO/specification/2.5/schema/vgo.ps.customData.schema.json @@ -0,0 +1,60 @@ +{ + "$id": "vgo.ps.customData", + "type": "object", + "enabled": { + "type": "boolean" + }, + "stream": { + "anyOf": [ + { + "enum": [ 0 ], + "description": "Custom1", + "type": "integer" + }, + { + "enum": [ 1 ], + "description": "Custom2", + "type": "integer" + } + ] + }, + "mode": { + "anyOf": [ + { + "enum": [ 0 ], + "description": "Disabled", + "type": "integer" + }, + { + "enum": [ 1 ], + "description": "Vector", + "type": "integer" + }, + { + "enum": [ 2 ], + "description": "Color", + "type": "integer" + } + ] + }, + "vector": { + "type": [ + "array", + "null" + ], + "items": { + "$id": "vgo.ps.minMaxCurve", + "type": [ + "object", + "null" + ] + } + }, + "color": { + "$id": "vgo.ps.minMaxGradient", + "type": [ + "object", + "null" + ] + } +} \ No newline at end of file diff --git a/Documentation~/VGO/specification/2.5/schema/vgo.ps.customDataModule.schema.json b/Documentation~/VGO/specification/2.5/schema/vgo.ps.customDataModule.schema.json index 8a8c391..1243fd7 100644 --- a/Documentation~/VGO/specification/2.5/schema/vgo.ps.customDataModule.schema.json +++ b/Documentation~/VGO/specification/2.5/schema/vgo.ps.customDataModule.schema.json @@ -1,4 +1,17 @@ { "$id": "vgo.ps.customDataModule", - "type": "object" + "type": "object", + "enabled": { + "type": "boolean" + }, + "customData": { + "type": [ + "array", + "null" + ], + "items": { + "$id": "vgo.ps.customData", + "type": "object" + } + } } \ No newline at end of file diff --git a/Documentation~/VGO/specification/2.5/schema/vgo.ps.textureSheetAnimationModule.schema.json b/Documentation~/VGO/specification/2.5/schema/vgo.ps.textureSheetAnimationModule.schema.json index 01f4bda..cab7588 100644 --- a/Documentation~/VGO/specification/2.5/schema/vgo.ps.textureSheetAnimationModule.schema.json +++ b/Documentation~/VGO/specification/2.5/schema/vgo.ps.textureSheetAnimationModule.schema.json @@ -1,4 +1,143 @@ { "$id": "vgo.ps.textureSheetAnimationModule", - "type": "object" + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "mode": { + "anyOf": [ + { + "enum": [ 0 ], + "description": "Grid", + "type": "integer" + }, + { + "enum": [ 1 ], + "description": "Gradient", + "type": "integer" + } + ] + }, + "numTilesX": { + "type": "integer" + }, + "numTilesY": { + "type": "integer" + }, + "animation": { + "anyOf": [ + { + "enum": [ 0 ], + "description": "WholeSheet", + "type": "integer" + }, + { + "enum": [ 1 ], + "description": "SingleRow", + "type": "integer" + } + ] + }, + "rowMode": { + "anyOf": [ + { + "enum": [ 0 ], + "description": "Custom", + "type": "integer" + }, + { + "enum": [ 1 ], + "description": "Random", + "type": "integer" + }, + { + "enum": [ 2 ], + "description": "MeshIndex", + "type": "integer" + } + ] + }, + "rowIndex": { + "type": "integer" + }, + "timeMode": { + "anyOf": [ + { + "enum": [ 0 ], + "description": "Lifetime", + "type": "integer" + }, + { + "enum": [ 1 ], + "description": "Speed", + "type": "integer" + }, + { + "enum": [ 2 ], + "description": "FPS", + "type": "integer" + } + ] + }, + "frameOverTime": { + "$id": "vgo.ps.minMaxCurve", + "type": [ + "object", + "null" + ] + }, + "frameOverTimeMultiplier": { + "type": "number" + }, + "speedRange": { + "type": [ + "array", + "null" + ], + "items": { + "type": "number" + } + }, + "fps": { + "type": "number" + }, + "startFrame": { + "$id": "vgo.ps.minMaxCurve", + "type": [ + "object", + "null" + ] + }, + "startFrameMultiplier": { + "type": "number" + }, + "cycleCount": { + "type": "integer" + }, + "uvChannelMask": { + "anyOf": [ + { + "enum": [ 1 ], + "description": "UV0", + "type": "integer" + }, + { + "enum": [ 2 ], + "description": "UV1", + "type": "integer" + }, + { + "enum": [ 4 ], + "description": "UV2", + "type": "integer" + }, + { + "enum": [ 8 ], + "description": "UV3", + "type": "integer" + } + ] + } + } } \ No newline at end of file diff --git a/NewtonVgo/Runtime/Enums/UnityEngine/ParticleSystemModule.cs b/NewtonVgo/Runtime/Enums/UnityEngine/ParticleSystemModule.cs index bb0bc01..c693dbb 100644 --- a/NewtonVgo/Runtime/Enums/UnityEngine/ParticleSystemModule.cs +++ b/NewtonVgo/Runtime/Enums/UnityEngine/ParticleSystemModule.cs @@ -100,6 +100,27 @@ public enum ParticleSystemCurveMode TwoConstants = 3, } + /// The particle custom data. + public enum ParticleSystemCustomData + { + /// The first stream of custom per-particle data. + Custom1 = 0, + /// The second stream of custom per-particle data. + Custom2 = 1, + } + + + /// The particle custom data mode. + public enum ParticleSystemCustomDataMode + { + /// Don't generate any data. + Disabled = 0, + /// Generate data using ParticleSystem.MinMaxCurve. + Vector = 1, + /// Generate data using ParticleSystem.MinMaxGradient. + Color = 2, + } + /// Control how a Particle System calculates its velocity. public enum ParticleSystemEmitterVelocityMode { diff --git a/NewtonVgo/Runtime/Enums/UnityEngine/Rendering.cs b/NewtonVgo/Runtime/Enums/UnityEngine/Rendering.cs index 92833ca..d673b4e 100644 --- a/NewtonVgo/Runtime/Enums/UnityEngine/Rendering.cs +++ b/NewtonVgo/Runtime/Enums/UnityEngine/Rendering.cs @@ -156,15 +156,16 @@ public enum TextureDimension } /// A flag representing each UV channel. + [Flags] public enum UVChannelFlags { /// First UV channel. - UV0 = 0, + UV0 = 1, /// Second UV channel. - UV1 = 1, + UV1 = 2, /// Third UV channel. - UV2 = 2, + UV2 = 4, /// Fourth UV channel. - UV3 = 3, + UV3 = 8, } } diff --git a/NewtonVgo/Runtime/Schema/Layouts/Meshes/VgoMesh.cs b/NewtonVgo/Runtime/Schema/Layouts/Meshes/VgoMesh.cs index 072a526..e7fb597 100644 --- a/NewtonVgo/Runtime/Schema/Layouts/Meshes/VgoMesh.cs +++ b/NewtonVgo/Runtime/Schema/Layouts/Meshes/VgoMesh.cs @@ -49,8 +49,9 @@ public class VgoMesh /// List of the blend shape preset. /// This property is used only in spec version between 2.0 and 2.4. - [JsonProperty("blendShapePesets")] - public List? blendShapePesets; + [JsonProperty("blendShapePesets")] // typo + //[JsonProperty("blendShapePresets")] + public List? blendShapePresets; /// Whether this primitive has a vertex color. [JsonIgnore] diff --git a/NewtonVgo/Runtime/Schema/Layouts/Meshes/VgoMeshRenderer.cs b/NewtonVgo/Runtime/Schema/Layouts/Meshes/VgoMeshRenderer.cs index 945b906..f9294d8 100644 --- a/NewtonVgo/Runtime/Schema/Layouts/Meshes/VgoMeshRenderer.cs +++ b/NewtonVgo/Runtime/Schema/Layouts/Meshes/VgoMeshRenderer.cs @@ -46,9 +46,14 @@ public class VgoMeshRenderer public VgoBlendShapeKind? blendShapeKind; /// List of the blend shape preset. + //[Obsolete("typo")] [JsonProperty("blendShapePesets")] public List? blendShapePesets; + /// List of the blend shape preset. + [JsonProperty("blendShapePresets")] + public List? blendShapePresets; + /// /// Returns a string that represents the current object. /// diff --git a/NewtonVgo/Runtime/Schema/Layouts/ParticleSystems/VGO_PS_CustomDataModule.cs b/NewtonVgo/Runtime/Schema/Layouts/ParticleSystems/VGO_PS_CustomDataModule.cs index c5f0d63..8ba9d77 100644 --- a/NewtonVgo/Runtime/Schema/Layouts/ParticleSystems/VGO_PS_CustomDataModule.cs +++ b/NewtonVgo/Runtime/Schema/Layouts/ParticleSystems/VGO_PS_CustomDataModule.cs @@ -15,5 +15,36 @@ namespace NewtonVgo.Schema.ParticleSystems [JsonObject("vgo.ps.customDataModule")] public class VGO_PS_CustomDataModule { + /// Specifies whether the CustomDataModule is enabled or disabled. + [JsonProperty("enabled")] + public bool enabled; + + /// Array of the custom data. + [JsonProperty("customData")] + public VGO_PS_CustomData[]? customData; + } + + /// + /// VGO Particle System CustomData + /// + [Serializable] + [JsonObject("vgo.ps.customData")] + public class VGO_PS_CustomData + { + /// The stream of data. + [JsonProperty("stream")] + public ParticleSystemCustomData stream; + + /// The mode of data. + [JsonProperty("mode")] + public ParticleSystemCustomDataMode mode; + + /// Array of the vector component. + [JsonProperty("vector")] + public VGO_PS_MinMaxCurve[]? vector; + + ///// The color gradient. + [JsonProperty("color")] + public VGO_PS_MinMaxGradient? color; } } diff --git a/NewtonVgo/Runtime/Schema/Layouts/ParticleSystems/VGO_PS_TextureSheetAnimationModule.cs b/NewtonVgo/Runtime/Schema/Layouts/ParticleSystems/VGO_PS_TextureSheetAnimationModule.cs index 9529773..de053b3 100644 --- a/NewtonVgo/Runtime/Schema/Layouts/ParticleSystems/VGO_PS_TextureSheetAnimationModule.cs +++ b/NewtonVgo/Runtime/Schema/Layouts/ParticleSystems/VGO_PS_TextureSheetAnimationModule.cs @@ -48,13 +48,6 @@ public class VGO_PS_TextureSheetAnimationModule [JsonProperty("rowMode")] public ParticleSystemAnimationRowMode rowMode; - /// - /// Select whether the system bases the playback on mapping a curve to the lifetime of each particle, - /// by using the particle speeds, or if playback simply uses a constant frames per second. - /// - [JsonProperty("timeMode")] - public ParticleSystemAnimationTimeMode timeMode; - /// /// Explicitly select which row of the Texture sheet to use. /// The system uses this property when ParticleSystem.TextureSheetAnimationModule.rowMode is set to Custom. @@ -62,6 +55,13 @@ public class VGO_PS_TextureSheetAnimationModule [JsonProperty("rowIndex")] public int rowIndex; + /// + /// Select whether the system bases the playback on mapping a curve to the lifetime of each particle, + /// by using the particle speeds, or if playback simply uses a constant frames per second. + /// + [JsonProperty("timeMode")] + public ParticleSystemAnimationTimeMode timeMode; + /// A curve to control which frame of the Texture sheet animation to play. [JsonProperty("frameOverTime")] public VGO_PS_MinMaxCurve? frameOverTime; @@ -70,23 +70,22 @@ public class VGO_PS_TextureSheetAnimationModule [JsonProperty("frameOverTimeMultiplier")] public float frameOverTimeMultiplier; - /// Define a random starting frame for the Texture sheet animation. - [JsonProperty("startFrame")] - public VGO_PS_MinMaxCurve? startFrame; - - /// The starting frame multiplier. - [JsonProperty("startFrameMultiplier")] - public float startFrameMultiplier; - /// Specify how particle speeds are mapped to the animation frames. [JsonProperty("speedRange")] - //public Vector2 speedRange; public Vector2? speedRange; /// Control how quickly the animation plays. [JsonProperty("fps")] public float fps; + /// Define a random starting frame for the Texture sheet animation. + [JsonProperty("startFrame")] + public VGO_PS_MinMaxCurve? startFrame; + + /// The starting frame multiplier. + [JsonProperty("startFrameMultiplier")] + public float startFrameMultiplier; + /// Specifies how many times the animation loops during the lifetime of the particle. [JsonProperty("cycleCount")] public int cycleCount; diff --git a/NewtonVgo/Runtime/Schema/Layouts/Textures/VgoTexture.cs b/NewtonVgo/Runtime/Schema/Layouts/Textures/VgoTexture.cs index 1f3e7cf..950304b 100644 --- a/NewtonVgo/Runtime/Schema/Layouts/Textures/VgoTexture.cs +++ b/NewtonVgo/Runtime/Schema/Layouts/Textures/VgoTexture.cs @@ -29,6 +29,21 @@ public class VgoTexture [DefaultValue(-1)] public int source = -1; + ///// The texture width. + //[JsonProperty("width", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + //[DefaultValue(-1)] + //public int width = -1; + + ///// The texture height. + //[JsonProperty("height", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + //[DefaultValue(-1)] + //public int height = -1; + + ///// The texture depth. + //[JsonProperty("depth", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + //[DefaultValue(-1)] + //public int depth = -1; + /// Dimensionality type of the texture. [JsonProperty("dimensionType", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] [DefaultValue(TextureDimension.None)] diff --git a/README.ja.md b/README.ja.md index 2660662..bfbaccc 100644 --- a/README.ja.md +++ b/README.ja.md @@ -43,7 +43,7 @@ VGOとは、新しい形の3Dデータフォーマットです。 ### UniVGO [![UniVGO](https://img.shields.io/github/v/release/izayoijiichan/VGO?label=UniVGO)](https://github.com/izayoijiichan/VGO/releases) -![Unity](https://img.shields.io/badge/Unity-2021%7e6000-2196F3.svg?logo=unity&style=flat) +![Unity](https://img.shields.io/badge/Unity-2022%7e6000-2196F3.svg?logo=unity&style=flat) ![C#](https://img.shields.io/badge/C%23-9.0-058E0C.svg?logo=csharp&style=flat) VGOファイルを生成/出力/取り込み/ロードするためのツールです。 @@ -88,7 +88,7 @@ VGOファイルをアセット内に配置するだけで簡単に取り込み [Wiki](https://github.com/izayoijiichan/VGO/wiki) ___ -最終更新日:2024年10月1日 +最終更新日:2024年11月4日 編集者:十六夜おじいちゃん *Copyright (C) 2020 Izayoi Jiichan. All Rights Reserved.* diff --git a/README.md b/README.md index 379d81b..80eebb3 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ VGO is a new type of 3D data format. ### UniVGO [![UniVGO](https://img.shields.io/github/v/release/izayoijiichan/VGO?label=UniVGO)](https://github.com/izayoijiichan/VGO/releases) -![Unity](https://img.shields.io/badge/Unity-2021%7e6000-2196F3.svg?logo=unity&style=flat) +![Unity](https://img.shields.io/badge/Unity-2022%7e6000-2196F3.svg?logo=unity&style=flat) ![C#](https://img.shields.io/badge/C%23-9.0-058E0C.svg?logo=csharp&style=flat) A tool for creating\/exporting\/importing\/loading VGO file. @@ -88,7 +88,7 @@ You can easily run-time load a VGO file by writing a few scripts. [Wiki](https://github.com/izayoijiichan/VGO/wiki) ___ -Last updated: 1 October, 2024 +Last updated: 4 November, 2024 Editor: Izayoi Jiichan *Copyright (C) 2020 Izayoi Jiichan. All Rights Reserved.* diff --git a/UniVgo2/Editor/Menubar/VgoMenu.cs b/UniVgo2/Editor/Menubar/VgoMenu.cs index fbd3d9b..ea2ce9e 100644 --- a/UniVgo2/Editor/Menubar/VgoMenu.cs +++ b/UniVgo2/Editor/Menubar/VgoMenu.cs @@ -94,6 +94,10 @@ public static void VersionMenu() sb.Append(", ").Append("IZAYOI_LILTOON_SHADER_UTILITY_1_7_OR_NEWER"); #endif +#if IZAYOI_NOVA_SHADER_UTILITY_2_4_OR_NEWER + sb.Append(", ").Append("IZAYOI_NOVA_SHADER_UTILITY_2_4_OR_NEWER"); +#endif + #if IZAYOI_UNISHADERS_1_0_OR_NEWER sb.Append(", ").Append("IZAYOI_UNISHADERS_1_0_OR_NEWER"); #elif IZAYOI_UNISHADERS_1_1 @@ -150,6 +154,30 @@ public static void VersionMenu() sb.Append(", ").Append("LILTOON_1_7_0_OR_NEWER"); #endif +#if NOVA_SHADER_2_4_OR_NEWER + sb.Append(", ").Append("NOVA_SHADER_2_4_OR_NEWER"); +#elif NOVA_SHADER_2_3_OR_NEWER + sb.Append(", ").Append("NOVA_SHADER_2_3_OR_NEWER"); +#elif NOVA_SHADER_2_2_OR_NEWER + sb.Append(", ").Append("NOVA_SHADER_2_2_OR_NEWER"); +#elif NOVA_SHADER_2_1_OR_NEWER + sb.Append(", ").Append("NOVA_SHADER_2_1_OR_NEWER"); +#elif NOVA_SHADER_2_0_OR_NEWER + sb.Append(", ").Append("NOVA_SHADER_2_0_OR_NEWER"); +#elif NOVA_SHADER_1_5_OR_NEWER + sb.Append(", ").Append("NOVA_SHADER_1_5_OR_NEWER"); +#elif NOVA_SHADER_1_4_OR_NEWER + sb.Append(", ").Append("NOVA_SHADER_1_4_OR_NEWER"); +#elif NOVA_SHADER_1_3_OR_NEWER + sb.Append(", ").Append("NOVA_SHADER_1_3_OR_NEWER"); +#elif NOVA_SHADER_1_2_OR_NEWER + sb.Append(", ").Append("NOVA_SHADER_1_2_OR_NEWER"); +#elif NOVA_SHADER_1_1_OR_NEWER + sb.Append(", ").Append("NOVA_SHADER_1_1_OR_NEWER"); +#elif NOVA_SHADER_1_0_OR_NEWER + sb.Append(", ").Append("NOVA_SHADER_1_0_OR_NEWER"); +#endif + #if CYSHARP_UNITASK_2_OR_NEWER sb.Append(", ").Append("CYSHARP_UNITASK_2_OR_NEWER"); #endif diff --git a/UniVgo2/Editor/ScriptedImporters/VgoScriptedImporter.cs b/UniVgo2/Editor/ScriptedImporters/VgoScriptedImporter.cs index f3f0021..deb89ae 100644 --- a/UniVgo2/Editor/ScriptedImporters/VgoScriptedImporter.cs +++ b/UniVgo2/Editor/ScriptedImporters/VgoScriptedImporter.cs @@ -206,11 +206,11 @@ public override void OnImportAsset(AssetImportContext ctx) } // Texture - if (modelAsset.Texture2dList != null) + if (modelAsset.TextureList != null) { Dictionary externalObjects = GetExternalUnityObjects(); - foreach (Texture2D? texture in modelAsset.Texture2dList) + foreach (Texture2D? texture in modelAsset.TextureList) { if (texture == null) { @@ -538,8 +538,8 @@ public virtual void ExtractTextures(in string dirName, bool continueMaterial = f if (modelAsset.Layout != null && modelAsset.Layout.textures != null && modelAsset.Layout.textures.Any() && - modelAsset.Texture2dList != null && - modelAsset.Texture2dList.Any()) + modelAsset.TextureList != null && + modelAsset.TextureList.Any()) { for (int textureIndex = 0; textureIndex < modelAsset.Layout.textures.Count; textureIndex++) { @@ -550,9 +550,9 @@ public virtual void ExtractTextures(in string dirName, bool continueMaterial = f continue; } - Texture2D? texture2d = modelAsset.Texture2dList[textureIndex]; + Texture? texture = modelAsset.TextureList[textureIndex]; - if (texture2d == null) + if (!(texture is Texture2D texture2d)) { continue; } diff --git a/UniVgo2/Editor/UniVgo2.Editor.asmdef b/UniVgo2/Editor/UniVgo2.Editor.asmdef index f95cc93..d2adf1b 100644 --- a/UniVgo2/Editor/UniVgo2.Editor.asmdef +++ b/UniVgo2/Editor/UniVgo2.Editor.asmdef @@ -43,6 +43,11 @@ "expression": "[1.7,1.8)", "define": "IZAYOI_LILTOON_SHADER_UTILITY_1_7_OR_NEWER" }, + { + "name": "com.izayoi.nova.shader.utility", + "expression": "2.4", + "define": "IZAYOI_NOVA_SHADER_UTILITY_2_4_OR_NEWER" + }, { "name": "com.izayoi.unishaders", "expression": "[1.0.0,1.0.1]", @@ -123,6 +128,61 @@ "expression": "[0.104,0.124.2]", "define": "VRMC_VRMSHADERS_0_104_OR_NEWER" }, + { + "name": "jp.co.cyberagent.nova", + "expression": "[1.0,2.0)", + "define": "NOVA_SHADER_1_0_OR_NEWER" + }, + { + "name": "jp.co.cyberagent.nova", + "expression": "[1.1,2.0)", + "define": "NOVA_SHADER_1_1_OR_NEWER" + }, + { + "name": "jp.co.cyberagent.nova", + "expression": "[1.2,2.0)", + "define": "NOVA_SHADER_1_2_OR_NEWER" + }, + { + "name": "jp.co.cyberagent.nova", + "expression": "[1.3,2.0)", + "define": "NOVA_SHADER_1_3_OR_NEWER" + }, + { + "name": "jp.co.cyberagent.nova", + "expression": "[1.4,2.0)", + "define": "NOVA_SHADER_1_4_OR_NEWER" + }, + { + "name": "jp.co.cyberagent.nova", + "expression": "[1.5,2.0)", + "define": "NOVA_SHADER_1_5_OR_NEWER" + }, + { + "name": "jp.co.cyberagent.nova", + "expression": "2.0", + "define": "NOVA_SHADER_2_0_OR_NEWER" + }, + { + "name": "jp.co.cyberagent.nova", + "expression": "2.1", + "define": "NOVA_SHADER_2_1_OR_NEWER" + }, + { + "name": "jp.co.cyberagent.nova", + "expression": "2.2", + "define": "NOVA_SHADER_2_2_OR_NEWER" + }, + { + "name": "jp.co.cyberagent.nova", + "expression": "2.3", + "define": "NOVA_SHADER_2_3_OR_NEWER" + }, + { + "name": "jp.co.cyberagent.nova", + "expression": "2.4", + "define": "NOVA_SHADER_2_4_OR_NEWER" + }, { "name": "jp.lilxyzw.liltoon", "expression": "[1.2.0,1.2.12]", diff --git a/UniVgo2/README.md b/UniVgo2/README.md index 521120c..b3b7036 100644 --- a/UniVgo2/README.md +++ b/UniVgo2/README.md @@ -40,6 +40,7 @@ ___ |com.unity.nuget.newtonsoft-json|Unity Technologies|NuGet|[link](https://docs.unity3d.com/Packages/com.unity.nuget.newtonsoft-json@3.0)| |com.vrmc.vrmshaders|vrm-c|GitHub|[link](https://github.com/vrm-c/UniVRM/tree/master/Assets/VRMShaders)| |com.izayoi.liltoon.shader.utility|IzayoiJiichan|GitHub|[link](https://github.com/izayoijiichan/lilToonShaderUtility.git)| +|com.izayoi.nova.shader.utility|IzayoiJiichan|GitHub|[link](https://github.com/izayoijiichan/NovaShaderUtility.git)| |com.izayoi.unishaders|IzayoiJiichan|GitHub|[link](https://github.com/izayoijiichan/UniShaders.git)| |com.izayoi.vgospringbone|IzayoiJiichan|GitHub|[link](https://github.com/izayoijiichan/VgoSpringBone.git)| @@ -61,7 +62,7 @@ and other related people. I would like to take this opportunity to thank you. ___ -Last updated: 24 August, 2023 +Last updated: 4 November, 2024 Editor: Izayoi Jiichan *Copyright (C) 2020 Izayoi Jiichan. All Rights Reserved.* diff --git a/UniVgo2/Runtime/Converters/Textures/ITextureConverter.cs b/UniVgo2/Runtime/Converters/Textures/ITextureConverter.cs index b63acd1..3b163c1 100644 --- a/UniVgo2/Runtime/Converters/Textures/ITextureConverter.cs +++ b/UniVgo2/Runtime/Converters/Textures/ITextureConverter.cs @@ -23,9 +23,9 @@ public interface ITextureConverter /// The metallic roughness. /// #if UNITY_2021_2_OR_NEWER - Texture2D GetImportTexture(in Texture2D source, in VgoTextureMapType textureMapType, in float metallicRoughness = -1.0f); + Texture GetImportTexture(in Texture source, in VgoTextureMapType textureMapType, in float metallicRoughness = -1.0f); #else - Texture2D GetImportTexture(in Texture2D source, in VgoTextureMapType textureMapType, float metallicRoughness = -1.0f); + Texture GetImportTexture(in Texture source, in VgoTextureMapType textureMapType, float metallicRoughness = -1.0f); #endif /// @@ -37,9 +37,9 @@ public interface ITextureConverter /// The metallic smoothness. /// #if UNITY_2021_2_OR_NEWER - Texture2D GetExportTexture(in Texture2D source, in VgoTextureMapType textureMapType, in VgoColorSpaceType colorSpaceType, in float metallicSmoothness = -1.0f); + Texture GetExportTexture(in Texture source, in VgoTextureMapType textureMapType, in VgoColorSpaceType colorSpaceType, in float metallicSmoothness = -1.0f); #else - Texture2D GetExportTexture(in Texture2D source, in VgoTextureMapType textureMapType, in VgoColorSpaceType colorSpaceType, float metallicSmoothness = -1.0f); + Texture GetExportTexture(in Texture source, in VgoTextureMapType textureMapType, in VgoColorSpaceType colorSpaceType, float metallicSmoothness = -1.0f); #endif #endregion diff --git a/UniVgo2/Runtime/Converters/Textures/NormalMapConverter.cs b/UniVgo2/Runtime/Converters/Textures/NormalMapConverter.cs index c917875..28d8b88 100644 --- a/UniVgo2/Runtime/Converters/Textures/NormalMapConverter.cs +++ b/UniVgo2/Runtime/Converters/Textures/NormalMapConverter.cs @@ -47,8 +47,9 @@ public class NormalMapConverter : TextureConverterBase /// Get import texture. /// /// The source texture. + /// /// - public Texture2D GetImportTexture(in Texture2D source) + public Texture GetImportTexture(in Texture source, in VgoColorSpaceType colorSpaceType) { if (Encoder == null) { @@ -57,7 +58,7 @@ public Texture2D GetImportTexture(in Texture2D source) var converter = new Material(Encoder); - Texture2D copyTexture = CopyTexture2d(source, VgoColorSpaceType.Linear, converter); + Texture copyTexture = CopyTexture(source, colorSpaceType, converter); if (Application.isEditor) { @@ -75,8 +76,9 @@ public Texture2D GetImportTexture(in Texture2D source) /// Get export texture. /// /// The source texture. + /// /// - public Texture2D GetExportTexture(in Texture2D source) + public Texture GetExportTexture(in Texture source, in VgoColorSpaceType colorSpaceType) { Shader? exporter = Exporter; @@ -92,7 +94,7 @@ public Texture2D GetExportTexture(in Texture2D source) var converter = new Material(exporter); - Texture2D copyTexture = CopyTexture2d(source, VgoColorSpaceType.Linear, converter); + Texture copyTexture = CopyTexture(source, colorSpaceType, converter); if (Application.isEditor) { diff --git a/UniVgo2/Runtime/Converters/Textures/OrmMapConverter.cs b/UniVgo2/Runtime/Converters/Textures/OrmMapConverter.cs index b862767..c5d0357 100644 --- a/UniVgo2/Runtime/Converters/Textures/OrmMapConverter.cs +++ b/UniVgo2/Runtime/Converters/Textures/OrmMapConverter.cs @@ -26,26 +26,201 @@ namespace UniVgo2.Converters /// public class OrmMapConverter : TextureConverterBase { - #region Public Methods + #region Public Methods (Import) /// /// Get import texture. /// /// The source texture. + /// /// /// - public Texture2D GetImportTexture(in Texture2D texture, in float roughnessFactor) + public Texture GetImportTexture(in Texture texture, in VgoColorSpaceType colorSpaceType, in float roughnessFactor) { - Texture2D copyTexture = CopyTexture2d(texture, VgoColorSpaceType.Linear); + if (texture is Texture2D texture2D) + { + return GetImportTexture2D(texture2D, colorSpaceType, roughnessFactor); + } + else if (texture is Texture2DArray texture2DArray) + { + return GetImportTexture2DArray(texture2DArray, colorSpaceType, roughnessFactor); + } + else if (texture is Texture3D texture3D) + { + return GetImportTexture3D(texture3D, colorSpaceType, roughnessFactor); + } + else + { +#if NET_STANDARD_2_1 + ThrowHelper.ThrowNotSupportedException($"{texture.dimension}, {texture.name}"); + return default; +#else + throw new NotSupportedException($"{source.dimension}, {source.name}"); +#endif + } + } + + /// + /// Get import texture. + /// + /// The source texture. + /// + /// + /// + public Texture2D GetImportTexture2D(in Texture2D texture, in VgoColorSpaceType colorSpaceType, in float roughnessFactor) + { + Texture2D copyTexture = CopyTexture2D(texture, colorSpaceType); - Color32[] pixcels = copyTexture.GetPixels32(); + Color32[] pixels = copyTexture.GetPixels32(); - for (int i = 0; i < pixcels.Length; i++) + for (int i = 0; i < pixels.Length; i++) { - pixcels[i] = Import(pixcels[i], roughnessFactor); + pixels[i] = Import(pixels[i], roughnessFactor); } - copyTexture.SetPixels32(pixcels); + copyTexture.SetPixels32(pixels); + + copyTexture.Apply(); + + return copyTexture; + } + + /// + /// Get import texture. + /// + /// The source texture. + /// + /// + /// + public Texture2DArray GetImportTexture2DArray(in Texture2DArray texture, in VgoColorSpaceType colorSpaceType, in float roughnessFactor) + { + Texture2DArray copyTexture = CopyTexture2DArray(texture, colorSpaceType); + + for (int arrayElement = 0; arrayElement < texture.depth; arrayElement++) + { + Color32[] pixels = copyTexture.GetPixels32(arrayElement); + + for (int i = 0; i < pixels.Length; i++) + { + pixels[i] = Import(pixels[i], roughnessFactor); + } + + copyTexture.SetPixels32(pixels, arrayElement); + } + + copyTexture.Apply(); + + return copyTexture; + } + + /// + /// Get import texture. + /// + /// The source texture. + /// + /// + /// + public Texture3D GetImportTexture3D(in Texture3D texture, in VgoColorSpaceType colorSpaceType, in float roughnessFactor) + { + Texture3D copyTexture = CopyTexture3D(texture, colorSpaceType); + + Color32[] pixels = copyTexture.GetPixels32(); + + for (int i = 0; i < pixels.Length; i++) + { + pixels[i] = Import(pixels[i], roughnessFactor); + } + + copyTexture.SetPixels32(pixels); + + copyTexture.Apply(); + + return copyTexture; + } + + #endregion + + #region Public Methods (Export) + + /// + /// Get export texture. + /// + /// The source texture. + /// + /// + /// + public Texture GetExportTexture(in Texture texture, in VgoColorSpaceType colorSpaceType, in float smoothnessFactor) + { + if (texture is Texture2D texture2D) + { + return GetExportTexture2D(texture2D, colorSpaceType, smoothnessFactor); + } + else if (texture is Texture2DArray texture2DArray) + { + return GetExportTexture2DArray(texture2DArray, colorSpaceType, smoothnessFactor); + } + else if (texture is Texture3D texture3D) + { + return GetExportTexture3D(texture3D, colorSpaceType, smoothnessFactor); + } + else + { +#if NET_STANDARD_2_1 + ThrowHelper.ThrowNotSupportedException($"{texture.dimension}, {texture.name}"); + return default; +#else + throw new NotSupportedException($"{source.dimension}, {source.name}"); +#endif + } + } + + /// + /// Get export texture. + /// + /// The source texture. + /// + /// + /// + public Texture2D GetExportTexture2D(in Texture2D texture, in VgoColorSpaceType colorSpaceType, in float smoothnessFactor) + { + Texture2D copyTexture = CopyTexture2D(texture, colorSpaceType); + + Color32[] pixels = copyTexture.GetPixels32(); + + for (int i = 0; i < pixels.Length; i++) + { + pixels[i] = Export(pixels[i], smoothnessFactor); + } + + copyTexture.SetPixels32(pixels); + + copyTexture.Apply(); + + return copyTexture; + } + + /// + /// Get export texture. + /// + /// The source texture. + /// + /// + /// + public Texture2DArray GetExportTexture2DArray(in Texture2DArray texture, in VgoColorSpaceType colorSpaceType, in float smoothnessFactor) + { + Texture2DArray copyTexture = CopyTexture2DArray(texture, colorSpaceType); + + for (int arrayElement = 0; arrayElement < texture.depth; arrayElement++) + { + Color32[] pixels = copyTexture.GetPixels32(arrayElement); + + for (int i = 0; i < pixels.Length; i++) + { + pixels[i] = Export(pixels[i], smoothnessFactor); + } + + copyTexture.SetPixels32(pixels, arrayElement); + } copyTexture.Apply(); @@ -56,20 +231,21 @@ public Texture2D GetImportTexture(in Texture2D texture, in float roughnessFactor /// Get export texture. /// /// The source texture. + /// /// /// - public Texture2D GetExportTexture(in Texture2D texture, in float smoothnessFactor) + public Texture3D GetExportTexture3D(in Texture3D texture, in VgoColorSpaceType colorSpaceType, in float smoothnessFactor) { - Texture2D copyTexture = CopyTexture2d(texture, VgoColorSpaceType.Linear); + Texture3D copyTexture = CopyTexture3D(texture, colorSpaceType); - Color32[] pixcels = copyTexture.GetPixels32(); + Color32[] pixels = copyTexture.GetPixels32(); - for (int i = 0; i < pixcels.Length; i++) + for (int i = 0; i < pixels.Length; i++) { - pixcels[i] = Export(pixcels[i], smoothnessFactor); + pixels[i] = Export(pixels[i], smoothnessFactor); } - copyTexture.SetPixels32(pixcels); + copyTexture.SetPixels32(pixels); copyTexture.Apply(); diff --git a/UniVgo2/Runtime/Converters/Textures/TextureConverter.cs b/UniVgo2/Runtime/Converters/Textures/TextureConverter.cs index 6314c9b..3ad63e0 100644 --- a/UniVgo2/Runtime/Converters/Textures/TextureConverter.cs +++ b/UniVgo2/Runtime/Converters/Textures/TextureConverter.cs @@ -33,9 +33,9 @@ public class TextureConverter : TextureConverterBase, ITextureConverter /// The metallic roughness. /// #if UNITY_2021_2_OR_NEWER - public virtual Texture2D GetImportTexture(in Texture2D source, in VgoTextureMapType textureMapType, in float metallicRoughness = -1.0f) + public virtual Texture GetImportTexture(in Texture source, in VgoTextureMapType textureMapType, in float metallicRoughness = -1.0f) #else - public virtual Texture2D GetImportTexture(in Texture2D source, in VgoTextureMapType textureMapType, float metallicRoughness = -1.0f) + public virtual Texture GetImportTexture(in Texture source, in VgoTextureMapType textureMapType, float metallicRoughness = -1.0f) #endif { if (textureMapType == VgoTextureMapType.NormalMap) @@ -44,13 +44,13 @@ public virtual Texture2D GetImportTexture(in Texture2D source, in VgoTextureMapT // @notice no conversion. // Unity's normal map is same with glTF's. - return CopyTexture2d(source, VgoColorSpaceType.Linear, converter: null); + return CopyTexture(source, VgoColorSpaceType.Linear, converter: null); } else if ( (textureMapType == VgoTextureMapType.OcclusionMap) || (textureMapType == VgoTextureMapType.MetallicRoughnessMap)) { - return _OrmMapConverter.GetImportTexture(source, metallicRoughness); + return _OrmMapConverter.GetImportTexture(source, VgoColorSpaceType.Linear, metallicRoughness); } else { @@ -67,24 +67,24 @@ public virtual Texture2D GetImportTexture(in Texture2D source, in VgoTextureMapT /// The metallic smoothness. /// #if UNITY_2021_2_OR_NEWER - public virtual Texture2D GetExportTexture(in Texture2D source, in VgoTextureMapType textureMapType, in VgoColorSpaceType colorSpaceType, in float metallicSmoothness = -1.0f) + public virtual Texture GetExportTexture(in Texture source, in VgoTextureMapType textureMapType, in VgoColorSpaceType colorSpaceType, in float metallicSmoothness = -1.0f) #else - public virtual Texture2D GetExportTexture(in Texture2D source, in VgoTextureMapType textureMapType, in VgoColorSpaceType colorSpaceType, float metallicSmoothness = -1.0f) + public virtual Texture GetExportTexture(in Texture source, in VgoTextureMapType textureMapType, in VgoColorSpaceType colorSpaceType, float metallicSmoothness = -1.0f) #endif { if (textureMapType == VgoTextureMapType.NormalMap) { - return _NormalMapConverter.GetExportTexture(source); + return _NormalMapConverter.GetExportTexture(source, colorSpaceType); } else if ( (textureMapType == VgoTextureMapType.OcclusionMap) || (textureMapType == VgoTextureMapType.MetallicRoughnessMap)) { - return _OrmMapConverter.GetExportTexture(source, metallicSmoothness); + return _OrmMapConverter.GetExportTexture(source, colorSpaceType, metallicSmoothness); } else { - return CopyTexture2d(source, colorSpaceType); + return CopyTexture(source, colorSpaceType); } } diff --git a/UniVgo2/Runtime/Converters/Textures/TextureConverterBase.cs b/UniVgo2/Runtime/Converters/Textures/TextureConverterBase.cs index 1e17d3b..43d01f7 100644 --- a/UniVgo2/Runtime/Converters/Textures/TextureConverterBase.cs +++ b/UniVgo2/Runtime/Converters/Textures/TextureConverterBase.cs @@ -15,6 +15,38 @@ public abstract class TextureConverterBase { #region Protected Methods + /// + /// Copy Texture. + /// + /// The source texture. + /// The color space type. + /// The converter. + /// The copied Texture. + protected virtual Texture CopyTexture(in Texture source, in VgoColorSpaceType colorSpaceType, in Material? converter = null) + { + if (source is Texture2D texture2D) + { + return CopyTexture2D(texture2D, colorSpaceType, converter); + } + else if (source is Texture2DArray texture2DArray) + { + return CopyTexture2DArray(texture2DArray, colorSpaceType, converter); + } + else if (source is Texture3D texture3D) + { + return CopyTexture3D(texture3D, colorSpaceType, converter); + } + else + { +#if NET_STANDARD_2_1 + ThrowHelper.ThrowNotSupportedException($"{source.dimension}, {source.name}"); + return default; +#else + throw new NotSupportedException($"{source.dimension}, {source.name}"); +#endif + } + } + /// /// Copy Texture2D. /// @@ -22,7 +54,7 @@ public abstract class TextureConverterBase /// The color space type. /// The converter. /// The copied Texture2D. - protected virtual Texture2D CopyTexture2d(in Texture2D source, in VgoColorSpaceType colorSpaceType, in Material? converter = null) + protected virtual Texture2D CopyTexture2D(in Texture2D source, in VgoColorSpaceType colorSpaceType, in Material? converter = null) { RenderTextureReadWrite readWrite = (colorSpaceType == VgoColorSpaceType.Linear) ? RenderTextureReadWrite.Linear @@ -42,7 +74,7 @@ protected virtual Texture2D CopyTexture2d(in Texture2D source, in VgoColorSpaceT } } - Texture2D dest = new Texture2D(source.width, source.height, TextureFormat.ARGB32, mipChain: false, linear: (readWrite == RenderTextureReadWrite.Linear)); + var dest = new Texture2D(source.width, source.height, TextureFormat.ARGB32, mipChain: false, linear: (readWrite == RenderTextureReadWrite.Linear)); dest.ReadPixels(new Rect(x: 0, y: 0, source.width, source.height), destX: 0, destY: 0, recalculateMipMaps: false); @@ -71,6 +103,125 @@ protected virtual Texture2D CopyTexture2d(in Texture2D source, in VgoColorSpaceT return dest; } + /// + /// Copy Texture2DArray. + /// + /// The source texture. + /// The color space type. + /// The converter. + /// The copied Texture2DArray. + protected virtual Texture2DArray CopyTexture2DArray(in Texture2DArray source, in VgoColorSpaceType colorSpaceType, in Material? converter = null) + { + RenderTextureReadWrite readWrite = (colorSpaceType == VgoColorSpaceType.Linear) + ? RenderTextureReadWrite.Linear + : RenderTextureReadWrite.sRGB; + + var renderTexture = new RenderTexture(source.width, source.height, depth: source.depth, RenderTextureFormat.ARGB32, readWrite); + + using (var scope = new ColorSpaceScope(readWrite)) + { + if (converter == null) + { + Graphics.Blit(source, renderTexture); + } + else + { + Graphics.Blit(source, renderTexture, converter); + } + } + + var dest = new Texture2DArray(source.width, source.height, source.depth, TextureFormat.ARGB32, mipChain: false); + + for (int arrayElement = 0; arrayElement < source.depth; arrayElement++) + { + Color32[] pixels = source.GetPixels32(arrayElement); + + dest.SetPixels32(pixels, arrayElement); + } + + dest.name = source.name; + dest.anisoLevel = source.anisoLevel; + dest.filterMode = source.filterMode; + dest.mipMapBias = source.mipMapBias; + dest.wrapMode = source.wrapMode; + dest.wrapModeU = source.wrapModeU; + dest.wrapModeV = source.wrapModeV; + dest.wrapModeW = source.wrapModeW; + + dest.Apply(); + + RenderTexture.active = null; + + if (Application.isEditor) + { + UnityEngine.Object.DestroyImmediate(renderTexture); + } + else + { + UnityEngine.Object.Destroy(renderTexture); + } + + return dest; + } + + /// + /// Copy Texture3D. + /// + /// The source texture. + /// The color space type. + /// The converter. + /// The copied Texture3D. + protected virtual Texture3D CopyTexture3D(in Texture3D source, in VgoColorSpaceType colorSpaceType, in Material? converter = null) + { + RenderTextureReadWrite readWrite = (colorSpaceType == VgoColorSpaceType.Linear) + ? RenderTextureReadWrite.Linear + : RenderTextureReadWrite.sRGB; + + var renderTexture = new RenderTexture(source.width, source.height, depth: source.depth, RenderTextureFormat.ARGB32, readWrite); + + using (var scope = new ColorSpaceScope(readWrite)) + { + if (converter == null) + { + Graphics.Blit(source, renderTexture); + } + else + { + Graphics.Blit(source, renderTexture, converter); + } + } + + var dest = new Texture3D(source.width, source.height, source.depth, TextureFormat.ARGB32, mipChain: false); + + Color32[] pixels = source.GetPixels32(); + + dest.SetPixels32(pixels); + + dest.name = source.name; + dest.anisoLevel = source.anisoLevel; + dest.filterMode = source.filterMode; + dest.mipMapBias = source.mipMapBias; + dest.wrapMode = source.wrapMode; + dest.wrapModeU = source.wrapModeU; + dest.wrapModeV = source.wrapModeV; + dest.wrapModeW = source.wrapModeW; + + dest.Apply(); + + RenderTexture.active = null; + + if (Application.isEditor) + { + UnityEngine.Object.DestroyImmediate(renderTexture); + } + else + { + UnityEngine.Object.Destroy(renderTexture); + } + + return dest; + } + #endregion } } diff --git a/UniVgo2/Runtime/Converters/VgoParticleSystemCustomDataConverter.cs b/UniVgo2/Runtime/Converters/VgoParticleSystemCustomDataConverter.cs new file mode 100644 index 0000000..a8915d7 --- /dev/null +++ b/UniVgo2/Runtime/Converters/VgoParticleSystemCustomDataConverter.cs @@ -0,0 +1,84 @@ +// ---------------------------------------------------------------------- +// @Namespace : UniVgo2.Converters +// @Class : VgoParticleSystemCustomDataConverter +// ---------------------------------------------------------------------- +#nullable enable +namespace UniVgo2.Converters +{ + using NewtonVgo.Schema.ParticleSystems; + using static UnityEngine.ParticleSystem; + + /// + /// VGO ParticleSystem CustomData Converter + /// + public class VgoParticleSystemCustomDataConverter + { + /// + /// Create VGO_PS_CustomDataModule from CustomDataModule. + /// + /// + /// + public static VGO_PS_CustomDataModule CreateFrom(in CustomDataModule customDataModule) + { + VGO_PS_CustomData vgoCustomData1 = CreateFrom(customDataModule, UnityEngine.ParticleSystemCustomData.Custom1); + VGO_PS_CustomData vgoCustomData2 = CreateFrom(customDataModule, UnityEngine.ParticleSystemCustomData.Custom2); + + return new VGO_PS_CustomDataModule() + { + enabled = customDataModule.enabled, + customData = new VGO_PS_CustomData[] + { + vgoCustomData1, + vgoCustomData2, + }, + }; + } + + /// + /// Create VGO_PS_CustomData from CustomDataModule. + /// + /// + /// + /// + protected static VGO_PS_CustomData CreateFrom(in CustomDataModule customDataModule, UnityEngine.ParticleSystemCustomData stream) + { + UnityEngine.ParticleSystemCustomDataMode mode = customDataModule.GetMode(stream); + + var customData = new VGO_PS_CustomData() + { + stream = (NewtonVgo.ParticleSystemCustomData)stream, + mode = (NewtonVgo.ParticleSystemCustomDataMode)mode, + }; + + if (mode == UnityEngine.ParticleSystemCustomDataMode.Vector) + { + int vectorComponentCount = customDataModule.GetVectorComponentCount(stream); + + if (vectorComponentCount > 0) + { + customData.vector = new VGO_PS_MinMaxCurve[vectorComponentCount]; + + // X, Y, Z, W + for (int componentIndex = 0; componentIndex < vectorComponentCount; componentIndex++) + { + MinMaxCurve componentCurve = customDataModule.GetVector(stream, componentIndex); + + VGO_PS_MinMaxCurve vgoComponentCurve = VgoParticleSystemMinMaxCurveConverter.CreateFrom(componentCurve); + + customData.vector[componentIndex] = vgoComponentCurve; + } + } + } + else if (mode == UnityEngine.ParticleSystemCustomDataMode.Color) + { + MinMaxGradient colorGradient = customDataModule.GetColor(stream); + + VGO_PS_MinMaxGradient vgoColorGradient = VgoParticleSystemMinMaxGradientConverter.CreateFrom(colorGradient); + + customData.color = vgoColorGradient; + } + + return customData; + } + } +} \ No newline at end of file diff --git a/UniVgo2/Runtime/Converters/VgoParticleSystemCustomDataConverter.cs.meta b/UniVgo2/Runtime/Converters/VgoParticleSystemCustomDataConverter.cs.meta new file mode 100644 index 0000000..21f8240 --- /dev/null +++ b/UniVgo2/Runtime/Converters/VgoParticleSystemCustomDataConverter.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: f62aa0927718cb046acdc6a8f0666cb5 \ No newline at end of file diff --git a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialMToon0xDefinitionExtensions.cs b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialMToon0xDefinitionExtensions.cs index 6d865c5..3d7dfc1 100644 --- a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialMToon0xDefinitionExtensions.cs +++ b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialMToon0xDefinitionExtensions.cs @@ -20,9 +20,9 @@ public static class VgoMaterialMToon0xDefinitionExtensions /// Convert vgo material to MToon 0x definition. /// /// A vgo material. - /// List of all texture 2D. + /// List of all texture. /// A MToon 0x definition. - public static MToonDefinition ToMToon0xDefinition(this VgoMaterial vgoMaterial, in List allTexture2dList) + public static MToonDefinition ToMToon0xDefinition(this VgoMaterial vgoMaterial, in List allTextureList) { if (vgoMaterial.shaderName != ShaderName.VRM_MToon) { @@ -50,9 +50,9 @@ public static MToonDefinition ToMToon0xDefinition(this VgoMaterial vgoMaterial, mtoonDefinition.Color = new ColorDefinition { LitColor = vgoMaterial.GetColorOrDefault(MToon.Utils.PropColor, Color.white).gamma, - LitMultiplyTexture = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropMainTex)), + LitMultiplyTexture = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropMainTex)) as Texture2D, ShadeColor = vgoMaterial.GetColorOrDefault(MToon.Utils.PropShadeColor, Color.black).gamma, - ShadeMultiplyTexture = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropShadeTexture)), + ShadeMultiplyTexture = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropShadeTexture)) as Texture2D, CutoutThresholdValue = vgoMaterial.GetSafeFloat(MToon.Utils.PropCutoff, 0.0f, 1.0f, 0.5f), }; @@ -65,9 +65,9 @@ public static MToonDefinition ToMToon0xDefinition(this VgoMaterial vgoMaterial, ShadingShiftValue = vgoMaterial.GetSafeFloat(MToon.Utils.PropShadeShift, -1.0f, 1.0f, 0.0f), ShadingToonyValue = vgoMaterial.GetSafeFloat(MToon.Utils.PropShadeToony, 0.0f, 1.0f, 0.9f), ShadowReceiveMultiplierValue = vgoMaterial.GetSafeFloat(MToon.Utils.PropReceiveShadowRate, 0.0f, 1.0f, 1.0f), - ShadowReceiveMultiplierMultiplyTexture = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropReceiveShadowTexture)), + ShadowReceiveMultiplierMultiplyTexture = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropReceiveShadowTexture)) as Texture2D, LitAndShadeMixingMultiplierValue = vgoMaterial.GetSafeFloat(MToon.Utils.PropShadingGradeRate, 0.0f, 1.0f, 1.0f), - LitAndShadeMixingMultiplierMultiplyTexture = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropShadingGradeTexture)), + LitAndShadeMixingMultiplierMultiplyTexture = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropShadingGradeTexture)) as Texture2D, }; // LightingInfluence @@ -80,7 +80,7 @@ public static MToonDefinition ToMToon0xDefinition(this VgoMaterial vgoMaterial, // Normal mtoonDefinition.Lighting.Normal = new NormalDefinition { - NormalTexture = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropBumpMap)), + NormalTexture = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropBumpMap)) as Texture2D, NormalScaleValue = vgoMaterial.GetSafeFloat(MToon.Utils.PropBumpScale, 0.0f, float.MaxValue, 1.0f), }; @@ -88,20 +88,20 @@ public static MToonDefinition ToMToon0xDefinition(this VgoMaterial vgoMaterial, mtoonDefinition.Emission = new EmissionDefinition { EmissionColor = vgoMaterial.GetColorOrDefault(MToon.Utils.PropEmissionColor, Color.black).gamma, - EmissionMultiplyTexture = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropEmissionMap)), + EmissionMultiplyTexture = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropEmissionMap)) as Texture2D, }; // MatCap mtoonDefinition.MatCap = new MatCapDefinition { - AdditiveTexture = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropSphereAdd)), + AdditiveTexture = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropSphereAdd)) as Texture2D, }; // Rim mtoonDefinition.Rim = new RimDefinition() { RimColor = vgoMaterial.GetColorOrDefault(MToon.Utils.PropRimColor, Color.black).gamma, - RimMultiplyTexture = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropRimTexture)), + RimMultiplyTexture = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropRimTexture)) as Texture2D, RimLightingMixValue = vgoMaterial.GetSafeFloat(MToon.Utils.PropRimLightingMix, 0.0f, 1.0f, 0.0f), RimFresnelPowerValue = vgoMaterial.GetSafeFloat(MToon.Utils.PropRimFresnelPower, 0.0f, 100.0f, 1.0f), RimLiftValue = vgoMaterial.GetSafeFloat(MToon.Utils.PropRimLift, 0.0f, 1.0f, 0.0f), @@ -112,7 +112,7 @@ public static MToonDefinition ToMToon0xDefinition(this VgoMaterial vgoMaterial, { OutlineWidthMode = vgoMaterial.GetEnumOrDefault(MToon.Utils.PropOutlineWidthMode, MToon.OutlineWidthMode.None), OutlineWidthValue = vgoMaterial.GetSafeFloat(MToon.Utils.PropOutlineWidth, 0.0f, 1.0f, 0.5f), - OutlineWidthMultiplyTexture = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropOutlineWidthTexture)), + OutlineWidthMultiplyTexture = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropOutlineWidthTexture)) as Texture2D, OutlineScaledMaxDistanceValue = vgoMaterial.GetSafeFloat(MToon.Utils.PropOutlineScaledMaxDistance, 1.0f, 10.0f, 1.0f), OutlineColorMode = vgoMaterial.GetEnumOrDefault(MToon.Utils.PropOutlineColorMode, MToon.OutlineColorMode.FixedColor), OutlineColor = vgoMaterial.GetColorOrDefault(MToon.Utils.PropOutlineColor, Color.black).gamma, @@ -124,7 +124,7 @@ public static MToonDefinition ToMToon0xDefinition(this VgoMaterial vgoMaterial, { MainTextureLeftBottomOriginScale = vgoMaterial.GetVector2OrDefault(MToon.Utils.PropMainTex, Vector2.one), MainTextureLeftBottomOriginOffset = vgoMaterial.GetVector2OrDefault(MToon.Utils.PropMainTex, Vector2.zero), - UvAnimationMaskTexture = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropUvAnimMaskTexture)), + UvAnimationMaskTexture = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(MToon.Utils.PropUvAnimMaskTexture)) as Texture2D, UvAnimationScrollXSpeedValue = vgoMaterial.GetSafeFloat(MToon.Utils.PropUvAnimScrollX, 0.0f, float.MaxValue, 0.0f), UvAnimationScrollYSpeedValue = vgoMaterial.GetSafeFloat(MToon.Utils.PropUvAnimScrollY, 0.0f, float.MaxValue, 0.0f), UvAnimationRotationSpeedValue = vgoMaterial.GetSafeFloat(MToon.Utils.PropUvAnimRotation, 0.0f, float.MaxValue, 0.0f), diff --git a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialMToon10DefinitionExtensions.cs b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialMToon10DefinitionExtensions.cs index 307bab7..fc30abe 100644 --- a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialMToon10DefinitionExtensions.cs +++ b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialMToon10DefinitionExtensions.cs @@ -24,9 +24,9 @@ public static class VgoMaterialMToon10DefinitionExtensions /// Convert vgo material to MToon 1.0 definition. /// /// A vgo material. - /// List of all texture 2D. + /// List of all texture. /// A MToon 1.0 definition. - public static MToon10Definition ToMToon10Definition(this VgoMaterial vgoMaterial, in List allTexture2dList) + public static MToon10Definition ToMToon10Definition(this VgoMaterial vgoMaterial, in List allTextureList) { if ((vgoMaterial.shaderName != ShaderName.VRM_MToon10) && (vgoMaterial.shaderName != ShaderName.VRM_URP_MToon10)) @@ -45,15 +45,15 @@ public static MToon10Definition ToMToon10Definition(this VgoMaterial vgoMaterial // Color BaseColorFactor = vgoMaterial.GetColorOrDefault(MToon10Prop.BaseColorFactor, Color.white).gamma, - BaseColorTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.BaseColorTexture, allTexture2dList), + BaseColorTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.BaseColorTexture, allTextureList) as Texture2D, BaseColorTextureScale = vgoMaterial.GetTextureScaleOrDefault(MToon10Prop.BaseColorTexture, Vector2.one), BaseColorTextureOffset = vgoMaterial.GetTextureOffsetOrDefault(MToon10Prop.BaseColorTexture, Vector2.zero), ShadeColorFactor = vgoMaterial.GetColorOrDefault(MToon10Prop.ShadeColorFactor, Color.white).gamma, - ShadeColorTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.ShadeColorTexture, allTexture2dList), - NormalTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.NormalTexture, allTexture2dList), + ShadeColorTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.ShadeColorTexture, allTextureList) as Texture2D, + NormalTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.NormalTexture, allTextureList) as Texture2D, NormalTextureScale = vgoMaterial.GetSafeFloat(MToon10Prop.NormalTextureScale, 0.0f, float.MaxValue, 1.0f), ShadingShiftFactor = vgoMaterial.GetSafeFloat(MToon10Prop.ShadingShiftFactor, -1.0f, 1.0f, -0.05f), - ShadingShiftTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.ShadingShiftTexture, allTexture2dList), + ShadingShiftTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.ShadingShiftTexture, allTextureList) as Texture2D, ShadingShiftTextureScale = vgoMaterial.GetSafeFloat(MToon10Prop.ShadingShiftTextureScale, 0.0f, float.MaxValue, 1.0f), ShadingToonyFactor = vgoMaterial.GetSafeFloat(MToon10Prop.ShadingToonyFactor, 0.0f, 1.0f, 0.95f), @@ -62,28 +62,28 @@ public static MToon10Definition ToMToon10Definition(this VgoMaterial vgoMaterial // Emission EmissiveFactor = vgoMaterial.GetColorOrDefault(MToon10Prop.EmissiveFactor, Color.black).gamma, - EmissiveTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.EmissiveTexture, allTexture2dList), + EmissiveTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.EmissiveTexture, allTextureList) as Texture2D, // Rim Lighting #if VRMC_VRMSHADERS_0_104_OR_NEWER MatcapColorFactor = vgoMaterial.GetColorOrDefault(MToon10Prop.MatcapColorFactor, Color.black).gamma, #endif - MatcapTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.MatcapTexture, allTexture2dList), + MatcapTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.MatcapTexture, allTextureList) as Texture2D, ParametricRimColorFactor = vgoMaterial.GetColorOrDefault(MToon10Prop.ParametricRimColorFactor, Color.black).gamma, ParametricRimFresnelPowerFactor = vgoMaterial.GetSafeFloat(MToon10Prop.ParametricRimFresnelPowerFactor, 0.0f, 100.0f, 5.0f), ParametricRimLiftFactor = vgoMaterial.GetSafeFloat(MToon10Prop.ParametricRimLiftFactor, 0.0f, 1.0f), - RimMultiplyTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.RimMultiplyTexture, allTexture2dList), + RimMultiplyTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.RimMultiplyTexture, allTextureList) as Texture2D, RimLightingMixFactor = vgoMaterial.GetSafeFloat(MToon10Prop.RimLightingMixFactor, 0.0f, 1.0f, 1.0f), // Outline OutlineWidthMode = vgoMaterial.GetEnumOrDefault(MToon10Prop.OutlineWidthMode, MToon10OutlineMode.None), OutlineWidthFactor = vgoMaterial.GetSafeFloat(MToon10Prop.OutlineWidthFactor, 0.0f, 0.05f), - OutlineWidthMultiplyTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.OutlineWidthMultiplyTexture, allTexture2dList), + OutlineWidthMultiplyTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.OutlineWidthMultiplyTexture, allTextureList) as Texture2D, OutlineColorFactor = vgoMaterial.GetColorOrDefault(MToon10Prop.OutlineColorFactor, Color.black).gamma, OutlineLightingMixFactor = vgoMaterial.GetSafeFloat(MToon10Prop.OutlineLightingMixFactor, 0.0f, 1.0f, 1.0f), // UV Animation - UvAnimationMaskTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.UvAnimationMaskTexture, allTexture2dList), + UvAnimationMaskTexture = vgoMaterial.GetTextureOrDefault(MToon10Prop.UvAnimationMaskTexture, allTextureList) as Texture2D, UvAnimationScrollXSpeedFactor = vgoMaterial.GetSafeFloat(MToon10Prop.UvAnimationScrollXSpeedFactor, 0.0f, float.MaxValue, 0.0f), UvAnimationScrollYSpeedFactor = vgoMaterial.GetSafeFloat(MToon10Prop.UvAnimationScrollYSpeedFactor, 0.0f, float.MaxValue, 0.0f), UvAnimationRotationSpeedFactor = vgoMaterial.GetSafeFloat(MToon10Prop.UvAnimationRotationSpeedFactor, 0.0f, float.MaxValue, 0.0f), @@ -166,19 +166,19 @@ private static Color GetColorOrDefault(this VgoMaterial self, in MToon10Prop pro /// /// A vgo material. /// A material property. - /// List of all texture 2D. + /// List of all texture. /// - private static Texture2D? GetTextureOrDefault(this VgoMaterial self, in MToon10Prop property, in List allTexture2dList) + private static Texture? GetTextureOrDefault(this VgoMaterial self, in MToon10Prop property, in List allTextureList) { string propertyName = property.ToUnityShaderLabName(); - Texture2D? texture = null; + Texture? texture = null; int textureIndex = self.GetTextureIndexOrDefault(propertyName); if (textureIndex >= 0) { - texture = allTexture2dList.GetNullableValueOrDefault(textureIndex); + texture = allTextureList.GetNullableValueOrDefault(textureIndex); } return texture; diff --git a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialSkyboxDefinitionExtensions.cs b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialSkyboxDefinitionExtensions.cs index dbc9a6b..5d66994 100644 --- a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialSkyboxDefinitionExtensions.cs +++ b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialSkyboxDefinitionExtensions.cs @@ -19,9 +19,9 @@ public static class VgoMaterialSkyboxDefinitionExtensions /// Convert vgo material to skybox 6 sided definition. /// /// A vgo material. - /// List of all texture 2D. + /// List of all texture. /// A skybox 6 sided definition. - public static Skybox6SidedDefinition ToSkybox6SidedDefinition(this VgoMaterial vgoMaterial, in List allTexture2dList) + public static Skybox6SidedDefinition ToSkybox6SidedDefinition(this VgoMaterial vgoMaterial, in List allTextureList) { if (vgoMaterial.shaderName != ShaderName.Skybox_6_Sided) { @@ -33,12 +33,12 @@ public static Skybox6SidedDefinition ToSkybox6SidedDefinition(this VgoMaterial v Tint = vgoMaterial.GetColorOrDefault(Property.Tint, Color.white).gamma, Exposure = vgoMaterial.GetSafeFloat(Property.Exposure, PropertyRange.Exposure), Rotation = vgoMaterial.GetSafeInt(Property.Rotation, PropertyRange.Rotation), - FrontTex = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.FrontTex)), - BackTex = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.BackTex)), - LeftTex = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.LeftTex)), - RightTex = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.RightTex)), - UpTex = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.UpTex)), - DownTex = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.DownTex)), + FrontTex = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.FrontTex)) as Texture2D, + BackTex = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.BackTex)) as Texture2D, + LeftTex = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.LeftTex)) as Texture2D, + RightTex = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.RightTex)) as Texture2D, + UpTex = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.UpTex)) as Texture2D, + DownTex = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.DownTex)) as Texture2D, }; } @@ -67,9 +67,9 @@ public static SkyboxCubemapDefinition ToSkyboxCubemapDefinition(this VgoMaterial /// Convert vgo material to skybox panoramic definition. /// /// A vgo material. - /// List of all texture 2D. + /// List of all texture. /// A skybox panoramic definition. - public static SkyboxPanoramicDefinition ToSkyboxPanoramicDefinition(this VgoMaterial vgoMaterial, in List allTexture2dList) + public static SkyboxPanoramicDefinition ToSkyboxPanoramicDefinition(this VgoMaterial vgoMaterial, in List allTextureList) { if (vgoMaterial.shaderName != ShaderName.Skybox_Panoramic) { @@ -81,7 +81,7 @@ public static SkyboxPanoramicDefinition ToSkyboxPanoramicDefinition(this VgoMate Tint = vgoMaterial.GetColorOrDefault(Property.Tint, Color.white).gamma, Exposure = vgoMaterial.GetSafeFloat(Property.Exposure, PropertyRange.Exposure), Rotation = vgoMaterial.GetSafeInt(Property.Rotation, PropertyRange.Rotation), - MainTex = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.MainTex)), + MainTex = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.MainTex)) as Texture2D, Mapping = (Mapping)vgoMaterial.GetIntOrDefault(Property.Mapping), ImageType = (UniSkyboxShader.ImageType)vgoMaterial.GetIntOrDefault(Property.ImageType), MirrorOnBack = vgoMaterial.GetIntOrDefault(Property.MirrorOnBack) == 1, diff --git a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialStandardDefinitionExtensions.cs b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialStandardDefinitionExtensions.cs index f89d571..02d28fe 100644 --- a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialStandardDefinitionExtensions.cs +++ b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialStandardDefinitionExtensions.cs @@ -19,9 +19,9 @@ public static class VgoMaterialStandardDefinitionExtensions /// Convert vgo material to standard definition. /// /// A vgo material. - /// List of all texture 2D. + /// List of all texture. /// A standard definition. - public static StandardDefinition ToStandardDefinition(this VgoMaterial vgoMaterial, in List allTexture2dList) + public static StandardDefinition ToStandardDefinition(this VgoMaterial vgoMaterial, in List allTextureList) { // @notice Accept any shader. //if (vgoMaterial.shaderName != UniStandardShader.ShaderName.Standard) @@ -83,23 +83,23 @@ public static StandardDefinition ToStandardDefinition(this VgoMaterial vgoMateri // Textures standardDefinition.MainTex - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.MainTex)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.MainTex)) as Texture2D; standardDefinition.MetallicGlossMap - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.MetallicGlossMap)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.MetallicGlossMap)) as Texture2D; standardDefinition.BumpMap - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.BumpMap)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.BumpMap)) as Texture2D; standardDefinition.ParallaxMap - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.ParallaxMap)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.ParallaxMap)) as Texture2D; standardDefinition.OcclusionMap - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.OcclusionMap)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.OcclusionMap)) as Texture2D; standardDefinition.EmissionMap - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.EmissionMap)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.EmissionMap)) as Texture2D; standardDefinition.DetailMask - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.DetailMask)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.DetailMask)) as Texture2D; standardDefinition.DetailAlbedoMap - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.DetailAlbedoMap)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.DetailAlbedoMap)) as Texture2D; standardDefinition.DetailNormalMap - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.DetailNormalMap)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.DetailNormalMap)) as Texture2D; standardDefinition.MainTexScale = vgoMaterial.GetTextureScaleOrDefault(Property.MainTex, Vector2.one); diff --git a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialStandardParticleDefinitionExtensions.cs b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialStandardParticleDefinitionExtensions.cs index 8d560fc..b845713 100644 --- a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialStandardParticleDefinitionExtensions.cs +++ b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialStandardParticleDefinitionExtensions.cs @@ -20,9 +20,9 @@ public static class VgoMaterialStandardParticleDefinitionExtensions /// Convert vgo material to BRP particle definition. /// /// A vgo material. - /// List of all texture 2D. + /// List of all texture. /// A BRP particle definition. - public static ParticleDefinition ToBrpParticleDefinition(this VgoMaterial vgoMaterial, in List allTexture2dList) + public static ParticleDefinition ToBrpParticleDefinition(this VgoMaterial vgoMaterial, in List allTextureList) { if ((vgoMaterial.shaderName != ShaderName.Particles_Standard_Surface) && (vgoMaterial.shaderName != ShaderName.Particles_Standard_Unlit)) @@ -91,15 +91,15 @@ public static ParticleDefinition ToBrpParticleDefinition(this VgoMaterial vgoMat // Textures particleDefinition.MainTex - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.MainTex)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.MainTex)) as Texture2D; particleDefinition.MetallicGlossMap - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.MetallicGlossMap)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.MetallicGlossMap)) as Texture2D; particleDefinition.BumpMap - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.BumpMap)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.BumpMap)) as Texture2D; particleDefinition.EmissionMap - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.EmissionMap)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.EmissionMap)) as Texture2D; particleDefinition.GrabTexture - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.GrabTexture)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.GrabTexture)) as Texture2D; particleDefinition.MainTexScale = new Vector2(particleDefinition.MainTexSt.x, particleDefinition.MainTexSt.y); diff --git a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialStandardVColorDefinitionExtensions.cs b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialStandardVColorDefinitionExtensions.cs index e0a9603..b244390 100644 --- a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialStandardVColorDefinitionExtensions.cs +++ b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialStandardVColorDefinitionExtensions.cs @@ -18,9 +18,9 @@ public static class VgoMaterialStandardVColorDefinitionExtensions /// Convert vgo material to standard vertex color definition. /// /// A vgo material. - /// List of all texture 2D. + /// List of all texture. /// A standard vertex color definition. - public static StandardVColorDefinition ToStandardVColorDefinition(this VgoMaterial vgoMaterial, in List allTexture2dList) + public static StandardVColorDefinition ToStandardVColorDefinition(this VgoMaterial vgoMaterial, in List allTextureList) { if (vgoMaterial.shaderName != ShaderName.UniGLTF_StandardVColor) { @@ -39,7 +39,7 @@ public static StandardVColorDefinition ToStandardVColorDefinition(this VgoMateri int mainTextureIndex = vgoMaterial.GetTextureIndexOrDefault(UniStandardShader.Property.MainTex); - standardVColorDefinition.MainTex = allTexture2dList.GetNullableValueOrDefault(mainTextureIndex); + standardVColorDefinition.MainTex = allTextureList.GetNullableValueOrDefault(mainTextureIndex) as Texture2D; return standardVColorDefinition; } diff --git a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialUniGltfUnlitDefinitionExtensions.cs b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialUniGltfUnlitDefinitionExtensions.cs index 4cc0fde..dcdefaf 100644 --- a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialUniGltfUnlitDefinitionExtensions.cs +++ b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialUniGltfUnlitDefinitionExtensions.cs @@ -34,9 +34,9 @@ public static class VgoMaterialUniGltfUnlitDefinitionExtensions /// Convert vgo material to UniGLTF unlit definition. /// /// A vgo material. - /// List of all texture 2D. + /// List of all texture. /// A UniGLTF unlit definition. - public static UniGltfUnlitDefinition ToUniGltfUnlitDefinition(this VgoMaterial vgoMaterial, in List allTexture2dList) + public static UniGltfUnlitDefinition ToUniGltfUnlitDefinition(this VgoMaterial vgoMaterial, in List allTextureList) { if (vgoMaterial.shaderName != ShaderName.UniGLTF_UniUnlit) { @@ -60,7 +60,7 @@ public static UniGltfUnlitDefinition ToUniGltfUnlitDefinition(this VgoMaterial v int mainTextureIndex = vgoMaterial.GetTextureIndexOrDefault(UniUnlitUtil.PropNameMainTex); - uniGltfUnlitDefinition.MainTex = allTexture2dList.GetNullableValueOrDefault(mainTextureIndex); + uniGltfUnlitDefinition.MainTex = allTextureList.GetNullableValueOrDefault(mainTextureIndex) as Texture2D; return uniGltfUnlitDefinition; } diff --git a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialUrpParticleDefinitionExtensions.cs b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialUrpParticleDefinitionExtensions.cs index 4779fcb..6b942e3 100644 --- a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialUrpParticleDefinitionExtensions.cs +++ b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialUrpParticleDefinitionExtensions.cs @@ -20,9 +20,9 @@ public static class VgoMaterialUrpParticleDefinitionExtensions /// Convert vgo material to URP particle definition. /// /// A vgo material. - /// List of all texture 2D. + /// List of all texture. /// A URP particle definition. - public static UrpParticleDefinition ToUrpParticleDefinition(this VgoMaterial vgoMaterial, in List allTexture2dList) + public static UrpParticleDefinition ToUrpParticleDefinition(this VgoMaterial vgoMaterial, in List allTextureList) { if ((vgoMaterial.shaderName != ShaderName.URP_Particles_Lit) && (vgoMaterial.shaderName != ShaderName.URP_Particles_Unlit)) @@ -100,13 +100,13 @@ public static UrpParticleDefinition ToUrpParticleDefinition(this VgoMaterial vgo // Textures urpParticleDefinition.BaseMap - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.BaseMap)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.BaseMap)) as Texture2D; urpParticleDefinition.MetallicGlossMap - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.MetallicGlossMap)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.MetallicGlossMap)) as Texture2D; urpParticleDefinition.BumpMap - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.BumpMap)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.BumpMap)) as Texture2D; urpParticleDefinition.EmissionMap - = allTexture2dList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.EmissionMap)); + = allTextureList.GetNullableValueOrDefault(vgoMaterial.GetTextureIndexOrDefault(Property.EmissionMap)) as Texture2D; return urpParticleDefinition; } diff --git a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialUrpUnlitDefinitionExtensions.cs b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialUrpUnlitDefinitionExtensions.cs index f4231e5..e9ba966 100644 --- a/UniVgo2/Runtime/Extensions/Materials/VgoMaterialUrpUnlitDefinitionExtensions.cs +++ b/UniVgo2/Runtime/Extensions/Materials/VgoMaterialUrpUnlitDefinitionExtensions.cs @@ -35,7 +35,7 @@ public static class VgoMaterialUrpUnlitDefinitionExtensions /// Convert vgo material to URP unlit definition. /// /// A vgo material. - /// List of all texture 2D. + /// List of all texture. /// A URP unlit definition. /// /// ShaderName.UniGLTF_UniUnlit @@ -48,11 +48,11 @@ public static class VgoMaterialUrpUnlitDefinitionExtensions /// ShaderName.VRM_UnlitTransparent /// ShaderName.VRM_UnlitTransparentZWrite /// - public static UrpUnlitDefinition ToUrpUnlitDefinition(this VgoMaterial vgoMaterial, in List allTexture2dList) + public static UrpUnlitDefinition ToUrpUnlitDefinition(this VgoMaterial vgoMaterial, in List allTextureList) { if (vgoMaterial.shaderName == ShaderName.UniGLTF_UniUnlit) { - UniGltfUnlitDefinition brpUnlitDefinition = vgoMaterial.ToUniGltfUnlitDefinition(allTexture2dList); + UniGltfUnlitDefinition brpUnlitDefinition = vgoMaterial.ToUniGltfUnlitDefinition(allTextureList); UrpUnlitDefinition urpUnlitDefinition = brpUnlitDefinition.ToUrpUnlitDefinition(); @@ -116,7 +116,7 @@ public static UrpUnlitDefinition ToUrpUnlitDefinition(this VgoMaterial vgoMateri int mainTextureIndex = vgoMaterial.GetTextureIndexOrDefault(UniUnlitUtil.PropNameMainTex); - urpUnlitDefinition.BaseMap = allTexture2dList.GetNullableValueOrDefault(mainTextureIndex); + urpUnlitDefinition.BaseMap = allTextureList.GetNullableValueOrDefault(mainTextureIndex) as Texture2D; urpUnlitDefinition.BaseMapScale = vgoMaterial.GetTextureScaleOrDefault(UniUnlitUtil.PropNameMainTex, Vector2.one); urpUnlitDefinition.BaseMapOffset = vgoMaterial.GetTextureOffsetOrDefault(UniUnlitUtil.PropNameMainTex, Vector2.zero); diff --git a/UniVgo2/Runtime/Models/Interfaces/IVgoModelAsset.cs b/UniVgo2/Runtime/Models/Interfaces/IVgoModelAsset.cs index 3936b47..6d324a1 100644 --- a/UniVgo2/Runtime/Models/Interfaces/IVgoModelAsset.cs +++ b/UniVgo2/Runtime/Models/Interfaces/IVgoModelAsset.cs @@ -35,8 +35,8 @@ public interface IVgoModelAsset : IDisposable /// List of unity mesh and renderer. List? MeshAssetList { get; set; } - /// List of unity texture2D. - List? Texture2dList { get; set; } + /// List of unity texture. + List? TextureList { get; set; } /// List of scriptable object. List ScriptableObjectList { get; } diff --git a/UniVgo2/Runtime/Models/VgoModelAsset.cs b/UniVgo2/Runtime/Models/VgoModelAsset.cs index 94588fa..c86cecc 100644 --- a/UniVgo2/Runtime/Models/VgoModelAsset.cs +++ b/UniVgo2/Runtime/Models/VgoModelAsset.cs @@ -40,8 +40,8 @@ public class VgoModelAsset : IVgoModelAsset, IDisposable /// List of unity mesh and renderer. private List? _MeshAssetList = null; - /// List of unity texture2D. - private List? _Texture2dList = null; + /// List of unity texture. + private List? _TextureList = null; /// List of scriptable object. private readonly List _ScriptableObjectList = new List(); @@ -77,8 +77,8 @@ public class VgoModelAsset : IVgoModelAsset, IDisposable /// List of unity mesh and renderer. public List? MeshAssetList { get => _MeshAssetList; set => _MeshAssetList = value; } - /// List of unity texture2D. - public List? Texture2dList { get => _Texture2dList; set => _Texture2dList = value; } + /// List of unity texture. + public List? TextureList { get => _TextureList; set => _TextureList = value; } /// List of scriptable object. public List ScriptableObjectList => _ScriptableObjectList; @@ -436,9 +436,9 @@ protected virtual void DestroyRootAndResources() { foreach (var x in MeshAssetList) { yield return x?.Mesh; } } - if (Texture2dList != null) + if (TextureList != null) { - foreach (var x in Texture2dList) { yield return x; } + foreach (var x in TextureList) { yield return x; } } if (SpringBoneColliderGroupArray != null) { diff --git a/UniVgo2/Runtime/Options/VgoImporterOption.cs b/UniVgo2/Runtime/Options/VgoImporterOption.cs index c8c484a..0ddedc1 100644 --- a/UniVgo2/Runtime/Options/VgoImporterOption.cs +++ b/UniVgo2/Runtime/Options/VgoImporterOption.cs @@ -18,5 +18,8 @@ public class VgoImporterOption /// Whether update skinned mesh renderer when off screen. public bool UpdateWhenOffscreen { get; set; } = false; + + /// Whether to force the particle system duration in Runtime. + public bool ForceSetRuntimeParticleDuration { get; set; } = false; } } diff --git a/UniVgo2/Runtime/Porters/Interfaces/IMaterialPorter.cs b/UniVgo2/Runtime/Porters/Interfaces/IMaterialPorter.cs index ea59c92..f2acb15 100644 --- a/UniVgo2/Runtime/Porters/Interfaces/IMaterialPorter.cs +++ b/UniVgo2/Runtime/Porters/Interfaces/IMaterialPorter.cs @@ -41,9 +41,9 @@ public interface IMaterialPorter /// /// A vgo material. /// A shader. - /// List of all texture 2D. + /// List of all texture. /// A unity material. - Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTexture2dList); + Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTextureList); #endregion } diff --git a/UniVgo2/Runtime/Porters/Interfaces/IVgoMaterialImporter.cs b/UniVgo2/Runtime/Porters/Interfaces/IVgoMaterialImporter.cs index 9b46fdd..2b58c64 100644 --- a/UniVgo2/Runtime/Porters/Interfaces/IVgoMaterialImporter.cs +++ b/UniVgo2/Runtime/Porters/Interfaces/IVgoMaterialImporter.cs @@ -30,9 +30,9 @@ public interface IVgoMaterialImporter /// Create a material. /// /// A vgo material. - /// List of Texture2D. + /// List of Texture. /// A unity material. - Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in List texture2dList); + Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in List textureList); #endregion } diff --git a/UniVgo2/Runtime/Porters/Interfaces/IVgoParticleSystemImporter.cs b/UniVgo2/Runtime/Porters/Interfaces/IVgoParticleSystemImporter.cs index 5db90c1..3274c02 100644 --- a/UniVgo2/Runtime/Porters/Interfaces/IVgoParticleSystemImporter.cs +++ b/UniVgo2/Runtime/Porters/Interfaces/IVgoParticleSystemImporter.cs @@ -24,9 +24,10 @@ public interface IVgoParticleSystemImporter /// /// /// - /// + /// + /// /// Returns ParticleSystem component. - ParticleSystem AddComponent(GameObject go, in VgoParticleSystem vgoParticleSystem, in VgoGeometryCoordinate geometryCoordinate, in IList? materialList, in IList? texture2dList); + ParticleSystem AddComponent(GameObject go, in VgoParticleSystem vgoParticleSystem, in VgoGeometryCoordinate geometryCoordinate, in IList? materialList, in IList? textureList, in bool forceSetRuntimeDuration); /// /// Set particleSystemRenderer field value. diff --git a/UniVgo2/Runtime/Porters/Interfaces/IVgoTextureImporter.cs b/UniVgo2/Runtime/Porters/Interfaces/IVgoTextureImporter.cs index c11d9a2..448cd2a 100644 --- a/UniVgo2/Runtime/Porters/Interfaces/IVgoTextureImporter.cs +++ b/UniVgo2/Runtime/Porters/Interfaces/IVgoTextureImporter.cs @@ -29,21 +29,21 @@ public interface IVgoTextureImporter /// Create texture assets. /// /// A vgo storage. - /// List of unity texture2D. - List CreateTextureAssets(in IVgoStorage vgoStorage); + /// List of unity texture. + List CreateTextureAssets(in IVgoStorage vgoStorage); /// /// Create texture assets. /// /// A vgo storage. /// The token to monitor for cancellation requests. - /// List of unity texture2D. + /// List of unity texture. #if UNITY_2023_1_OR_NEWER && UNIVGO_USE_UNITY_AWAITABLE - Awaitable> CreateTextureAssetsAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken); + Awaitable> CreateTextureAssetsAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken); #elif CYSHARP_UNITASK_2_OR_NEWER && UNIVGO_USE_UNITASK - UniTask> CreateTextureAssetsAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken); + UniTask> CreateTextureAssetsAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken); #else - Task> CreateTextureAssetsAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken); + Task> CreateTextureAssetsAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken); #endif /// @@ -51,13 +51,13 @@ public interface IVgoTextureImporter /// /// A vgo storage. /// The token to monitor for cancellation requests. - /// List of unity texture2D. + /// List of unity texture. #if UNITY_2023_1_OR_NEWER && UNIVGO_USE_UNITY_AWAITABLE - Awaitable> CreateTextureAssetsParallelAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken); + Awaitable> CreateTextureAssetsParallelAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken); #elif CYSHARP_UNITASK_2_OR_NEWER && UNIVGO_USE_UNITASK - UniTask> CreateTextureAssetsParallelAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken); + UniTask> CreateTextureAssetsParallelAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken); #else - Task> CreateTextureAssetsParallelAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken); + Task> CreateTextureAssetsParallelAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken); #endif #endregion diff --git a/UniVgo2/Runtime/Porters/Materials/AbstractMaterialPorterBase.cs b/UniVgo2/Runtime/Porters/Materials/AbstractMaterialPorterBase.cs index 5903bd5..db880b1 100644 --- a/UniVgo2/Runtime/Porters/Materials/AbstractMaterialPorterBase.cs +++ b/UniVgo2/Runtime/Porters/Materials/AbstractMaterialPorterBase.cs @@ -398,7 +398,7 @@ protected virtual bool ExportKeyword(VgoMaterial vgoMaterial, Material material, /// A tag name. /// /// If searchFallbacks is true then this function will look for tag in all subshaders and all fallbacks. - /// If seachFallbacks is false then only the currently used subshader will be queried for the tag. + /// If searchFallbacks is false then only the currently used subshader will be queried for the tag. /// /// If the material's shader does not define the tag, defaultValue is returned. /// @@ -563,9 +563,9 @@ protected virtual bool ExportTextureScale(VgoMaterial vgoMaterial, Material mate /// /// A vgo material. /// A shader. - /// List of all texture 2D. + /// List of all texture. /// A unity material. - public virtual Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTexture2dList) + public virtual Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTextureList) { var material = new Material(shader) { @@ -591,7 +591,7 @@ public virtual Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shade ImportColorProperties(material, vgoMaterial); - ImportTextureProperties(material, vgoMaterial, allTexture2dList); + ImportTextureProperties(material, vgoMaterial, allTextureList); return material; } @@ -864,8 +864,8 @@ protected virtual void ImportVectorProperties(Material material, in VgoMaterial /// /// A unity material. /// A vgo material. - /// List of all texture 2D. - protected virtual void ImportTextureProperties(Material material, in VgoMaterial vgoMaterial, in List allTexture2dList) + /// List of all texture. + protected virtual void ImportTextureProperties(Material material, in VgoMaterial vgoMaterial, in List allTextureList) { if (vgoMaterial.textureIndexProperties != null) { @@ -878,14 +878,14 @@ protected virtual void ImportTextureProperties(Material material, in VgoMaterial try { - //if (allTexture2dList.TryGetValue(textureIndex, out Texture2D texture)) + //if (allTextureList.TryGetValue(textureIndex, out Texture texture)) //{ // material.SetTexture(propertyName, texture); //} - if (textureIndex.IsInRangeOf(allTexture2dList)) + if (textureIndex.IsInRangeOf(allTextureList)) { - material.SetTexture(propertyName, allTexture2dList[textureIndex]); + material.SetTexture(propertyName, allTextureList[textureIndex]); } } catch diff --git a/UniVgo2/Runtime/Porters/Materials/HdrpMaterialPorter.cs b/UniVgo2/Runtime/Porters/Materials/HdrpMaterialPorter.cs index b6167c4..de84ffc 100644 --- a/UniVgo2/Runtime/Porters/Materials/HdrpMaterialPorter.cs +++ b/UniVgo2/Runtime/Porters/Materials/HdrpMaterialPorter.cs @@ -171,9 +171,9 @@ protected VgoMaterial CreateVgoMaterialFromHdrpLit(in Material material, in IVgo /// /// A vgo material. /// A HDRP shader. - /// List of all texture 2D. + /// List of all texture. /// A HDRP material. - public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTexture2dList) + public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTextureList) { switch (vgoMaterial.shaderName) { @@ -192,7 +192,7 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad #endif } - Material material = base.CreateMaterialAsset(vgoMaterial, shader, allTexture2dList); + Material material = base.CreateMaterialAsset(vgoMaterial, shader, allTextureList); SurfaceType? surfaceType = null; BlendMode? blendMode = null; diff --git a/UniVgo2/Runtime/Porters/Materials/LilToonMaterialPorter.cs b/UniVgo2/Runtime/Porters/Materials/LilToonMaterialPorter.cs index 7abdcdb..d108104 100644 --- a/UniVgo2/Runtime/Porters/Materials/LilToonMaterialPorter.cs +++ b/UniVgo2/Runtime/Porters/Materials/LilToonMaterialPorter.cs @@ -596,9 +596,9 @@ protected virtual void ExportLilTextureProperties( /// /// A vgo material. /// A lilToon shader. - /// List of all texture 2D. + /// List of all texture. /// A lilToon material. - public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTexture2dList) + public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTextureList) { #if IZAYOI_LILTOON_UTILITY_1_0_OR_NEWER if ((shader.name.Contains("lilToon") == false) && @@ -611,7 +611,7 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad #endif } - Material material = base.CreateMaterialAsset(vgoMaterial, shader, allTexture2dList); + Material material = base.CreateMaterialAsset(vgoMaterial, shader, allTextureList); return material; #else diff --git a/UniVgo2/Runtime/Porters/Materials/Mtoon10MaterialPorter.cs b/UniVgo2/Runtime/Porters/Materials/Mtoon10MaterialPorter.cs index 35523df..7468576 100644 --- a/UniVgo2/Runtime/Porters/Materials/Mtoon10MaterialPorter.cs +++ b/UniVgo2/Runtime/Porters/Materials/Mtoon10MaterialPorter.cs @@ -230,9 +230,9 @@ protected virtual bool ExportTextureProperty( /// /// A vgo material. /// A MToon 1.0 shader. - /// List of all texture 2D. + /// List of all texture. /// A MToon 1.0 material. - public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTexture2dList) + public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTextureList) { if (vgoMaterial.shaderName != ShaderName.VRM_MToon10) { @@ -242,7 +242,7 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad #if UNIVGO_ENABLE_MTOON_1_0 if (shader.name == ShaderName.VRM_URP_MToon10) { - return CreateMaterialAssetAsUrp(vgoMaterial, shader, allTexture2dList); + return CreateMaterialAssetAsUrp(vgoMaterial, shader, allTextureList); } #endif @@ -252,7 +252,7 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad } #if UNIVGO_ENABLE_MTOON_1_0 - return CreateMaterialAssetInternal(vgoMaterial, shader, allTexture2dList); + return CreateMaterialAssetInternal(vgoMaterial, shader, allTextureList); #else #if NET_STANDARD_2_1 ThrowHelper.ThrowNotSupportedException(vgoMaterial.shaderName); @@ -273,11 +273,11 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad /// /// A vgo material. /// A MToon 1.0 shader. - /// List of all texture 2D. + /// List of all texture. /// A MToon 1.0 material. - protected virtual Material CreateMaterialAssetAsUrp(in VgoMaterial vgoMaterial, in Shader shader, in List allTexture2dList) + protected virtual Material CreateMaterialAssetAsUrp(in VgoMaterial vgoMaterial, in Shader shader, in List allTextureList) { - return CreateMaterialAssetInternal(vgoMaterial, shader, allTexture2dList); + return CreateMaterialAssetInternal(vgoMaterial, shader, allTextureList); } /// @@ -285,11 +285,11 @@ protected virtual Material CreateMaterialAssetAsUrp(in VgoMaterial vgoMaterial, /// /// A vgo material. /// A MToon 1.0 shader. - /// List of all texture 2D. + /// List of all texture. /// A MToon 1.0 material. - protected virtual Material CreateMaterialAssetInternal(in VgoMaterial vgoMaterial, in Shader shader, in List allTexture2dList) + protected virtual Material CreateMaterialAssetInternal(in VgoMaterial vgoMaterial, in Shader shader, in List allTextureList) { - MToon10Definition mtoon10 = vgoMaterial.ToMToon10Definition(allTexture2dList); + MToon10Definition mtoon10 = vgoMaterial.ToMToon10Definition(allTextureList); var material = new Material(shader) { @@ -318,20 +318,20 @@ protected virtual Material CreateMaterialAssetInternal(in VgoMaterial vgoMateria { // Base (Main) SetColor(material, MToon10Prop.BaseColorFactor, mtoon10.BaseColorFactor); - SetTexture(material, vgoMaterial, allTexture2dList, MToon10Prop.BaseColorTexture); + SetTexture(material, vgoMaterial, allTextureList, MToon10Prop.BaseColorTexture); // Shade SetColor(material, MToon10Prop.ShadeColorFactor, mtoon10.ShadeColorFactor); - SetTexture(material, vgoMaterial, allTexture2dList, MToon10Prop.ShadeColorTexture); + SetTexture(material, vgoMaterial, allTextureList, MToon10Prop.ShadeColorTexture); // Normal (Bump) - SetTexture(material, vgoMaterial, allTexture2dList, MToon10Prop.NormalTexture); + SetTexture(material, vgoMaterial, allTextureList, MToon10Prop.NormalTexture); SetSafeValue(material, MToon10Prop.NormalTextureScale, mtoon10.NormalTextureScale); // Shading Shift SetSafeValue(material, MToon10Prop.ShadingShiftFactor, mtoon10.ShadingShiftFactor); - SetTexture(material, vgoMaterial, allTexture2dList, MToon10Prop.ShadingShiftTexture); + SetTexture(material, vgoMaterial, allTextureList, MToon10Prop.ShadingShiftTexture); SetSafeValue(material, MToon10Prop.ShadingShiftTextureScale, mtoon10.ShadingShiftTextureScale); // Shading Toony @@ -345,20 +345,20 @@ protected virtual Material CreateMaterialAssetInternal(in VgoMaterial vgoMateria // Emission { - SetTexture(material, vgoMaterial, allTexture2dList, MToon10Prop.EmissiveTexture); + SetTexture(material, vgoMaterial, allTextureList, MToon10Prop.EmissiveTexture); SetColor(material, MToon10Prop.EmissiveFactor, mtoon10.EmissiveFactor); } // Rim Lighting { - SetTexture(material, vgoMaterial, allTexture2dList, MToon10Prop.RimMultiplyTexture); + SetTexture(material, vgoMaterial, allTextureList, MToon10Prop.RimMultiplyTexture); SetSafeValue(material, MToon10Prop.RimLightingMixFactor, mtoon10.RimLightingMixFactor); // Mat Cap #if VRMC_VRMSHADERS_0_104_OR_NEWER SetColor(material, MToon10Prop.MatcapColorFactor, mtoon10.MatcapColorFactor); #endif - SetTexture(material, vgoMaterial, allTexture2dList, MToon10Prop.MatcapTexture); + SetTexture(material, vgoMaterial, allTextureList, MToon10Prop.MatcapTexture); // Parametric Rim SetColor(material, MToon10Prop.ParametricRimColorFactor, mtoon10.ParametricRimColorFactor); @@ -370,14 +370,14 @@ protected virtual Material CreateMaterialAssetInternal(in VgoMaterial vgoMateria { SetSafeValue(material, MToon10Prop.OutlineWidthMode, (int)mtoon10.OutlineWidthMode); SetSafeValue(material, MToon10Prop.OutlineWidthFactor, mtoon10.OutlineWidthFactor); - SetTexture(material, vgoMaterial, allTexture2dList, MToon10Prop.OutlineWidthMultiplyTexture); + SetTexture(material, vgoMaterial, allTextureList, MToon10Prop.OutlineWidthMultiplyTexture); SetColor(material, MToon10Prop.OutlineColorFactor, mtoon10.OutlineColorFactor); SetSafeValue(material, MToon10Prop.OutlineLightingMixFactor, mtoon10.OutlineLightingMixFactor); } // UV Animation { - SetTexture(material, vgoMaterial, allTexture2dList, MToon10Prop.UvAnimationMaskTexture); + SetTexture(material, vgoMaterial, allTextureList, MToon10Prop.UvAnimationMaskTexture); SetSafeValue(material, MToon10Prop.UvAnimationScrollXSpeedFactor, mtoon10.UvAnimationScrollXSpeedFactor); SetSafeValue(material, MToon10Prop.UvAnimationScrollYSpeedFactor, mtoon10.UvAnimationScrollYSpeedFactor); SetSafeValue(material, MToon10Prop.UvAnimationRotationSpeedFactor, mtoon10.UvAnimationRotationSpeedFactor); @@ -443,9 +443,9 @@ protected virtual void SetColor(Material material, in MToon10Prop property, Colo /// /// A material. /// A vgo material. - /// List of all texture 2D. + /// List of all texture. /// A material property. - protected virtual void SetTexture(Material material, in VgoMaterial vgoMaterial, in List allTexture2dList, in MToon10Prop property) + protected virtual void SetTexture(Material material, in VgoMaterial vgoMaterial, in List allTextureList, in MToon10Prop property) { string propertyName = property.ToUnityShaderLabName(); @@ -456,11 +456,11 @@ protected virtual void SetTexture(Material material, in VgoMaterial vgoMaterial, int textureIndex = vgoMaterial.GetTextureIndexOrDefault(propertyName); - Texture2D? texture2d = allTexture2dList.GetNullableValueOrDefault(textureIndex); + Texture? texture = allTextureList.GetNullableValueOrDefault(textureIndex); - if (texture2d != null) + if (texture != null) { - material.SetTexture(propertyName, texture2d); + material.SetTexture(propertyName, texture); } Vector2? textureOffset = vgoMaterial.GetTextureOffsetOrNull(propertyName); diff --git a/UniVgo2/Runtime/Porters/Materials/MtoonMaterialPorter.cs b/UniVgo2/Runtime/Porters/Materials/MtoonMaterialPorter.cs index 5c583ea..64d4d55 100644 --- a/UniVgo2/Runtime/Porters/Materials/MtoonMaterialPorter.cs +++ b/UniVgo2/Runtime/Porters/Materials/MtoonMaterialPorter.cs @@ -142,9 +142,9 @@ public override VgoMaterial CreateVgoMaterial(in Material material, in IVgoStora /// /// A vgo material. /// A MToon shader. - /// List of all texture 2D. + /// List of all texture. /// A MToon material. - public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTexture2dList) + public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTextureList) { if (vgoMaterial.shaderName != ShaderName.VRM_MToon) { @@ -154,7 +154,7 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad #if UNIVGO_ENABLE_MTOON_0_0 && UNIVGO_ENABLE_MTOON_1_0 if ((shader.name == ShaderName.VRM_MToon10) || (shader.name == ShaderName.VRM_URP_MToon10)) { - return CreateMaterialAssetAsMtoon10(vgoMaterial, shader, allTexture2dList); + return CreateMaterialAssetAsMtoon10(vgoMaterial, shader, allTextureList); } #endif @@ -174,7 +174,7 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad material.renderQueue = vgoMaterial.renderQueue; } - MToonDefinition mtoonParameter = vgoMaterial.ToMToon0xDefinition(allTexture2dList); + MToonDefinition mtoonParameter = vgoMaterial.ToMToon0xDefinition(allTextureList); MToon.Utils.SetMToonParametersToMaterial(material, mtoonParameter); @@ -199,19 +199,19 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad /// /// A vgo material. /// A MToon 1.0 shader. - /// List of all texture 2D. + /// List of all texture. /// A MToon 1.0 material. /// /// Migrate from MToon 0.x setting to MToon 1.0 material. /// - protected virtual Material CreateMaterialAssetAsMtoon10(in VgoMaterial vgoMaterial, Shader shader, in List allTexture2dList) + protected virtual Material CreateMaterialAssetAsMtoon10(in VgoMaterial vgoMaterial, Shader shader, in List allTextureList) { var material = new Material(shader) { name = vgoMaterial.name }; - MToonDefinition mtoon0x = vgoMaterial.ToMToon0xDefinition(allTexture2dList); + MToonDefinition mtoon0x = vgoMaterial.ToMToon0xDefinition(allTextureList); MToon10Definition mtoon10 = mtoon0x.ToMToon10Definition(destructiveMigration: true); diff --git a/UniVgo2/Runtime/Porters/Materials/NovaMaterialPorter.cs b/UniVgo2/Runtime/Porters/Materials/NovaMaterialPorter.cs new file mode 100644 index 0000000..01f7b27 --- /dev/null +++ b/UniVgo2/Runtime/Porters/Materials/NovaMaterialPorter.cs @@ -0,0 +1,347 @@ +// ---------------------------------------------------------------------- +// @Namespace : UniVgo2.Porters +// @Class : NovaMaterialPorter +// ---------------------------------------------------------------------- +#nullable enable +namespace UniVgo2.Porters +{ +#if IZAYOI_NOVA_SHADER_UTILITY_2_0_OR_NEWER + using Izayoi.NovaShader; + using Izayoi.NovaShader.Extensions; + using NovaShader = Izayoi.NovaShader; +#endif + using NewtonVgo; + using System.Collections.Generic; + using UnityEngine; + + /// + /// NOVA Shader Material Porter + /// + /// + /// The following particle system features are not yet implemented, so it is not complete. + /// - VgoParticleSystemExporter + /// - VgoParticleSystemImporter + /// + public class NovaMaterialPorter : AbstractMaterialPorterBase + { + #region Constructors + + /// + /// Create a new instance of NovaMaterialPorter. + /// + public NovaMaterialPorter() : base() { } + + #endregion + + #region Public Methods (Export) + + /// + /// Create a vgo material. + /// + /// A URP material. + /// A vgo storage. + /// A vgo material. + public override VgoMaterial CreateVgoMaterial(in Material material, in IVgoStorage vgoStorage) + { + switch (material.shader.name) + { +#if IZAYOI_NOVA_SHADER_UTILITY_2_0_OR_NEWER + // Opaque + case ShaderName.Nova_Particles_UberLit: + case ShaderName.Nova_UIParticles_UberLit: + return CreateVgoMaterialFromNova(material, vgoStorage, NovaPropertyEntityType.UberLit); + case ShaderName.Nova_Particles_UberUnlit: + case ShaderName.Nova_UIParticles_UberUnlit: + return CreateVgoMaterialFromNova(material, vgoStorage, NovaPropertyEntityType.UberUnlit); + + // Cutout + case ShaderName.Nova_Particles_Distortion: + return CreateVgoMaterialFromNova(material, vgoStorage, NovaPropertyEntityType.Distortion); +#endif + default: +#if NET_STANDARD_2_1 + ThrowHelper.ThrowNotSupportedException(material.shader.name); + return default; +#else + throw new NotSupportedException(material.shader.name); +#endif + } + } + + #endregion + +#if IZAYOI_NOVA_SHADER_UTILITY_2_0_OR_NEWER + + #region Protected Methods (Export) + + /// + /// Create a vgo material from a NOVA material. + /// + /// A NOVA material. + /// A vgo storage. + /// + /// A vgo material. + protected virtual VgoMaterial CreateVgoMaterialFromNova( + in Material material, + in IVgoStorage vgoStorage, + in NovaPropertyEntityType propertyEntityType) + { + var vgoMaterial = new VgoMaterial() + { + name = material.name, + shaderName = material.shader.name, + renderQueue = material.renderQueue, + isUnlit = propertyEntityType == NovaPropertyEntityType.UberUnlit, + }; + + ExportProperties(vgoMaterial, material); + + ExportNovaTextureProperties(vgoStorage, vgoMaterial, material, propertyEntityType); + + // Tags + ExportTag(vgoMaterial, material, Tag.RenderType); + ExportTag(vgoMaterial, material, Tag.RenderPipeline); + + // Keywords + ExportKeywords(vgoMaterial, material); + + return vgoMaterial; + } + + /// + /// Export NOVA texture type properties. + /// + /// A vgo storage. + /// A vgo material. + /// A NOVA material. + /// + protected virtual void ExportNovaTextureProperties( + IVgoStorage vgoStorage, + VgoMaterial vgoMaterial, + in Material material, + in NovaPropertyEntityType propertyEntityType) + { + // Base Map + if (propertyEntityType == NovaPropertyEntityType.Distortion) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.BaseMap, VgoTextureMapType.Default, VgoColorSpaceType.Srgb); + } + else + { + NovaBaseMapMode baseMapMode = material.GetSafeEnum(NovaShader.PropertyName.BaseMapMode); + + if (baseMapMode == NovaBaseMapMode.SingleTexture) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.BaseMap, VgoTextureMapType.Default, VgoColorSpaceType.Srgb); + } + else if (baseMapMode == NovaBaseMapMode.FlipBook) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.BaseMap2DArray, VgoTextureMapType.Default, VgoColorSpaceType.Srgb); + } + else if (baseMapMode == NovaBaseMapMode.FlipBookBlending) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.BaseMap3D, VgoTextureMapType.Default, VgoColorSpaceType.Srgb); + } + } + + // Surface Maps + if (propertyEntityType == NovaPropertyEntityType.UberLit) + { + float metallic = material.GetSafeFloat(NovaShader.PropertyNameID.Metallic, -1.0f); + float smoothness = material.GetSafeFloat(NovaShader.PropertyNameID.Smoothness, -1.0f); + + // Normal Map + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.NormalMap, VgoTextureMapType.NormalMap, VgoColorSpaceType.Linear); + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.NormalMap2DArray, VgoTextureMapType.NormalMap, VgoColorSpaceType.Linear); + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.NormalMap3D, VgoTextureMapType.NormalMap, VgoColorSpaceType.Linear); + + // Specular Map + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.SpecularMap, VgoTextureMapType.SpecularGlossinessMap, VgoColorSpaceType.Linear); + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.SpecularMap2DArray, VgoTextureMapType.SpecularGlossinessMap, VgoColorSpaceType.Linear); + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.SpecularMap3D, VgoTextureMapType.SpecularGlossinessMap, VgoColorSpaceType.Linear); + + // Metallic Map + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.MetallicMap, VgoTextureMapType.SpecularGlossinessMap, VgoColorSpaceType.Linear, metallic); + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.MetallicMap2DArray, VgoTextureMapType.SpecularGlossinessMap, VgoColorSpaceType.Linear, metallic); + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.MetallicMap3D, VgoTextureMapType.SpecularGlossinessMap, VgoColorSpaceType.Linear, metallic); + + // Smoothness Map + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.SmoothnessMap, VgoTextureMapType.SpecularGlossinessMap, VgoColorSpaceType.Linear, smoothness); + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.SmoothnessMap2DArray, VgoTextureMapType.SpecularGlossinessMap, VgoColorSpaceType.Linear, smoothness); + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.SmoothnessMap3D, VgoTextureMapType.SpecularGlossinessMap, VgoColorSpaceType.Linear, smoothness); + } + + // Tint + if (propertyEntityType != NovaPropertyEntityType.Distortion) + { + NovaTintAreaMode tintAreaMode = material.GetSafeEnum(NovaShader.PropertyName.TintAreaMode); + + if (tintAreaMode != NovaTintAreaMode.None) + { + NovaTintColorMode tintColorMode = material.GetSafeEnum(NovaShader.PropertyName.TintColorMode); + + // Tint Map + if (tintColorMode == NovaTintColorMode.Texture2D) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.TintMap, VgoTextureMapType.Default, VgoColorSpaceType.Srgb); + } + else if (tintColorMode == NovaTintColorMode.Texture3D) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.TintMap3D, VgoTextureMapType.Default, VgoColorSpaceType.Srgb); + } + } + } + + // Flow Map + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.FlowMap, VgoTextureMapType.Default, VgoColorSpaceType.Srgb); + } + + // Parallax Map + if (propertyEntityType != NovaPropertyEntityType.Distortion) + { + NovaParallaxMapMode parallaxMapMode = material.GetSafeEnum(NovaShader.PropertyName.ParallaxMapMode); + + if (parallaxMapMode == NovaParallaxMapMode.SingleTexture) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.ParallaxMap, VgoTextureMapType.Default, VgoColorSpaceType.Srgb); + } + else if (parallaxMapMode == NovaParallaxMapMode.FlipBook) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.ParallaxMap2DArray, VgoTextureMapType.Default, VgoColorSpaceType.Srgb); + } + else if (parallaxMapMode == NovaParallaxMapMode.FlipBookBlending) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.ParallaxMap3D, VgoTextureMapType.Default, VgoColorSpaceType.Srgb); + } + } + + // Color Correction + if (propertyEntityType != NovaPropertyEntityType.Distortion) + { + NovaColorCorrectionMode colorCorrectionMode = material.GetSafeEnum(NovaShader.PropertyName.ColorCorrectionMode); + + // Gradient Map + if (colorCorrectionMode == NovaColorCorrectionMode.GradientMap) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.GradientMap, VgoTextureMapType.Default, VgoColorSpaceType.Srgb); + } + } + + // Alpha Transition + { + NovaAlphaTransitionMode alphaTransitionMode = material.GetSafeEnum(NovaShader.PropertyName.AlphaTransitionMode); + + if (alphaTransitionMode != NovaAlphaTransitionMode.None) + { + // Alpha Transition Map + if (propertyEntityType == NovaPropertyEntityType.Distortion) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.AlphaTransitionMap, VgoTextureMapType.Default, VgoColorSpaceType.Srgb); + } + else + { + NovaAlphaTransitionMapMode alphaTransitionMapMode = material.GetSafeEnum(NovaShader.PropertyName.AlphaTransitionMapMode); + + if (alphaTransitionMapMode == NovaAlphaTransitionMapMode.SingleTexture) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.AlphaTransitionMap, VgoTextureMapType.Default, VgoColorSpaceType.Srgb); + } + else if (alphaTransitionMapMode == NovaAlphaTransitionMapMode.FlipBook) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.AlphaTransitionMap2DArray, VgoTextureMapType.Default, VgoColorSpaceType.Srgb); + } + else if (alphaTransitionMapMode == NovaAlphaTransitionMapMode.FlipBookBlending) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.AlphaTransitionMap3D, VgoTextureMapType.Default, VgoColorSpaceType.Srgb); + } + } + } + } + + // Emission + if (propertyEntityType != NovaPropertyEntityType.Distortion) + { + NovaEmissionAreaType emissionAreaType = material.GetSafeEnum(NovaShader.PropertyName.EmissionAreaType); + + // Emission Map + if (emissionAreaType == NovaEmissionAreaType.ByTexture) + { + NovaEmissionMapMode emissionMapMode = material.GetSafeEnum(NovaShader.PropertyName.EmissionMapMode); + + if (emissionMapMode == NovaEmissionMapMode.SingleTexture) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.EmissionMap, VgoTextureMapType.EmissionMap, VgoColorSpaceType.Srgb); + } + else if (emissionMapMode == NovaEmissionMapMode.FlipBook) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.EmissionMap2DArray, VgoTextureMapType.EmissionMap, VgoColorSpaceType.Srgb); + } + else if (emissionMapMode == NovaEmissionMapMode.FlipBookBlending) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.EmissionMap3D, VgoTextureMapType.EmissionMap, VgoColorSpaceType.Srgb); + } + } + + // Emission Color Ramp + if (emissionAreaType != NovaEmissionAreaType.None) + { + NovaEmissionColorType emissionColorType = material.GetSafeEnum(NovaShader.PropertyName.EmissionColorType); + + if (emissionColorType == NovaEmissionColorType.GradientMap) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.EmissionColorRamp, VgoTextureMapType.Default, VgoColorSpaceType.Srgb); + } + } + } + + // Vertex Deformation Map + if (propertyEntityType != NovaPropertyEntityType.Distortion) + { + if (material.GetSafeBool(NovaShader.PropertyName.VertexDeformationEnabled)) + { + base.ExportTextureProperty(vgoStorage, vgoMaterial, material, NovaShader.PropertyName.VertexDeformationMap, VgoTextureMapType.Default, VgoColorSpaceType.Srgb); + } + } + } + + #endregion +#endif + + #region Public Methods (Import) + + /// + /// Create a lilToon material. + /// + /// A vgo material. + /// A lilToon shader. + /// List of all texture. + /// A lilToon material. + public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTextureList) + { +#if IZAYOI_NOVA_SHADER_UTILITY_2_0_OR_NEWER + if (shader.name.StartsWith("Nova/Particles/") == false) + { +#if NET_STANDARD_2_1 + ThrowHelper.ThrowNotSupportedException(vgoMaterial?.shaderName ?? string.Empty); +#else + throw new NotSupportedException(vgoMaterial.shaderName ?? string.Empty); +#endif + } + + Material material = base.CreateMaterialAsset(vgoMaterial, shader, allTextureList); + + return material; +#else +#if NET_STANDARD_2_1 + ThrowHelper.ThrowNotSupportedException(vgoMaterial.shaderName ?? string.Empty); + return default; +#else + throw new NotSupportedException(vgoMaterial.shaderName ?? string.Empty); +#endif +#endif + } + + #endregion + } +} diff --git a/UniVgo2/Runtime/Porters/Materials/NovaMaterialPorter.cs.meta b/UniVgo2/Runtime/Porters/Materials/NovaMaterialPorter.cs.meta new file mode 100644 index 0000000..daebf7d --- /dev/null +++ b/UniVgo2/Runtime/Porters/Materials/NovaMaterialPorter.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: afeca12db2fe70b41b51cd2601473424 \ No newline at end of file diff --git a/UniVgo2/Runtime/Porters/Materials/ParticleMaterialPorter.cs b/UniVgo2/Runtime/Porters/Materials/ParticleMaterialPorter.cs index abc551f..edada69 100644 --- a/UniVgo2/Runtime/Porters/Materials/ParticleMaterialPorter.cs +++ b/UniVgo2/Runtime/Porters/Materials/ParticleMaterialPorter.cs @@ -131,9 +131,9 @@ public override VgoMaterial CreateVgoMaterial(in Material material, in IVgoStora /// /// A vgo material. /// A particle shader. - /// List of all texture 2D. + /// List of all texture. /// A particle material. - public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTexture2dList) + public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTextureList) { if ((vgoMaterial.shaderName != UniVgo2.ShaderName.Particles_Standard_Surface) && (vgoMaterial.shaderName != UniVgo2.ShaderName.Particles_Standard_Unlit)) @@ -144,7 +144,7 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad if ((shader.name == UniVgo2.ShaderName.URP_Particles_Lit) || (shader.name == UniVgo2.ShaderName.URP_Particles_Unlit)) { - return CreateMaterialAssetAsUrp(vgoMaterial, shader, allTexture2dList); + return CreateMaterialAssetAsUrp(vgoMaterial, shader, allTextureList); } if ((shader.name != UniVgo2.ShaderName.Particles_Standard_Surface) && @@ -158,7 +158,7 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad name = vgoMaterial.name }; - ParticleDefinition particleDefinition = vgoMaterial.ToBrpParticleDefinition(allTexture2dList); + ParticleDefinition particleDefinition = vgoMaterial.ToBrpParticleDefinition(allTextureList); UniParticleShader.Utils.SetParametersToMaterial(material, particleDefinition); @@ -174,9 +174,9 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad /// /// A vgo material. /// A URP Particle shader. - /// List of all texture 2D. + /// List of all texture. /// A URP Particle material. - protected virtual Material CreateMaterialAssetAsUrp(in VgoMaterial vgoMaterial, Shader shader, in List allTexture2dList) + protected virtual Material CreateMaterialAssetAsUrp(in VgoMaterial vgoMaterial, Shader shader, in List allTextureList) { var material = new Material(shader) { @@ -188,7 +188,7 @@ protected virtual Material CreateMaterialAssetAsUrp(in VgoMaterial vgoMaterial, material.renderQueue = vgoMaterial.renderQueue; } - ParticleDefinition brpParticleDefinition = vgoMaterial.ToBrpParticleDefinition(allTexture2dList); + ParticleDefinition brpParticleDefinition = vgoMaterial.ToBrpParticleDefinition(allTextureList); UniUrpParticleShader.UrpParticleDefinition urpParticleDefinition = brpParticleDefinition.ToUrpParticleDefinition(); diff --git a/UniVgo2/Runtime/Porters/Materials/SkyboxMaterialPorter.cs b/UniVgo2/Runtime/Porters/Materials/SkyboxMaterialPorter.cs index a6f3df9..2f189de 100644 --- a/UniVgo2/Runtime/Porters/Materials/SkyboxMaterialPorter.cs +++ b/UniVgo2/Runtime/Porters/Materials/SkyboxMaterialPorter.cs @@ -121,9 +121,9 @@ public override VgoMaterial CreateVgoMaterial(in Material material, in IVgoStora /// /// A vgo material. /// A skybox shader. - /// List of all texture 2D. + /// List of all texture. /// A skybox material. - public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTexture2dList) + public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTextureList) { var material = new Material(shader) { @@ -141,7 +141,7 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad { case ShaderName.Skybox_6_Sided: { - var skyboxParameter = vgoMaterial.ToSkybox6SidedDefinition(allTexture2dList); + var skyboxParameter = vgoMaterial.ToSkybox6SidedDefinition(allTextureList); UniSkyboxShader.Utils.SetParametersToMaterial(material, skyboxParameter); } @@ -157,7 +157,7 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad case ShaderName.Skybox_Panoramic: { - var skyboxParameter = vgoMaterial.ToSkyboxPanoramicDefinition(allTexture2dList); + var skyboxParameter = vgoMaterial.ToSkyboxPanoramicDefinition(allTextureList); UniSkyboxShader.Utils.SetParametersToMaterial(material, skyboxParameter); } diff --git a/UniVgo2/Runtime/Porters/Materials/StandardMaterialPorter.cs b/UniVgo2/Runtime/Porters/Materials/StandardMaterialPorter.cs index 3138cfd..9c126bb 100644 --- a/UniVgo2/Runtime/Porters/Materials/StandardMaterialPorter.cs +++ b/UniVgo2/Runtime/Porters/Materials/StandardMaterialPorter.cs @@ -118,9 +118,9 @@ public override VgoMaterial CreateVgoMaterial(in Material material, in IVgoStora /// /// A vgo material. /// A standard shader. - /// List of all texture 2D. + /// List of all texture. /// A standard material. - public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTexture2dList) + public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTextureList) { // Accept all shaders //if (vgoMaterial.shaderName != UniVgo2.ShaderName.Standard) @@ -130,7 +130,7 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad if (shader.name == UniVgo2.ShaderName.URP_Lit) { - return CreateMaterialAssetAsUrp(vgoMaterial, shader, allTexture2dList); + return CreateMaterialAssetAsUrp(vgoMaterial, shader, allTextureList); } var material = new Material(shader) @@ -138,7 +138,7 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad name = vgoMaterial.name }; - StandardDefinition standardDefinition = vgoMaterial.ToStandardDefinition(allTexture2dList); + StandardDefinition standardDefinition = vgoMaterial.ToStandardDefinition(allTextureList); UniStandardShader.Utils.SetParametersToMaterial(material, standardDefinition); @@ -159,9 +159,9 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad /// /// A vgo material. /// A URP lit shader. - /// List of all texture 2D. + /// List of all texture. /// A URP lit material. - protected virtual Material CreateMaterialAssetAsUrp(in VgoMaterial vgoMaterial, Shader shader, in List allTexture2dList) + protected virtual Material CreateMaterialAssetAsUrp(in VgoMaterial vgoMaterial, Shader shader, in List allTextureList) { if (shader.name != UniVgo2.ShaderName.URP_Lit) { @@ -178,7 +178,7 @@ protected virtual Material CreateMaterialAssetAsUrp(in VgoMaterial vgoMaterial, material.renderQueue = vgoMaterial.renderQueue; } - StandardDefinition brpStandardDefinition = vgoMaterial.ToStandardDefinition(allTexture2dList); + StandardDefinition brpStandardDefinition = vgoMaterial.ToStandardDefinition(allTextureList); UniUrpShader.UrpLitDefinition urpLitDefinition = brpStandardDefinition.ToUrpLitDefinition(); diff --git a/UniVgo2/Runtime/Porters/Materials/StandardVColorMaterialPorter.cs b/UniVgo2/Runtime/Porters/Materials/StandardVColorMaterialPorter.cs index b0315a7..3c1131d 100644 --- a/UniVgo2/Runtime/Porters/Materials/StandardVColorMaterialPorter.cs +++ b/UniVgo2/Runtime/Porters/Materials/StandardVColorMaterialPorter.cs @@ -64,13 +64,13 @@ public override VgoMaterial CreateVgoMaterial(in Material material, in IVgoStora /// /// A vgo material. /// A standard shader. - /// List of all texture 2D. + /// List of all texture. /// A standard vertex color material. - public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTexture2dList) + public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTextureList) { if (shader.name == ShaderName.URP_Lit) { - return CreateMaterialAssetAsUrp(vgoMaterial, shader, allTexture2dList); + return CreateMaterialAssetAsUrp(vgoMaterial, shader, allTextureList); } if (vgoMaterial.shaderName != ShaderName.UniGLTF_StandardVColor) @@ -83,7 +83,7 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad ThrowHelper.ThrowArgumentException($"shader.name: {shader.name}"); } - StandardVColorDefinition vgoMaterialParameter = vgoMaterial.ToStandardVColorDefinition(allTexture2dList); + StandardVColorDefinition vgoMaterialParameter = vgoMaterial.ToStandardVColorDefinition(allTextureList); var material = new Material(shader) { @@ -117,19 +117,19 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad /// /// A vgo material. /// A URP lit shader. - /// List of all texture 2D. + /// List of all texture. /// A URP lit material. /// /// @notice Universal Render Pipeline/Lit shader is not support vertex color. /// - protected virtual Material CreateMaterialAssetAsUrp(in VgoMaterial vgoMaterial, Shader shader, in List allTexture2dList) + protected virtual Material CreateMaterialAssetAsUrp(in VgoMaterial vgoMaterial, Shader shader, in List allTextureList) { var material = new Material(shader) { name = vgoMaterial.name }; - StandardVColorDefinition standardVColorDefinition = vgoMaterial.ToStandardVColorDefinition(allTexture2dList); + StandardVColorDefinition standardVColorDefinition = vgoMaterial.ToStandardVColorDefinition(allTextureList); UniUrpShader.UrpLitDefinition urpLitDefinition = standardVColorDefinition.ToUrpLitDefinition(); diff --git a/UniVgo2/Runtime/Porters/Materials/UnlitMaterialPorter.cs b/UniVgo2/Runtime/Porters/Materials/UnlitMaterialPorter.cs index ccb704b..8dbff3a 100644 --- a/UniVgo2/Runtime/Porters/Materials/UnlitMaterialPorter.cs +++ b/UniVgo2/Runtime/Porters/Materials/UnlitMaterialPorter.cs @@ -105,19 +105,19 @@ public override VgoMaterial CreateVgoMaterial(in Material material, in IVgoStora /// /// A vgo material. /// A unlit shader. - /// List of all texture 2D. + /// List of all texture. /// A unlit material. - public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTexture2dList) + public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTextureList) { #if UNIVGO_ENABLE_UNIGLTF_UNIUNLIT if (shader.name == ShaderName.URP_Unlit) { - return CreateMaterialAssetAsUrp(vgoMaterial, shader, allTexture2dList); + return CreateMaterialAssetAsUrp(vgoMaterial, shader, allTextureList); } if (vgoMaterial.shaderName == ShaderName.UniGLTF_UniUnlit) { - UniGltfUnlitDefinition vgoMaterialParameter = vgoMaterial.ToUniGltfUnlitDefinition(allTexture2dList); + UniGltfUnlitDefinition vgoMaterialParameter = vgoMaterial.ToUniGltfUnlitDefinition(allTextureList); var material = new Material(shader) { @@ -150,7 +150,7 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad return material; } - return base.CreateMaterialAsset(vgoMaterial, shader, allTexture2dList); + return base.CreateMaterialAsset(vgoMaterial, shader, allTextureList); #else #if NET_STANDARD_2_1 ThrowHelper.ThrowNotSupportedException(vgoMaterial.shaderName ?? string.Empty); @@ -171,9 +171,9 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad /// /// A vgo material. /// A URP unlit shader. - /// List of all texture 2D. + /// List of all texture. /// A URP unlit material. - protected virtual Material CreateMaterialAssetAsUrp(in VgoMaterial vgoMaterial, Shader shader, in List allTexture2dList) + protected virtual Material CreateMaterialAssetAsUrp(in VgoMaterial vgoMaterial, Shader shader, in List allTextureList) { #if ENABLE_UNITY_URP_SHADER var material = new Material(shader) @@ -181,7 +181,7 @@ protected virtual Material CreateMaterialAssetAsUrp(in VgoMaterial vgoMaterial, name = vgoMaterial.name }; - UniUrpShader.UrpUnlitDefinition urpUnlitMaterialParameter = vgoMaterial.ToUrpUnlitDefinition(allTexture2dList); + UniUrpShader.UrpUnlitDefinition urpUnlitMaterialParameter = vgoMaterial.ToUrpUnlitDefinition(allTextureList); UniUrpShader.Utils.SetParametersToMaterial(material, urpUnlitMaterialParameter); diff --git a/UniVgo2/Runtime/Porters/Materials/UrpMaterialPorter.cs b/UniVgo2/Runtime/Porters/Materials/UrpMaterialPorter.cs index 2cefcbd..6f2efd3 100644 --- a/UniVgo2/Runtime/Porters/Materials/UrpMaterialPorter.cs +++ b/UniVgo2/Runtime/Porters/Materials/UrpMaterialPorter.cs @@ -202,9 +202,9 @@ protected VgoMaterial CreateVgoMaterialFromUrpUnlit(in Material material, in IVg /// /// A vgo material. /// A URP shader. - /// List of all texture 2D. + /// List of all texture. /// A URP material. - public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTexture2dList) + public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTextureList) { switch (vgoMaterial.shaderName) { @@ -224,7 +224,7 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad } - Material material = base.CreateMaterialAsset(vgoMaterial, shader, allTexture2dList); + Material material = base.CreateMaterialAsset(vgoMaterial, shader, allTextureList); SurfaceType? surfaceType = null; BlendMode? blendMode = null; diff --git a/UniVgo2/Runtime/Porters/Materials/UrpMtoon10MaterialPorter.cs b/UniVgo2/Runtime/Porters/Materials/UrpMtoon10MaterialPorter.cs index b448779..30af0ca 100644 --- a/UniVgo2/Runtime/Porters/Materials/UrpMtoon10MaterialPorter.cs +++ b/UniVgo2/Runtime/Porters/Materials/UrpMtoon10MaterialPorter.cs @@ -52,9 +52,9 @@ public override VgoMaterial CreateVgoMaterial(in Material material, in IVgoStora /// /// A vgo material. /// A URP MToon 1.0 shader. - /// List of all texture 2D. + /// List of all texture. /// A URP MToon 1.0 material. - public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTexture2dList) + public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTextureList) { if (vgoMaterial.shaderName != ShaderName.VRM_URP_MToon10) { @@ -67,7 +67,7 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad } #if UNIVGO_ENABLE_MTOON_1_0 - return CreateMaterialAssetInternal(vgoMaterial, shader, allTexture2dList); + return CreateMaterialAssetInternal(vgoMaterial, shader, allTextureList); #else #if NET_STANDARD_2_1 ThrowHelper.ThrowNotSupportedException(vgoMaterial.shaderName); diff --git a/UniVgo2/Runtime/Porters/Materials/UrpParticleMaterialPorter.cs b/UniVgo2/Runtime/Porters/Materials/UrpParticleMaterialPorter.cs index 97cf7b2..7bed169 100644 --- a/UniVgo2/Runtime/Porters/Materials/UrpParticleMaterialPorter.cs +++ b/UniVgo2/Runtime/Porters/Materials/UrpParticleMaterialPorter.cs @@ -123,9 +123,9 @@ public override VgoMaterial CreateVgoMaterial(in Material material, in IVgoStora /// /// A vgo material. /// A URP Particle shader. - /// List of all texture 2D. + /// List of all texture. /// A URP Particle material. - public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTexture2dList) + public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shader shader, in List allTextureList) { switch (vgoMaterial.shaderName) { @@ -151,7 +151,7 @@ public override Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in Shad material.renderQueue = vgoMaterial.renderQueue; } - UrpParticleDefinition definition = vgoMaterial.ToUrpParticleDefinition(allTexture2dList); + UrpParticleDefinition definition = vgoMaterial.ToUrpParticleDefinition(allTextureList); UniUrpParticleShader.Utils.SetParametersToMaterial(material, definition); diff --git a/UniVgo2/Runtime/Porters/Materials/VgoMaterialPorter.cs b/UniVgo2/Runtime/Porters/Materials/VgoMaterialPorter.cs index 2f18d41..aaff777 100644 --- a/UniVgo2/Runtime/Porters/Materials/VgoMaterialPorter.cs +++ b/UniVgo2/Runtime/Porters/Materials/VgoMaterialPorter.cs @@ -90,9 +90,9 @@ public VgoMaterial CreateVgoMaterial(in Material material, in IVgoStorage vgoSto /// Create a material. /// /// A vgo material. - /// List of Texture2D. + /// List of Texture. /// A unity material. - public virtual Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in List texture2dList) + public virtual Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in List textureList) { if (MaterialPorterStore == null) { @@ -118,7 +118,7 @@ public virtual Material CreateMaterialAsset(in VgoMaterial vgoMaterial, in List< //IMaterialPorter materialPorter = MaterialPorterStore.GetPorterOrStandard(shader.name, RenderPipelineType); IMaterialPorter materialPorter = MaterialPorterStore.GetPorterOrStandard(shader.name, vgoMaterial, RenderPipelineType); - Material material = materialPorter.CreateMaterialAsset(vgoMaterial, shader, texture2dList); + Material material = materialPorter.CreateMaterialAsset(vgoMaterial, shader, textureList); #if UNITY_EDITOR material.hideFlags = HideFlags.DontUnloadUnusedAsset; diff --git a/UniVgo2/Runtime/Porters/Materials/VgoMaterialPorterStore.cs b/UniVgo2/Runtime/Porters/Materials/VgoMaterialPorterStore.cs index cc71ad4..7b8432f 100644 --- a/UniVgo2/Runtime/Porters/Materials/VgoMaterialPorterStore.cs +++ b/UniVgo2/Runtime/Porters/Materials/VgoMaterialPorterStore.cs @@ -28,6 +28,13 @@ protected HdrpMaterialPorter HdrpMaterialPorter protected LilToonMaterialPorter LilToonMaterialPorter => _LilToonMaterialPorter ??= new LilToonMaterialPorter(); + /// NOVA Material Porter + protected NovaMaterialPorter? _NovaMaterialPorter; + + /// NOVA Material Porter + protected NovaMaterialPorter NovaMaterialPorter + => _NovaMaterialPorter ??= new NovaMaterialPorter(); + /// MToon Material Porter protected MtoonMaterialPorter? _MtoonMaterialPorter; @@ -302,6 +309,13 @@ public virtual IMaterialPorter GetPorterOrStandard(in VgoMaterial vgoMaterial, i case ShaderName.Lil_LilToonPassLiteTransparent: return LilToonMaterialPorter; + case ShaderName.Nova_Particles_Distortion: + case ShaderName.Nova_Particles_UberLit: + case ShaderName.Nova_Particles_UberUnlit: + case ShaderName.Nova_UIParticles_UberLit: + case ShaderName.Nova_UIParticles_UberUnlit: + return NovaMaterialPorter; + case ShaderName.VRM_MToon: return MtoonMaterialPorter; diff --git a/UniVgo2/Runtime/Porters/Meshes/VgoMeshExporter.cs b/UniVgo2/Runtime/Porters/Meshes/VgoMeshExporter.cs index a310213..914bc98 100644 --- a/UniVgo2/Runtime/Porters/Meshes/VgoMeshExporter.cs +++ b/UniVgo2/Runtime/Porters/Meshes/VgoMeshExporter.cs @@ -171,7 +171,7 @@ protected virtual VgoMesh CreateVgoMesh(IVgoStorage vgoStorage, in MeshAsset mes if (blendShapeConfig != null) { vgoMesh.blendShapeKind = blendShapeConfig.Kind; - vgoMesh.blendShapePesets = blendShapeConfig.Presets; + vgoMesh.blendShapePresets = blendShapeConfig.Presets; } } } diff --git a/UniVgo2/Runtime/Porters/Meshes/VgoMeshImporter.cs b/UniVgo2/Runtime/Porters/Meshes/VgoMeshImporter.cs index e6d7764..27d7000 100644 --- a/UniVgo2/Runtime/Porters/Meshes/VgoMeshImporter.cs +++ b/UniVgo2/Runtime/Porters/Meshes/VgoMeshImporter.cs @@ -398,7 +398,7 @@ protected virtual async Task> CreateMeshContextListParallelAsy for (int meshIndex = 0; meshIndex < vgoStorage.Layout.meshes.Count; meshIndex++) { - int index = meshIndex; // @impotant + int index = meshIndex; // @important Task createMeshContextTask = Task.Run(() => { @@ -493,9 +493,9 @@ protected virtual MeshContext ReadMesh(in IVgoStorage vgoStorage, in int meshInd { blendShapeConfig.Kind = vgoMesh.blendShapeKind; - if (vgoMesh.blendShapePesets != null) + if (vgoMesh.blendShapePresets != null) { - blendShapeConfig.Presets = vgoMesh.blendShapePesets; + blendShapeConfig.Presets = vgoMesh.blendShapePresets; } } } diff --git a/UniVgo2/Runtime/Porters/ParticleSystems/VgoParticleSystemExporter.cs b/UniVgo2/Runtime/Porters/ParticleSystems/VgoParticleSystemExporter.cs index 6642f89..56334ae 100644 --- a/UniVgo2/Runtime/Porters/ParticleSystems/VgoParticleSystemExporter.cs +++ b/UniVgo2/Runtime/Porters/ParticleSystems/VgoParticleSystemExporter.cs @@ -54,10 +54,10 @@ public virtual VgoParticleSystem Create( //Collision = CreateVgoModule(particleSystem.collision), //Trigger = CreateVgoModule(particleSystem.trigger), //SubEmitters = CreateVgoModule(particleSystem.subEmitters), - //TextureSheetAnimation = CreateVgoModule(particleSystem.textureSheetAnimation), + textureSheetAnimation = CreateVgoModule(particleSystem.textureSheetAnimation), lights = CreateVgoModule(particleSystem.lights), trails = CreateVgoModule(particleSystem.trails), - //CustomData = CreateVgoModule(particleSystem.customData), + customData = CreateVgoModule(particleSystem.customData), renderer = CreateVgoPsRenderer(particleSystemRenderer, vgoStorage.GeometryCoordinate, vgoStorage.Layout), }; @@ -677,13 +677,28 @@ protected virtual VGO_PS_SubEmittersModule CreateVgoModule(in SubEmittersModule /// protected virtual VGO_PS_TextureSheetAnimationModule CreateVgoModule(in TextureSheetAnimationModule module) { -#if NET_STANDARD_2_1 - ThrowHelper.ThrowNotImplementedException(); + // @todo sprites (texture) + //int spriteCount = module.spriteCount; - return default; -#else - throw new NotImplementedException(); -#endif + return new VGO_PS_TextureSheetAnimationModule() + { + enabled = module.enabled, + mode = (NewtonVgo.ParticleSystemAnimationMode)module.mode, + numTilesX = module.numTilesX, + numTilesY = module.numTilesY, + animation = (NewtonVgo.ParticleSystemAnimationType)module.animation, + rowMode = (NewtonVgo.ParticleSystemAnimationRowMode)module.rowMode, + rowIndex = module.rowIndex, + timeMode = (NewtonVgo.ParticleSystemAnimationTimeMode)module.timeMode, + frameOverTime = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.frameOverTime), + frameOverTimeMultiplier = module.frameOverTimeMultiplier, + speedRange = module.speedRange.ToNumericsVector2(), + fps = module.fps, + startFrame = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startFrame), + startFrameMultiplier = module.startFrameMultiplier, + cycleCount = module.cycleCount, + uvChannelMask = (UVChannelFlags)module.uvChannelMask, + }; } /// @@ -726,13 +741,7 @@ protected virtual VGO_PS_TrailModule CreateVgoModule(in TrailModule module) /// protected virtual VGO_PS_CustomDataModule CreateVgoModule(in CustomDataModule module) { -#if NET_STANDARD_2_1 - ThrowHelper.ThrowNotImplementedException(); - - return default; -#else - throw new NotImplementedException(); -#endif + return VgoParticleSystemCustomDataConverter.CreateFrom(module); } /// diff --git a/UniVgo2/Runtime/Porters/ParticleSystems/VgoParticleSystemImporter.cs b/UniVgo2/Runtime/Porters/ParticleSystems/VgoParticleSystemImporter.cs index 969fbff..3abe6fe 100644 --- a/UniVgo2/Runtime/Porters/ParticleSystems/VgoParticleSystemImporter.cs +++ b/UniVgo2/Runtime/Porters/ParticleSystems/VgoParticleSystemImporter.cs @@ -28,14 +28,16 @@ public class VgoParticleSystemImporter : IVgoParticleSystemImporter /// /// /// - /// + /// + /// /// Returns ParticleSystem component. public virtual ParticleSystem AddComponent( GameObject go, in VgoParticleSystem vgoParticleSystem, in VgoGeometryCoordinate geometryCoordinate, in IList? materialList, - in IList? texture2dList) + in IList? textureList, + in bool forceSetRuntimeDuration) { if (go.TryGetComponentEx(out var particleSystem) == false) { @@ -49,7 +51,7 @@ public virtual ParticleSystem AddComponent( if (vgoParticleSystem.main != null) { - SetModuleValue(particleSystem, vgoParticleSystem.main, geometryCoordinate); + SetModuleValue(particleSystem, vgoParticleSystem.main, geometryCoordinate, forceSetRuntimeDuration); } if (vgoParticleSystem.emission != null) { @@ -57,7 +59,7 @@ public virtual ParticleSystem AddComponent( } if (vgoParticleSystem.shape != null) { - SetModuleValue(particleSystem, vgoParticleSystem.shape, texture2dList, geometryCoordinate); + SetModuleValue(particleSystem, vgoParticleSystem.shape, textureList, geometryCoordinate); } if (vgoParticleSystem.velocityOverLifetime != null) { @@ -110,7 +112,10 @@ public virtual ParticleSystem AddComponent( //SetModuleValue(particleSystem, vgoParticleSystem.Collision); //SetModuleValue(particleSystem, vgoParticleSystem.Trigger); //SetModuleValue(particleSystem, vgoParticleSystem.SubEmitters); - //SetModuleValue(particleSystem, vgoParticleSystem.TextureSheetAnimation); + if (vgoParticleSystem.textureSheetAnimation != null) + { + SetModuleValue(particleSystem, vgoParticleSystem.textureSheetAnimation); + } if (vgoParticleSystem.lights != null) { SetModuleValue(particleSystem, vgoParticleSystem.lights); @@ -119,7 +124,10 @@ public virtual ParticleSystem AddComponent( { SetModuleValue(particleSystem, vgoParticleSystem.trails); } - //SetModuleValue(particleSystem, vgoParticleSystem.CustomData); + if (vgoParticleSystem.customData != null) + { + SetModuleValue(particleSystem, vgoParticleSystem.customData); + } if (vgoParticleSystem.renderer != null) { @@ -147,7 +155,8 @@ public virtual ParticleSystem AddComponent( /// /// /// - protected virtual void SetModuleValue(ParticleSystem particleSystem, in VGO_PS_MainModule vgoModule, in VgoGeometryCoordinate geometryCoordinate) + /// + protected virtual void SetModuleValue(ParticleSystem particleSystem, in VGO_PS_MainModule vgoModule, in VgoGeometryCoordinate geometryCoordinate, in bool forceSetRuntimeDuration) { if (vgoModule == null) { @@ -156,8 +165,24 @@ protected virtual void SetModuleValue(ParticleSystem particleSystem, in VGO_PS_M MainModule module = particleSystem.main; - // @notice - if (Application.isPlaying == false) + if (Application.isPlaying) + { + if (module.duration != vgoModule.duration) + { + if (forceSetRuntimeDuration) + { + try + { + module.duration = vgoModule.duration; + } + catch (Exception ex) + { + Debug.LogException(ex); + } + } + } + } + else { module.duration = vgoModule.duration; } @@ -270,9 +295,9 @@ protected virtual void SetModuleValue(ParticleSystem particleSystem, in VGO_PS_E /// /// /// - /// + /// /// - protected virtual void SetModuleValue(ParticleSystem particleSystem, in VGO_PS_ShapeModule vgoModule, in IList? texture2dList, in VgoGeometryCoordinate geometryCoordinate) + protected virtual void SetModuleValue(ParticleSystem particleSystem, in VGO_PS_ShapeModule vgoModule, in IList? textureList, in VgoGeometryCoordinate geometryCoordinate) { if (vgoModule == null) { @@ -312,11 +337,13 @@ protected virtual void SetModuleValue(ParticleSystem particleSystem, in VGO_PS_S //module.sprite; //module.spriteRenderer; module.normalOffset = vgoModule.normalOffset; - if ((texture2dList != null) && (-1 < vgoModule.textureIndex) && (vgoModule.textureIndex < texture2dList.Count)) + if ((textureList != null) && (-1 < vgoModule.textureIndex) && (vgoModule.textureIndex < textureList.Count)) { - if (texture2dList[vgoModule.textureIndex] != null) + Texture? texture = textureList[vgoModule.textureIndex]; + + if (texture is Texture2D texture2D) { - module.texture = texture2dList[vgoModule.textureIndex]; + module.texture = texture2D; } } module.textureClipChannel = (UnityEngine.ParticleSystemShapeTextureChannel)vgoModule.textureClipChannel; @@ -421,7 +448,7 @@ protected virtual void SetModuleValue(ParticleSystem particleSystem, in VGO_PS_L } /// - /// Set ParticleSystem inhelitVelocity field value. + /// Set ParticleSystem inheritVelocity field value. /// /// /// @@ -761,7 +788,47 @@ protected virtual void SetModuleValue(ParticleSystem particleSystem, in VGO_PS_S /// protected virtual void SetModuleValue(ParticleSystem particleSystem, in VGO_PS_TextureSheetAnimationModule vgoModule) { - ThrowHelper.ThrowNotImplementedException(); + if (vgoModule == null) + { + return; + } + + TextureSheetAnimationModule module = particleSystem.textureSheetAnimation; + + module.enabled = vgoModule.enabled; + + module.mode = (UnityEngine.ParticleSystemAnimationMode)vgoModule.mode; + + module.numTilesX = vgoModule.numTilesX; + module.numTilesY = vgoModule.numTilesY; + + module.animation = (UnityEngine.ParticleSystemAnimationType)vgoModule.animation; + + module.rowMode = (UnityEngine.ParticleSystemAnimationRowMode)vgoModule.rowMode; + module.rowIndex = vgoModule.rowIndex; + + module.timeMode = (UnityEngine.ParticleSystemAnimationTimeMode)vgoModule.timeMode; + + if (vgoModule.timeMode == NewtonVgo.ParticleSystemAnimationTimeMode.Lifetime) + { + module.frameOverTime = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.frameOverTime); + module.frameOverTimeMultiplier = vgoModule.frameOverTimeMultiplier; + } + else if (vgoModule.timeMode == NewtonVgo.ParticleSystemAnimationTimeMode.Speed) + { + module.speedRange = vgoModule.speedRange.GetValueOrDefault().ToUnityVector2(); + } + else if (vgoModule.timeMode == NewtonVgo.ParticleSystemAnimationTimeMode.FPS) + { + module.fps = vgoModule.fps; + } + + module.startFrame = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startFrame); + module.startFrameMultiplier = vgoModule.startFrameMultiplier; + + module.cycleCount = vgoModule.cycleCount; + + module.uvChannelMask = (UnityEngine.Rendering.UVChannelFlags)vgoModule.uvChannelMask; } /// @@ -860,7 +927,81 @@ protected virtual void SetModuleValue(ParticleSystem particleSystem, in VGO_PS_T /// protected virtual void SetModuleValue(ParticleSystem particleSystem, in VGO_PS_CustomDataModule vgoModule) { - ThrowHelper.ThrowNotImplementedException(); + if (vgoModule == null) + { + return; + } + + CustomDataModule module = particleSystem.customData; + + module.enabled = vgoModule.enabled; + + if (vgoModule.customData == null || vgoModule.customData.Length == 0) + { + return; + } + + for (int customDataIndex = 0; customDataIndex < vgoModule.customData.Length; customDataIndex++) + { + VGO_PS_CustomData vgoCustomData = vgoModule.customData[customDataIndex]; + + UnityEngine.ParticleSystemCustomData stream; + + if (vgoCustomData.stream == NewtonVgo.ParticleSystemCustomData.Custom1) + { + stream = UnityEngine.ParticleSystemCustomData.Custom1; + } + else if (vgoCustomData.stream == NewtonVgo.ParticleSystemCustomData.Custom2) + { + stream = UnityEngine.ParticleSystemCustomData.Custom2; + } + else + { + continue; + } + + module.SetMode(stream, (UnityEngine.ParticleSystemCustomDataMode)vgoCustomData.mode); + + if (vgoCustomData.mode == NewtonVgo.ParticleSystemCustomDataMode.Disabled) + { + module.SetVectorComponentCount(stream, 0); + + continue; + } + + if (vgoCustomData.mode == NewtonVgo.ParticleSystemCustomDataMode.Vector) + { + if (vgoCustomData.vector == null || vgoCustomData.vector.Length == 0) + { + module.SetVectorComponentCount(stream, 0); + + continue; + } + + module.SetVectorComponentCount(stream, vgoCustomData.vector.Length); + + // X, Y, Z, W + for (int componentIndex = 0; componentIndex < vgoCustomData.vector.Length; componentIndex++) + { + VGO_PS_MinMaxCurve? vgoComponentCurve = vgoCustomData.vector[componentIndex]; + + MinMaxCurve componentCurve = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoComponentCurve); + + module.SetVector(stream, componentIndex, componentCurve); + } + } + else + { + module.SetVectorComponentCount(stream, 0); + } + + if (vgoCustomData.mode == NewtonVgo.ParticleSystemCustomDataMode.Color) + { + MinMaxGradient colorGradient = VgoParticleSystemMinMaxGradientConverter.CreateMinMaxGradient(vgoCustomData.color); + + module.SetColor(stream, colorGradient); + } + } } #endregion diff --git a/UniVgo2/Runtime/Porters/Textures/VgoTextureExporter.cs b/UniVgo2/Runtime/Porters/Textures/VgoTextureExporter.cs index cf4c3b7..e6dc95f 100644 --- a/UniVgo2/Runtime/Porters/Textures/VgoTextureExporter.cs +++ b/UniVgo2/Runtime/Porters/Textures/VgoTextureExporter.cs @@ -80,17 +80,14 @@ protected virtual int ExportTexture( return -1; } - if (!(texture is Texture2D srcTexture2d)) - { - return -1; - } + Texture srcTexture = texture; if (vgoStorage.Layout.textures == null) { vgoStorage.Layout.textures = new List(); } - int srcTextureInstanceId = srcTexture2d.GetInstanceID(); + int srcTextureInstanceId = srcTexture.GetInstanceID(); VgoTexture? vgoTexture = vgoStorage.Layout.textures .FirstOrDefault(x => x?.id == srcTextureInstanceId); @@ -102,14 +99,57 @@ protected virtual int ExportTexture( float metallicSmoothness = (metallicRoughness == -1.0f) ? -1.0f : (1.0f - metallicRoughness); - Texture2D convertedTexture2d = _TextureConverter.GetExportTexture(srcTexture2d, textureMapType, colorSpaceType, metallicSmoothness); + Texture convertedTexture = _TextureConverter.GetExportTexture(srcTexture, textureMapType, colorSpaceType, metallicSmoothness); - int width = convertedTexture2d.width; + int width = convertedTexture.width; - int height = convertedTexture2d.height; + int height = convertedTexture.height; string mimeType; byte[] imageBytes; + byte[] textureData; + //int depth = 0; + + if (convertedTexture is Texture2D convertedTexture2d) + { + textureData = convertedTexture2d.GetRawTextureData(); + } + else if (convertedTexture is Texture2DArray convertedTexture2dArray) + { + //depth = convertedTexture2dArray.depth; + + // @notice + var elementDataList = new List(convertedTexture2dArray.depth); + + for (int elementIndex = 0; elementIndex < convertedTexture2dArray.depth; elementIndex++) + { + byte[] elementData = convertedTexture2dArray.GetPixelData(mipLevel: 0, elementIndex).ToArray(); + + elementDataList.Add(elementData); + } + + textureData = new byte[elementDataList.Sum(e => e.Length)]; + + int offset = 0; + + foreach (byte[] elementData in elementDataList) + { + Buffer.BlockCopy(elementData, 0, textureData, offset, elementData.Length); + + offset += elementData.Length; + } + } + else if (convertedTexture is Texture3D convertedTexture3d) + { + //depth = convertedTexture3d.depth; + + // @notice + textureData = convertedTexture3d.GetPixelData(mipLevel: 0).ToArray(); + } + else + { + return -1; + } if (TextureType == ImageType.WebP) { @@ -119,19 +159,17 @@ protected virtual int ExportTexture( try { - byte[] textureData = convertedTexture2d.GetRawTextureData(); - - byte[]? pngBytes = ImageConversion.EncodeArrayToPNG(textureData, convertedTexture2d.graphicsFormat, (uint)width, (uint)height); + byte[]? pngBytes = ImageConversion.EncodeArrayToPNG(textureData, convertedTexture.graphicsFormat, (uint)width, (uint)height); if (pngBytes == null) { - ThrowHelper.ThrowBadImageFormatException(srcTexture2d.name); + ThrowHelper.ThrowBadImageFormatException(srcTexture.name); return -1; } // @heavy - webpBytes = ImageConverter.ConvertToWebp(pngBytes, ImageType.PNG, srcTexture2d.name, flipVertical: false); + webpBytes = ImageConverter.ConvertToWebp(pngBytes, ImageType.PNG, srcTexture.name, flipVertical: false); } catch (Exception ex) { @@ -151,9 +189,7 @@ protected virtual int ExportTexture( { mimeType = MimeType.Image_Jpeg; - byte[] textureData = convertedTexture2d.GetRawTextureData(); - - byte[]? jpgBytes = ImageConversion.EncodeArrayToJPG(textureData, convertedTexture2d.graphicsFormat, (uint)width, (uint)height, quality: 100); + byte[]? jpgBytes = ImageConversion.EncodeArrayToJPG(textureData, convertedTexture.graphicsFormat, (uint)width, (uint)height, quality: 100); if (jpgBytes == null) { @@ -166,9 +202,7 @@ protected virtual int ExportTexture( { mimeType = MimeType.Image_Png; - byte[] textureData = convertedTexture2d.GetRawTextureData(); - - byte[]? pngBytes = ImageConversion.EncodeArrayToPNG(textureData, convertedTexture2d.graphicsFormat, (uint)width, (uint)height); + byte[]? pngBytes = ImageConversion.EncodeArrayToPNG(textureData, convertedTexture.graphicsFormat, (uint)width, (uint)height); if (pngBytes == null) { @@ -183,16 +217,19 @@ protected virtual int ExportTexture( vgoTexture = new VgoTexture { id = srcTextureInstanceId, - name = convertedTexture2d.name, + name = convertedTexture.name, source = accessorIndex, - dimensionType = (TextureDimension)srcTexture2d.dimension, + //width = convertedTexture.width, + //height = convertedTexture.height, + //depth = depth, + dimensionType = (TextureDimension)srcTexture.dimension, mapType = textureMapType, colorSpace = colorSpaceType, mimeType = mimeType, - filterMode = (NewtonVgo.FilterMode)srcTexture2d.filterMode, - wrapMode = (NewtonVgo.TextureWrapMode)srcTexture2d.wrapMode, - wrapModeU = (NewtonVgo.TextureWrapMode)srcTexture2d.wrapModeU, - wrapModeV = (NewtonVgo.TextureWrapMode)srcTexture2d.wrapModeV, + filterMode = (NewtonVgo.FilterMode)srcTexture.filterMode, + wrapMode = (NewtonVgo.TextureWrapMode)srcTexture.wrapMode, + wrapModeU = (NewtonVgo.TextureWrapMode)srcTexture.wrapModeU, + wrapModeV = (NewtonVgo.TextureWrapMode)srcTexture.wrapModeV, metallicRoughness = metallicRoughness, }; diff --git a/UniVgo2/Runtime/Porters/Textures/VgoTextureImporter.cs b/UniVgo2/Runtime/Porters/Textures/VgoTextureImporter.cs index 17d7775..072ffe0 100644 --- a/UniVgo2/Runtime/Porters/Textures/VgoTextureImporter.cs +++ b/UniVgo2/Runtime/Porters/Textures/VgoTextureImporter.cs @@ -66,15 +66,15 @@ public VgoTextureImporter() /// Create texture assets. /// /// A vgo storage. - /// List of unity texture2D. - public virtual List CreateTextureAssets(in IVgoStorage vgoStorage) + /// List of unity texture. + public virtual List CreateTextureAssets(in IVgoStorage vgoStorage) { if ((vgoStorage.Layout.textures == null) || (vgoStorage.Layout.textures.Any() == false)) { - return new List(0); + return new List(0); } - var texture2dList = new List(vgoStorage.Layout.textures.Count); + var textureList = new List(vgoStorage.Layout.textures.Count); for (int textureIndex = 0; textureIndex < vgoStorage.Layout.textures.Count; textureIndex++) { @@ -82,26 +82,26 @@ public VgoTextureImporter() if (vgoTexture is null) { - texture2dList.Add(null); + textureList.Add(null); continue; } try { - Texture2D? texture2d = CreateTexture2d(vgoTexture, vgoStorage); + Texture? texture = CreateTexture(vgoTexture, vgoStorage); - texture2dList.Add(texture2d); + textureList.Add(texture); } catch (Exception ex) { Debug.LogException(ex); - texture2dList.Add(null); + textureList.Add(null); } } - return texture2dList; + return textureList; } /// @@ -109,21 +109,21 @@ public VgoTextureImporter() /// /// A vgo storage. /// The token to monitor for cancellation requests. - /// List of unity texture2D. + /// List of unity texture. #if UNITY_2023_1_OR_NEWER && UNIVGO_USE_UNITY_AWAITABLE - public virtual async Awaitable> CreateTextureAssetsAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken) + public virtual async Awaitable> CreateTextureAssetsAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken) #elif CYSHARP_UNITASK_2_OR_NEWER && UNIVGO_USE_UNITASK - public virtual async UniTask> CreateTextureAssetsAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken) + public virtual async UniTask> CreateTextureAssetsAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken) #else - public virtual async Task> CreateTextureAssetsAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken) + public virtual async Task> CreateTextureAssetsAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken) #endif { if ((vgoStorage.Layout.textures == null) || (vgoStorage.Layout.textures.Any() == false)) { - return new List(0); + return new List(0); } - var texture2dList = new List(vgoStorage.Layout.textures.Count); + var textureList = new List(vgoStorage.Layout.textures.Count); for (int textureIndex = 0; textureIndex < vgoStorage.Layout.textures.Count; textureIndex++) { @@ -133,16 +133,16 @@ public VgoTextureImporter() if (vgoTexture is null) { - texture2dList.Add(null); + textureList.Add(null); continue; } try { - Texture2D? texture2d = await CreateTexture2dAsync(vgoTexture, vgoStorage, cancellationToken); + Texture? texture = await CreateTextureAsync(vgoTexture, vgoStorage, cancellationToken); - texture2dList.Add(texture2d); + textureList.Add(texture); } catch (OperationCanceledException) { @@ -152,11 +152,11 @@ public VgoTextureImporter() { Debug.LogException(ex); - texture2dList.Add(null); + textureList.Add(null); } } - return texture2dList; + return textureList; } /// @@ -164,25 +164,25 @@ public VgoTextureImporter() /// /// A vgo storage. /// The token to monitor for cancellation requests. - /// List of unity texture2D. + /// List of unity texture. #if UNITY_2023_1_OR_NEWER && UNIVGO_USE_UNITY_AWAITABLE - public virtual async Awaitable> CreateTextureAssetsParallelAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken) + public virtual async Awaitable> CreateTextureAssetsParallelAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken) #elif CYSHARP_UNITASK_2_OR_NEWER && UNIVGO_USE_UNITASK - public virtual async UniTask> CreateTextureAssetsParallelAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken) + public virtual async UniTask> CreateTextureAssetsParallelAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken) #else - public virtual async Task> CreateTextureAssetsParallelAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken) + public virtual async Task> CreateTextureAssetsParallelAsync(IVgoStorage vgoStorage, CancellationToken cancellationToken) #endif { if ((vgoStorage.Layout.textures == null) || (vgoStorage.Layout.textures.Any() == false)) { - return new List(0); + return new List(0); } List imageInfoListForWebp = await CreateImageInfoListForWebpParallelAsync(vgoStorage, cancellationToken); cancellationToken.ThrowIfCancellationRequested(); - var texture2dList = new List(vgoStorage.Layout.textures.Count); + var textureList = new List(vgoStorage.Layout.textures.Count); for (int textureIndex = 0; textureIndex < vgoStorage.Layout.textures.Count; textureIndex++) { @@ -192,7 +192,7 @@ public VgoTextureImporter() if (vgoTexture is null) { - texture2dList.Add(null); + textureList.Add(null); continue; } @@ -204,20 +204,20 @@ public VgoTextureImporter() if (imageInfoListForWebp.TryGetValue(textureIndex, out ImageInfo? imageInfo) == false || imageInfo == null) { - texture2dList.Add(null); + textureList.Add(null); continue; } - Texture2D? texture2D = CreateTexture2dInternal1(vgoTexture, imageInfo); + Texture? texture = CreateTextureInternal1(vgoTexture, imageInfo); - texture2dList.Add(texture2D); + textureList.Add(texture); } else { - Texture2D? texture2d = await CreateTexture2dAsync(vgoTexture, vgoStorage, cancellationToken); + Texture? texture = await CreateTextureAsync(vgoTexture, vgoStorage, cancellationToken); - texture2dList.Add(texture2d); + textureList.Add(texture); } } catch (OperationCanceledException) @@ -228,11 +228,11 @@ public VgoTextureImporter() { Debug.LogException(ex); - texture2dList.Add(null); + textureList.Add(null); } } - return texture2dList; + return textureList; } #endregion @@ -240,12 +240,12 @@ public VgoTextureImporter() #region Protected Methods /// - /// Create a unity texture 2D. + /// Create a unity texture. /// /// A vgo texture. /// A vgo storage. - /// A unity texture 2D. - protected virtual Texture2D? CreateTexture2d(in VgoTexture vgoTexture, in IVgoStorage vgoStorage) + /// A unity texture. + protected virtual Texture? CreateTexture(in VgoTexture vgoTexture, in IVgoStorage vgoStorage) { if (vgoStorage.ResourceAccessors is null) { @@ -259,12 +259,12 @@ public VgoTextureImporter() return null; } - if (vgoTexture.dimensionType != TextureDimension.Tex2D) - { - Debug.LogError($"{nameof(VgoTexture)}.{nameof(vgoTexture.dimensionType)}: {vgoTexture.dimensionType}"); + //if (vgoTexture.dimensionType != TextureDimension.Tex2D) + //{ + // Debug.LogError($"{nameof(VgoTexture)}.{nameof(vgoTexture.dimensionType)}: {vgoTexture.dimensionType}"); - return null; - } + // return null; + //} byte[] imageBytes = vgoStorage.GetResourceDataAsByteArray(vgoTexture.source); @@ -283,34 +283,61 @@ public VgoTextureImporter() return null; } - return CreateTexture2dInternal1(vgoTexture, imageInfo); + return CreateTextureInternal1(vgoTexture, imageInfo); } else { - var srcTexture2d = new Texture2D(width: 2, height: 2, TextureFormat.ARGB32, mipChain: false, linear: vgoTexture.IsLinear) + if (vgoTexture.dimensionType == TextureDimension.Tex2D) { - name = vgoTexture.name - }; + var srcTexture2d = new Texture2D(width: 2, height: 2, TextureFormat.ARGB32, mipChain: false, linear: vgoTexture.IsLinear) + { + name = vgoTexture.name + }; + + ImageConversion.LoadImage(srcTexture2d, imageBytes); + + return CreateTextureInternal2(vgoTexture, srcTexture2d); + } + else if (vgoTexture.dimensionType == TextureDimension.Tex2DArray) + { + //var srcTexture2dArray = new Texture2DArray(vgoTexture.width, vgoTexture.height, vgoTexture.depth, TextureFormat.ARGB32, mipChain: false, linear: vgoTexture.IsLinear) + //{ + // name = vgoTexture.name + //}; + + //ImageConversion.LoadImage(srcTexture2dArray, imageBytes); + + //return CreateTextureInternal2(vgoTexture, srcTexture2dArray); + } + else if (vgoTexture.dimensionType == TextureDimension.Tex3D) + { + //var srcTexture3d = new Texture3D(vgoTexture.width, vgoTexture.height, vgoTexture.depth, TextureFormat.ARGB32, mipChain: false) + //{ + // name = vgoTexture.name + //}; - ImageConversion.LoadImage(srcTexture2d, imageBytes); + //ImageConversion.LoadImage(srcTexture3d, imageBytes); + + //return CreateTextureInternal2(vgoTexture, srcTexture3d); + } - return CreateTexture2dInternal2(vgoTexture, srcTexture2d); + return null; } } /// - /// Create a unity texture 2D. + /// Create a unity texture. /// /// A vgo texture. /// A vgo storage. /// The token to monitor for cancellation requests. - /// A unity texture 2D. + /// A unity texture. #if UNITY_2023_1_OR_NEWER && UNIVGO_USE_UNITY_AWAITABLE - protected virtual async Awaitable CreateTexture2dAsync(VgoTexture vgoTexture, IVgoStorage vgoStorage, CancellationToken cancellationToken) + protected virtual async Awaitable CreateTextureAsync(VgoTexture vgoTexture, IVgoStorage vgoStorage, CancellationToken cancellationToken) #elif CYSHARP_UNITASK_2_OR_NEWER && UNIVGO_USE_UNITASK - protected virtual async UniTask CreateTexture2dAsync(VgoTexture vgoTexture, IVgoStorage vgoStorage, CancellationToken cancellationToken) + protected virtual async UniTask CreateTextureAsync(VgoTexture vgoTexture, IVgoStorage vgoStorage, CancellationToken cancellationToken) #else - protected virtual async Task CreateTexture2dAsync(VgoTexture vgoTexture, IVgoStorage vgoStorage, CancellationToken cancellationToken) + protected virtual async Task CreateTextureAsync(VgoTexture vgoTexture, IVgoStorage vgoStorage, CancellationToken cancellationToken) #endif { if (vgoTexture.mimeType == MimeType.Image_WebP) @@ -333,63 +360,131 @@ public VgoTextureImporter() return null; } - return CreateTexture2dInternal1(vgoTexture, imageInfo); + return CreateTextureInternal1(vgoTexture, imageInfo); } else { // @notice sync - Texture2D? texture2D = CreateTexture2d(vgoTexture, vgoStorage); + Texture? texture = CreateTexture(vgoTexture, vgoStorage); #if UNITY_2023_1_OR_NEWER && UNIVGO_USE_UNITY_AWAITABLE //await Awaitable.NextFrameAsync(cancellationToken); - return texture2D; + return texture; #elif CYSHARP_UNITASK_2_OR_NEWER && UNIVGO_USE_UNITASK - return await UniTask.FromResult(texture2D); + return await UniTask.FromResult(texture); #else - return await Task.FromResult(texture2D); + return await Task.FromResult(texture); #endif } } /// - /// Create a unity texture 2D. + /// Create a unity texture. /// /// A vgo texture. /// An image info. - /// A unity texture 2D. - protected virtual Texture2D? CreateTexture2dInternal1(in VgoTexture vgoTexture, in ImageInfo imageInfo) + /// A unity texture. + protected virtual Texture? CreateTextureInternal1(in VgoTexture vgoTexture, in ImageInfo imageInfo) { - var srcTexture2d = new Texture2D(imageInfo.Width, imageInfo.Height, TextureFormat.ARGB32, mipChain: false, linear: vgoTexture.IsLinear) + if (vgoTexture.dimensionType == TextureDimension.Tex2D) + { + var srcTexture2d = new Texture2D(imageInfo.Width, imageInfo.Height, TextureFormat.ARGB32, mipChain: false, linear: vgoTexture.IsLinear) + { + name = vgoTexture.name + }; + + srcTexture2d.SetPixels32(imageInfo.Pixels); + + srcTexture2d.Apply(); + + return CreateTextureInternal2(vgoTexture, srcTexture2d); + } + else if (vgoTexture.dimensionType == TextureDimension.Tex2DArray) { - name = vgoTexture.name - }; + //var srcTexture2dArray = new Texture2DArray(imageInfo.Width, imageInfo.Height, vgoTexture.depth, TextureFormat.ARGB32, mipChain: false, linear: vgoTexture.IsLinear) + //{ + // name = vgoTexture.name + //}; - srcTexture2d.SetPixels32(imageInfo.Pixels); + //for (int elementIndex = 0; elementIndex < vgoTexture.depth; elementIndex++) + //{ + // //srcTexture2dArray.SetPixels32(imageInfo.Pixels, elementIndex); - srcTexture2d.Apply(); + // srcTexture2dArray.Apply(); + //} - return CreateTexture2dInternal2(vgoTexture, srcTexture2d); + //return CreateTextureInternal2(vgoTexture, srcTexture2dArray); + } + else if (vgoTexture.dimensionType == TextureDimension.Tex3D) + { + //var srcTexture3d = new Texture3D(imageInfo.Width, imageInfo.Height, vgoTexture.depth, TextureFormat.ARGB32, mipChain: false) + //{ + // name = vgoTexture.name + //}; + + //srcTexture3d.SetPixels32(imageInfo.Pixels); + + //srcTexture3d.Apply(); + + //return CreateTextureInternal2(vgoTexture, srcTexture3d); + } + + return null; } /// - /// Create a unity texture 2D. + /// Create a unity texture. /// /// A vgo texture. - /// - /// A unity texture 2D. - protected virtual Texture2D? CreateTexture2dInternal2(in VgoTexture vgoTexture, in Texture2D srcTexture2d) + /// + /// A unity texture. + protected virtual Texture? CreateTextureInternal2(in VgoTexture vgoTexture, in Texture srcTexture) { - Texture2D texture2D = _TextureConverter.GetImportTexture(srcTexture2d, vgoTexture.mapType, vgoTexture.metallicRoughness); + if (srcTexture is Texture2D) + { + // OK + } + else if (srcTexture is Texture2DArray) + { + // OK + } + else if (srcTexture is Texture3D) + { + // OK + } + else + { + return null; + } + + Texture texture = _TextureConverter.GetImportTexture(srcTexture, vgoTexture.mapType, vgoTexture.metallicRoughness); + + texture.filterMode = (UnityEngine.FilterMode)vgoTexture.filterMode; + texture.wrapMode = (UnityEngine.TextureWrapMode)vgoTexture.wrapMode; + texture.wrapModeU = (UnityEngine.TextureWrapMode)vgoTexture.wrapModeU; + texture.wrapModeV = (UnityEngine.TextureWrapMode)vgoTexture.wrapModeV; + + if (texture is Texture2D texture2D) + { + texture2D.Apply(); - texture2D.filterMode = (UnityEngine.FilterMode)vgoTexture.filterMode; - texture2D.wrapMode = (UnityEngine.TextureWrapMode)vgoTexture.wrapMode; - texture2D.wrapModeU = (UnityEngine.TextureWrapMode)vgoTexture.wrapModeU; - texture2D.wrapModeV = (UnityEngine.TextureWrapMode)vgoTexture.wrapModeV; + return texture2D; + } + else if (texture is Texture2DArray texture2DArray) + { + texture2DArray.Apply(); - texture2D.Apply(); + return texture2DArray; + } + else if (texture is Texture3D texture3D) + { + texture3D.Apply(); + + return texture3D; + } - return texture2D; + return null; } #endregion @@ -479,7 +574,7 @@ public VgoTextureImporter() for (int textureIndex = 0; textureIndex < vgoStorage.Layout.textures.Count; textureIndex++) { - int index = textureIndex; // @impotant + int index = textureIndex; // @important Task createImageInfoTask = Task.Run(async () => { diff --git a/UniVgo2/Runtime/Porters/VgoExporter.cs b/UniVgo2/Runtime/Porters/VgoExporter.cs index 3883106..1dd9af1 100644 --- a/UniVgo2/Runtime/Porters/VgoExporter.cs +++ b/UniVgo2/Runtime/Porters/VgoExporter.cs @@ -557,7 +557,7 @@ protected virtual VgoNode CreateVgoNode(in int nodeIndex, in IVgoStorage vgoStor if (vgoBlendShapeComponent.BlendShapeConfiguration != null) { vgoMeshRenderer.blendShapeKind = vgoBlendShapeComponent.BlendShapeConfiguration.Kind; - vgoMeshRenderer.blendShapePesets = vgoBlendShapeComponent.BlendShapeConfiguration.Presets; + vgoMeshRenderer.blendShapePresets = vgoBlendShapeComponent.BlendShapeConfiguration.Presets; } } diff --git a/UniVgo2/Runtime/Porters/VgoImporter.Internal.cs b/UniVgo2/Runtime/Porters/VgoImporter.Internal.cs index c71ab17..acc136b 100644 --- a/UniVgo2/Runtime/Porters/VgoImporter.Internal.cs +++ b/UniVgo2/Runtime/Porters/VgoImporter.Internal.cs @@ -39,11 +39,11 @@ protected virtual VgoModelAsset LoadInternal(in IVgoStorage vgoStorage) vgoModelAsset.Layout = vgoStorage.Layout; - // UnityEngine.Texture2D - vgoModelAsset.Texture2dList = _TextureImporter.CreateTextureAssets(vgoStorage); + // UnityEngine.Texture + vgoModelAsset.TextureList = _TextureImporter.CreateTextureAssets(vgoStorage); // UnityEngine.Material - vgoModelAsset.MaterialList = CreateMaterialAssets(vgoStorage, vgoModelAsset.Texture2dList); + vgoModelAsset.MaterialList = CreateMaterialAssets(vgoStorage, vgoModelAsset.TextureList); // UnityEngine.Mesh if (vgoStorage.IsSpecVersion_2_4_orLower) @@ -61,7 +61,7 @@ protected virtual VgoModelAsset LoadInternal(in IVgoStorage vgoStorage) // UnityEngine.VgoSpringBoneColliderGroup vgoModelAsset.SpringBoneColliderGroupArray = CreateSpringBoneColliderGroupArray(vgoStorage.Layout); - // UnityEngine.GameObejct + // UnityEngine.GameObject List nodes = CreateNodes(vgoStorage); CreateNodeHierarchy(nodes, vgoStorage.Layout); @@ -98,13 +98,13 @@ protected virtual async Task LoadInternalAsync(IVgoStorage vgoSto vgoModelAsset.Layout = vgoStorage.Layout; - // UnityEngine.Texture2D - //vgoModelAsset.Texture2dList = _TextureImporter.CreateTextureAssets(vgoStorage); - //vgoModelAsset.Texture2dList = await _TextureImporter.CreateTextureAssetsAsync(vgoStorage, cancellationToken); - vgoModelAsset.Texture2dList = await _TextureImporter.CreateTextureAssetsParallelAsync(vgoStorage, cancellationToken); + // UnityEngine.Texture + //vgoModelAsset.TextureList = _TextureImporter.CreateTextureAssets(vgoStorage); + //vgoModelAsset.TextureList = await _TextureImporter.CreateTextureAssetsAsync(vgoStorage, cancellationToken); + vgoModelAsset.TextureList = await _TextureImporter.CreateTextureAssetsParallelAsync(vgoStorage, cancellationToken); // UnityEngine.Material - vgoModelAsset.MaterialList = CreateMaterialAssets(vgoStorage, vgoModelAsset.Texture2dList); + vgoModelAsset.MaterialList = CreateMaterialAssets(vgoStorage, vgoModelAsset.TextureList); // UnityEngine.Mesh if (vgoStorage.IsSpecVersion_2_4_orLower) @@ -126,7 +126,7 @@ protected virtual async Task LoadInternalAsync(IVgoStorage vgoSto // UnityEngine.VgoSpringBoneColliderGroup vgoModelAsset.SpringBoneColliderGroupArray = CreateSpringBoneColliderGroupArray(vgoStorage.Layout); - // UnityEngine.GameObejct + // UnityEngine.GameObject List nodes = CreateNodes(vgoStorage); CreateNodeHierarchy(nodes, vgoStorage.Layout); @@ -168,11 +168,11 @@ protected virtual VgoModelAsset ExtractInternal(in IVgoStorage vgoStorage) vgoModelAsset.Layout = vgoStorage.Layout; - // UnityEngine.Texture2D - vgoModelAsset.Texture2dList = _TextureImporter.CreateTextureAssets(vgoStorage); + // UnityEngine.Texture + vgoModelAsset.TextureList = _TextureImporter.CreateTextureAssets(vgoStorage); // UnityEngine.Material - vgoModelAsset.MaterialList = CreateMaterialAssets(vgoStorage, vgoModelAsset.Texture2dList); + vgoModelAsset.MaterialList = CreateMaterialAssets(vgoStorage, vgoModelAsset.TextureList); return vgoModelAsset; } @@ -195,13 +195,13 @@ protected virtual async Task ExtractInternalAsync(IVgoStorage vgo vgoModelAsset.Layout = vgoStorage.Layout; - // UnityEngine.Texture2D - //vgoModelAsset.Texture2dList = _TextureImporter.CreateTextureAssets(vgoStorage); - //vgoModelAsset.Texture2dList = await _TextureImporter.CreateTextureAssetsAsync(vgoStorage, cancellationToken); - vgoModelAsset.Texture2dList = await _TextureImporter.CreateTextureAssetsParallelAsync(vgoStorage, cancellationToken); + // UnityEngine.Texture + //vgoModelAsset.TextureList = _TextureImporter.CreateTextureAssets(vgoStorage); + //vgoModelAsset.TextureList = await _TextureImporter.CreateTextureAssetsAsync(vgoStorage, cancellationToken); + vgoModelAsset.TextureList = await _TextureImporter.CreateTextureAssetsParallelAsync(vgoStorage, cancellationToken); // UnityEngine.Material - vgoModelAsset.MaterialList = CreateMaterialAssets(vgoStorage, vgoModelAsset.Texture2dList); + vgoModelAsset.MaterialList = CreateMaterialAssets(vgoStorage, vgoModelAsset.TextureList); return vgoModelAsset; } @@ -214,9 +214,9 @@ protected virtual async Task ExtractInternalAsync(IVgoStorage vgo /// Create material assets. /// /// A vgo storage. - /// List of unity texture 2D. + /// List of unity texture. /// List of unity material. - protected virtual List CreateMaterialAssets(in IVgoStorage vgoStorage, in List texture2dList) + protected virtual List CreateMaterialAssets(in IVgoStorage vgoStorage, in List textureList) { var materialList = new List(); @@ -232,13 +232,22 @@ protected virtual async Task ExtractInternalAsync(IVgoStorage vgo if (vgoMaterial is null) { materialList.Add(null); + + continue; } - else + + try { - Material material = _MaterialImporter.CreateMaterialAsset(vgoMaterial, texture2dList); + Material material = _MaterialImporter.CreateMaterialAsset(vgoMaterial, textureList); materialList.Add(material); } + catch (Exception ex) + { + Debug.LogException(ex); + + materialList.Add(null); + } } return materialList; @@ -440,13 +449,13 @@ protected virtual void SetupNodes(List nodes, in IVgoStorage vgoStora vgoModelAsset.ColliderList = CreateUnityColliderList(nodes); - // UnigyEngine.Cloth + // UnityEngine.Cloth for (int nodeIndex = 0; nodeIndex < vgoStorage.Layout.nodes.Count; nodeIndex++) { SetupNodeCloth(nodes, nodeIndex, vgoStorage, vgoModelAsset.ColliderList); } - // UnigyEngine.VgoSpringBone + // UnityEngine.VgoSpringBone for (int nodeIndex = 0; nodeIndex < vgoStorage.Layout.nodes.Count; nodeIndex++) { SetupNodeSpringBone(nodes, nodeIndex, vgoStorage.Layout, vgoStorage.GeometryCoordinate, vgoModelAsset); @@ -667,7 +676,13 @@ protected virtual void SetupNode( vgoLayout.particles.TryGetValue(vgoNode.particle, out var vgoParticleSystem) && vgoParticleSystem != null) { - _ParticleSystemImporter.AddComponent(go, vgoParticleSystem, geometryCoordinate, vgoModelAsset.MaterialList, vgoModelAsset.Texture2dList); + _ParticleSystemImporter.AddComponent( + go, + vgoParticleSystem, + geometryCoordinate, + vgoModelAsset.MaterialList, + vgoModelAsset.TextureList, + _Option.ForceSetRuntimeParticleDuration); } } catch (Exception ex) @@ -1102,7 +1117,13 @@ protected virtual void AttachMeshAndRenderer( blendShapeConfiguration.Blinks = meshAsset.BlendShapeConfig.Blinks; blendShapeConfiguration.Visemes = meshAsset.BlendShapeConfig.Visemes; - if (vgoMeshRenderer.blendShapePesets != null && + if (vgoMeshRenderer.blendShapePresets != null && + vgoMeshRenderer.blendShapePresets.Any()) + { + blendShapeConfiguration.Presets.AddRange(vgoMeshRenderer.blendShapePresets); + } + else if ( + vgoMeshRenderer.blendShapePesets != null && vgoMeshRenderer.blendShapePesets.Any()) { blendShapeConfiguration.Presets.AddRange(vgoMeshRenderer.blendShapePesets); diff --git a/UniVgo2/Runtime/Shaders/ShaderName.cs b/UniVgo2/Runtime/Shaders/ShaderName.cs index c31d497..aa173b0 100644 --- a/UniVgo2/Runtime/Shaders/ShaderName.cs +++ b/UniVgo2/Runtime/Shaders/ShaderName.cs @@ -363,7 +363,25 @@ public class ShaderName /// VRM10/Universal Render Pipeline/MToon10 public const string VRM_URP_MToon10 = "VRM10/Universal Render Pipeline/MToon10"; - + + #endregion + + #region NOVA + + /// Nova/Particles/Distortion + public const string Nova_Particles_Distortion = "Nova/Particles/Distortion"; + + /// Nova/Particles/Uber Lit + public const string Nova_Particles_UberLit = "Nova/Particles/UberLit"; + + /// Nova/Particles/Uber Unlit + public const string Nova_Particles_UberUnlit = "Nova/Particles/UberUnlit"; + + /// Nova/UI Particles/Uber Lit + public const string Nova_UIParticles_UberLit = "Nova/UIParticles/UberLit"; + + /// Nova/UI Particles/Uber Unlit + public const string Nova_UIParticles_UberUnlit = "Nova/UIParticles/UberUnlit"; #endregion } diff --git a/UniVgo2/Runtime/Shaders/ShaderStore.cs b/UniVgo2/Runtime/Shaders/ShaderStore.cs index cc3c2e2..516c846 100644 --- a/UniVgo2/Runtime/Shaders/ShaderStore.cs +++ b/UniVgo2/Runtime/Shaders/ShaderStore.cs @@ -915,6 +915,50 @@ protected Shader VrmUrpMtoon10 #endregion + #region Fields & Properties (NOVA) + + /// Nova/Particles/Distortion + protected Shader? _NovaParticlesDistortion; + + /// Nova/Particles/Distortion + protected Shader NovaParticlesDistortion + => _NovaParticlesDistortion + ??= Shader.Find(ShaderName.Nova_Particles_Distortion); + + /// Nova/Particles/Uber Lit + protected Shader? _NovaParticlesUberLit; + + /// Nova/Particles/Uber Lit + protected Shader NovaParticlesUberLit + => _NovaParticlesUberLit + ??= Shader.Find(ShaderName.Nova_Particles_UberLit); + + /// Nova/Particles/Uber Unlit + protected Shader? _NovaParticlesUberUnlit; + + /// Nova/Particles/Uber Unlit + protected Shader NovaParticlesUberUnlit + => _NovaParticlesUberUnlit + ??= Shader.Find(ShaderName.Nova_Particles_UberUnlit); + + /// Nova/UI Particles/Uber Lit + protected Shader? _NovaUIParticlesUberLit; + + /// Nova/UI Particles/Uber Lit + protected Shader NovaUIParticlesUberLit + => _NovaUIParticlesUberLit + ??= Shader.Find(ShaderName.Nova_UIParticles_UberLit); + + /// Nova/UI Particles/Uber Unlit + protected Shader? _NovaUIParticlesUberUnlit; + + /// Nova/UI Particles/Uber Unlit + protected Shader NovaUIParticlesUberUnlit + => _NovaUIParticlesUberUnlit + ??= Shader.Find(ShaderName.Nova_UIParticles_UberUnlit); + + #endregion + #region Methods /// @@ -1204,6 +1248,21 @@ protected Shader VrmUrpMtoon10 case ShaderName.VRM_URP_MToon10: return VrmUrpMtoon10; + case ShaderName.Nova_Particles_Distortion: + return NovaParticlesDistortion; + + case ShaderName.Nova_Particles_UberLit: + return NovaParticlesUberLit; + + case ShaderName.Nova_Particles_UberUnlit: + return NovaParticlesUberUnlit; + + case ShaderName.Nova_UIParticles_UberLit: + return NovaUIParticlesUberLit; + + case ShaderName.Nova_UIParticles_UberUnlit: + return NovaUIParticlesUberUnlit; + default: return default; } @@ -1333,12 +1392,6 @@ public virtual Shader GetShaderOrStandard(in VgoMaterial vgoMaterial, in RenderP break; } } - - // @test - //if (vgoMaterial.shaderName == ShaderName.VRM_MToon) - //{ - // shader = VrmMtoon10; - //} } return shader; diff --git a/UniVgo2/Runtime/UniVgo2.asmdef b/UniVgo2/Runtime/UniVgo2.asmdef index eb47be7..465a9cc 100644 --- a/UniVgo2/Runtime/UniVgo2.asmdef +++ b/UniVgo2/Runtime/UniVgo2.asmdef @@ -10,6 +10,7 @@ "references": [ "NewtonVgo", "LilToonShader.Utility", + "NovaShader.Utility", "UniShader.Shared", "UniShader.Standard.Utility", "UniShader.Standard.Particle.Utility", @@ -45,6 +46,11 @@ "expression": "[1.0,2.0)", "define": "IZAYOI_LILTOON_UTILITY_1_0_OR_NEWER" }, + { + "name": "com.izayoi.nova.shader.utility", + "expression": "2.0", + "define": "IZAYOI_NOVA_SHADER_UTILITY_2_0_OR_NEWER" + }, { "name": "com.unity.render-pipelines.high-definition", "expression": "1.0", @@ -120,6 +126,11 @@ "expression": "[0.79.0,1.0)", "define": "UNIVGO_ENABLE_UNIGLTF_UNIUNLIT" }, + { + "name": "jp.co.cyberagent.nova", + "expression": "2.0", + "define": "NOVA_SHADER_2_0_OR_NEWER" + }, { "name": "jp.lilxyzw.liltoon", "expression": "[1.2.0,1.2.12]", diff --git a/UniVgo2/Runtime/VgoVersion.cs b/UniVgo2/Runtime/VgoVersion.cs index 203a428..8e77e1d 100644 --- a/UniVgo2/Runtime/VgoVersion.cs +++ b/UniVgo2/Runtime/VgoVersion.cs @@ -17,9 +17,9 @@ public class VgoVersion public const int MINOR = 5; /// Patch - public const int PATCH = 21; + public const int PATCH = 22; /// Version - public const string VERSION = "2.5.21"; + public const string VERSION = "2.5.22"; } } diff --git a/package.json b/package.json index 5663080..3604db7 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "com.izayoi.univgo", "displayName": "UniVGO", "description": "UniVGO is a package that can handle VGO files in Unity.", - "version": "2.5.21", + "version": "2.5.22", "type": "tool", "category": "", "keywords": [ @@ -20,6 +20,7 @@ "particle", "skybox", "liltoon", + "nova", "unity", "unity3d", "unity3d-plugin",