Skip to content

Commit 0f95b93

Browse files
committed
fix: 修复将透明材质替换为普通材质导致的渲染异常问题
1 parent 9835963 commit 0f95b93

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
[English](CHANGELOG_EN.md) | 中文
44

5+
## v1.10.4-fix4
6+
7+
- 修复错误的将透视材质也替换成普通材质导致渲染表现异常的问题
8+
59
## v1.10.4-fix3
610

711
- 修复前一修复版本中引入的一个特定情形下材质渲染表现异常的问题

CHANGELOG_EN.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
English | [中文](CHANGELOG.md)
44

5+
## v1.10.4-fix4
6+
7+
- Fixed the issue of replacing the transparent material with the normal material, causing abnormal rendering performance
8+
59
## v1.10.4-fix3
610

711
- Fixed a material rendering performance issue in a specific scenario introduced in the previous fix version

DuckovCustomModel/Constant.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public static class Constant
44
{
55
public const string ModID = "DuckovCustomModel";
66
public const string ModName = "Duckov Custom Model";
7-
public const string ModVersion = "1.10.4-fix3";
7+
public const string ModVersion = "1.10.4-fix4";
88
public const string HarmonyId = "com.ritsukage.DuckovCustomModel";
99
}
1010
}

DuckovCustomModel/MonoBehaviours/ModelHandler.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,14 +1172,17 @@ private void CheckAndFixMaterialShaders()
11721172
var targetShader = GameDefaultShader;
11731173
if (targetShader == null) return;
11741174

1175+
var showBackShader = GameCharacterShowBackShader;
1176+
if (showBackShader == null) return;
1177+
11751178
foreach (var renderer in _cachedCustomModelRenderers)
11761179
{
11771180
if (renderer == null) continue;
11781181

11791182
foreach (var material in renderer.sharedMaterials)
11801183
{
11811184
if (material == null) continue;
1182-
if (material.shader == targetShader) continue;
1185+
if (material.shader == targetShader || material.shader == showBackShader) continue;
11831186

11841187
material.shader = targetShader;
11851188
if (material.HasProperty(EmissionColor))
@@ -1201,7 +1204,7 @@ private static void ReplaceRenderersShader(Renderer[] renderers, string? shaderN
12011204

12021205
if (shader == GameDefaultShader) // SodaCraft/SodaCharacter shader needs to disable emission
12031206
foreach (var renderer in renderers)
1204-
foreach (var material in renderer.materials)
1207+
foreach (var material in renderer.sharedMaterials)
12051208
{
12061209
if (material == null) continue;
12071210
material.shader = shader;
@@ -1210,7 +1213,7 @@ private static void ReplaceRenderersShader(Renderer[] renderers, string? shaderN
12101213
}
12111214
else
12121215
foreach (var renderer in renderers)
1213-
foreach (var material in renderer.materials)
1216+
foreach (var material in renderer.sharedMaterials)
12141217
{
12151218
if (material == null) continue;
12161219
material.shader = shader;

0 commit comments

Comments
 (0)