Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5
问题描述
在重建 ShaderLab Pass 渲染状态时,
GameExport.ColourMaskLetters(float mask)使用了反转后的位掩码定义(1 = R, 2 = G, 4 = B, 8 = A)来解码rtBlend0.colMask,而 UnityUnityEngine.Rendering.ColorWriteMask实际使用的位顺序为:Alpha = 1(1 << 0)Blue = 2(1 << 1)Green = 4(1 << 2)Red = 8(1 << 3)All = 15(0b1111)这会导致原始设置为
ColorMask RGB(colMask = 14,0b1110)的 Shader 被错误导出为ColorMask GBA,重新导入 Unity 渲染时丢失红色通道R并错误写入Alpha通道。colMaskColorWriteMask0000000010001ARA20010BGB40100GBG81000RAR141110RGBGBARGB151111RGBARGBARGBA修改内容
src/ShaderRipper/Game/GameExport.cs:修改ColourMaskLetters中的位判断顺序为8 = R, 4 = G, 2 = B, 1 = A,按RGBA顺序输出通道字母。src/ShaderRipper.Tests/ShaderLabTests.cs:新增ColorMaskTests,覆盖0 / 1 / 2 / 4 / 8 / 9 / 10 / 12 / 14、默认全写(15省略输出)以及材质属性驱动(ColorMask [_ColorMask])等场景。验证结果
dotnet test src/ShaderRipper.Tests/ShaderRipper.Tests.csproj -c Release,全部 283/283 通过(修复前新增用例中非对称位掩码1/2/4/8/10/12/14均失败,修复后全部通过)。ColorMask RGB)及多份真实 AssetBundle 对比导出前后结果,原本被错误输出为ColorMask GBA的 Shader 均恢复为正确的ColorMask RGB,ColorMask 0与ColorMask [_ColorMask]保持不变。