vault backup: 2025-07-28 10:20:16

This commit is contained in:
2025-07-28 10:20:16 +08:00
parent e06b593eb5
commit 5122ec2b37
2 changed files with 77 additions and 29 deletions

View File

@@ -0,0 +1,47 @@
---
title: Untitled
date: 2025-07-28 10:06:02
excerpt:
tags:
rating: ⭐
---
# 前言
- DXBC/DXIL 反汇编HLSL Decompiler:https://zhuanlan.zhihu.com/p/1927111489627599176
# 正文
## 项目背景
从 UE5 和 DirectX12 的时代开始,[Shader Model 6.0](https://zhida.zhihu.com/search?content_id=260234833&content_type=Article&match_order=1&q=Shader+Model+6.0&zhida_source=entity)+ 和它的新编译格式 DXIL已经接替老旧的 [DXBC](https://zhida.zhihu.com/search?content_id=260234833&content_type=Article&match_order=1&q=DXBC&zhida_source=entity) 成为新时代的标配。这意味着,当我们截帧分析基于 UE5 + DX12 的游戏时,看到的 Shader 代码不再是熟悉的 DXBC而是 DXIL 了。
对于热衷于深挖渲染管线一探究竟的逆向爱好者来说,这带来了一个痛点:我们急需一个能将 DXIL 反编译回可读性强的 HLSL 源码的工具。
## HLSL 反编译的历史
在 DXBC 时代Shader Model 5.1 及之前),开源项目 [3Dmigoto](https://link.zhihu.com/?target=https%3A//github.com/bo3b/3Dmigoto) 旗下的 [HLSLDecompiler](https://link.zhihu.com/?target=https%3A//github.com/bo3b/3Dmigoto/tree/master/HLSLDecompiler) 堪称神器。
它甚至被专门 Fork 出来([zxxyye/HLSLDecompiler](https://link.zhihu.com/?target=https%3A//github.com/zxxyye/HLSLDecompiler)),集成到 [RenderDoc](https://zhida.zhihu.com/search?content_id=260234833&content_type=Article&match_order=1&q=RenderDoc&zhida_source=entity) 中作为插件使用,并收获了 300+ Star 和 100+ Fork足见其受欢迎程度和逆向需求的旺盛。
## 现在与将来
然而,时代变了。[3Dmigoto](https://link.zhihu.com/?target=https%3A//github.com/bo3b/3Dmigoto) 项目本身已经陷入沉寂,其下的 [HLSLDecompiler](https://link.zhihu.com/?target=https%3A//github.com/bo3b/3Dmigoto/tree/master/HLSLDecompiler) 子模块更是多年未曾更新。
根据作者在 [Issue #358](https://link.zhihu.com/?target=https%3A//github.com/bo3b/3Dmigoto/issues/358) 中的说法,这个反编译器对 Shader Model 4.0 为止的 DXBC 代码具有良好的支持性,然而对于 Shader Model 5.0+ 的着色器代码已是捉襟见肘,并且大概率不会再有任何更新。
实际体验也印证了这点。很多 Shader Model 5.0+ DXBC 的基础指令(甚至包括 `numthreads`)它都翻译不出来,已经完全无法满足现代游戏分析的需求。
一言以蔽之,老工具已无法胜任 DXIL 和部分 DXBC 的反编译工作。为了解决这个痛点,我们需要打造一个全新的逆向分析工具:[HLSL-Decompiler](https://link.zhihu.com/?target=https%3A//github.com/YYadorigi/HLSL-Decompiler)。
它的目标很明确:高效、准确地将 DXBC / DXIL / [SPIR-V](https://zhida.zhihu.com/search?content_id=260234833&content_type=Article&match_order=1&q=SPIR-V&zhida_source=entity) 反编译回可读的 HLSL 源码,并且能无缝集成到 RenderDoc 中,真正做到「开箱即用」,接续前人未完成的使命。
## 项目简述
### 开源库
本项目基于如下开源库。它们权威,高质量,并且正活跃地持续维护。
- [DirectXShaderCompiler (DXC)](https://link.zhihu.com/?target=https%3A//github.com/microsoft/DirectXShaderCompiler/tree/main):微软官方提供的现代 HLSL 编译器。其中包括关键组件 [dxbc2dxil](https://link.zhihu.com/?target=https%3A//github.com/microsoft/DirectXShaderCompiler/tree/main/projects/dxilconv/tools/dxbc2dxil),将老式 DXBC 转换为 [LLVM IR](https://zhida.zhihu.com/search?content_id=260234833&content_type=Article&match_order=1&q=LLVM+IR&zhida_source=entity) 形式的 DXIL。
- [dxil-spirv](https://link.zhihu.com/?target=https%3A//github.com/HansKristian-Work/dxil-spirv/tree/master):将 DXIL 或其 LLVM IR 形式高效地转换为 SPIR-V。作者同时也是 [SPIRV-Cross](https://link.zhihu.com/?target=https%3A//github.com/KhronosGroup/SPIRV-Cross/tree/main) 的重要贡献者。
- [SPIRV-Cross](https://link.zhihu.com/?target=https%3A//github.com/KhronosGroup/SPIRV-Cross/tree/main)KhronosGroup 官方维护的 SPIR-V 反汇编工具,支持从 SPIR-V 到 HLSL 的转换。
### 工具链
该项目的核心就是巧妙地串联起上述库,形成一个高效的反编译流水线。原理如下图所示。
![](https://pic1.zhimg.com/v2-52e1214206c0ec9fcec5e6cf100f5040_1440w.jpg)
### 为什么你需要它?
- **分析 UE5 / DX12 游戏渲染管线**:轻松查看截帧得到的 DXIL Shader 源码。
- **逆向老旧 DXBC (SM5.1)**:老工具搞不定的,它能搞定。
- **研究 Vulkan Shader (SPIR-V)**:方便地将 SPIR-V 转回 HLSL 进行分析或移植。
- **RenderDoc 插件集成**:安装即用,分析体验丝滑流畅。
- **开源 & 活跃**:基于活跃项目构建,持续维护更新有保障。
### 项目地址
项目已开源在 GitHub[https://github.com/YYadorigi/HL](https://link.zhihu.com/?target=https%3A//github.com/YYadorigi/HLSL-Decompiler)

View File

@@ -126,12 +126,13 @@ rating: ⭐⭐⭐
2. [ ] 后处理边缘光
3. [ ] Matcap
4. [ ] ASoul边缘光
10. [ ] Reflection控制
10. [ ] 关于逆ToneMapping映射的万能人肉求解法 https://zhuanlan.zhihu.com/p/14603997646
11. [ ] Reflection控制
1. [x] ReflectionAlpha实现。
2. [ ] Matcap Reflection实现。
3. [ ] 对Reflection Texture进行Kuawahara处理之后根据亮度抽象成第二高光提取亮度之后乘以高光颜色
1. 【[UFSH2024]用虚幻引擎5为《幻塔》定制高品质动画流程风格化渲染管线 | 晨风 Neverwind 完美世界游戏】 【精准空降到 14:24】 https://www.bilibili.com/video/BV1rW2LYvEox/?share_source=copy_web&vd_source=fe8142e8e12816535feaeabd6f6cdc8e&t=864
11. [ ] Toon GILumen / Other)
12. [ ] Toon GILumen / Other)
1. [ ] DiffuseIndirect Alpha / DiffuseIndirect Saturation / AOAlpha
1. [x] Lumen
2. [ ] Other GI Method
@@ -144,36 +145,36 @@ rating: ⭐⭐⭐
4. [ ] 尝试平滑二阶、三阶球谐来使得Lumen效果低频化
1. 伪代码 OutSH = SH0 + (SH1 + SH2) * Smoothness;
5. [ ] Cel适配需要实现[[Toon多光源参考|Toon多光源后处理Pass]]
12. [ ] 阴影控制
13. [ ] 阴影控制
1. [x] 控制深度偏移
1. [x] 在材质中使用ShadowPassSwitch再对ViewSpace的Z轴方向使用DirectionalLightVector比较可以只对方向光进行偏移进行WPO偏移实现。
2. [ ] ContactShadow接触阴影实现衣服细节的DetailShadow
3. [x] 半程阴影DirectionOffsetToViewShadow半分阴影[[幻塔-半程自阴影.png]]
4. [x] 给图元添加禁用自阴影功能——发现启用RecivedViewOffsetShadow就可以起到这个功能。
13. [ ] ToonHair
14. [ ] ToonHair
1. [【UE5】通过深度偏移计算刘海投影](https://zhuanlan.zhihu.com/p/690066418)
2. [UE5 NPR-Shadow-Character Shadow2](https://zhuanlan.zhihu.com/p/13953884160)
14. [ ] ToonTranslucent
15. [ ] ToonTranslucent
1. [ ] 通过模仿SingleLayerWater实现折射效果 https://zhuanlan.zhihu.com/p/657928532
2. [ ] 眉眼细节 [[幻塔-眉眼细节.png]]
1. [ ] 【【Unity/虚幻5/Blender】3种引擎 崩坏: 星穹铁道风格 卡通渲染 从球谐光照到眉毛透过刘海 完整流程】 【精准空降到 1:24:29】 https://www.bilibili.com/video/BV1CN411C7qx/?share_source=copy_web&vd_source=fe8142e8e12816535feaeabd6f6cdc8e&t=5069
3. [ ] [【UE5】逐材质stencil、半透明排序、OverlayMaterial](https://zhuanlan.zhihu.com/p/31171114411)
15. [ ] TSR
16. [ ] TSR
1. [ ] [UE TAAU详细解析](https://zhuanlan.zhihu.com/p/681910495)
2. [ ] [UE TSR详细解析](https://zhuanlan.zhihu.com/p/682350835)
3. [ ] [GDC2025 : Generalized Stylized Post Processing Outline](https://zhuanlan.zhihu.com/p/1895785690161198348)
16. [ ] [[Toon多光源参考|Toon多光源后处理Pass]]
17. [ ] [【虚幻5】UE_动画变形工具(晶格变形)](https://www.bilibili.com/video/BV1DsR3YoEML/?share_source=copy_web&vd_source=fe8142e8e12816535feaeabd6f6cdc8e)
18. [ ]
19. [ ] 掰法线相关
17. [ ] [[Toon多光源参考|Toon多光源后处理Pass]]
18. [ ] [【虚幻5】UE_动画变形工具(晶格变形)](https://www.bilibili.com/video/BV1DsR3YoEML/?share_source=copy_web&vd_source=fe8142e8e12816535feaeabd6f6cdc8e)
19. [ ]
20. [ ] 掰法线相关
1. [ ] 【Blender插件 Easy Custom Normals V1.1.0汉化版,卡通渲染优化利器!-哔哩哔哩】 https://b23.tv/meLiEkj
1. [ ] https://superhivemarket.com/products/stylized-normals
2. [ ] https://tools.fondant.gg/
2. [ ] 月下幻影的掰法线思路:`N = _Scale * NoL * L + N`尝试找到使用场景。资产路径`/Game/ToonContentExample/MaterialUtility/NormalOffsetToDirectionalLight/M_NormalOffsetToDirectionalLight`
20. [ ] RGS 光线追踪与路径追踪支持。
21. [ ] RGS 光线追踪与路径追踪支持。
1. [ ] [【UE5】通过Raytracing自定义卡通渲染投影](https://zhuanlan.zhihu.com/p/688722298) https://zhuanlan.zhihu.com/p/688722298
21. [ ] 给EditorView添加卡通渲染用场景默认场景的渲染效果对不上。
22. [ ] 实现前向混合管线思路有21. Material直接计算光照结果。2. 自定义ToonBasePass到LightingPass后复制阴影贴图与Lumen渲染结果进行Composition。
22. [ ] 给EditorView添加卡通渲染用场景默认场景的渲染效果对不上。
23. [ ] 实现前向混合管线思路有21. Material直接计算光照结果。2. 自定义ToonBasePass到LightingPass后复制阴影贴图与Lumen渲染结果进行Composition。
1. 原神早期的方案:
1. 渲染地形(远景
2.
@@ -184,38 +185,38 @@ rating: ⭐⭐⭐
6. 渲染深度与法线Buffer。
7. 渲染级联阴影。
8. 合成阴影与环境光照AO、环境探针
23. [ ] 云彩生成器
24. [ ] 云彩生成器
1. [ ] https://www.bilibili.com/video/BV1L5kdYFEXc/?spm_id_from=333.1007.tianma.4-1-11.click&vd_source=d47c0bb42f9c72fd7d74562185cee290
2. [ ] 风格化水面资产 https://item.taobao.com/item.htm?id=865360489543&pisk=gLHsX7NMiNb1gB7njFKURXly5Dwb5q9y1iZxqmBNDReTkigKDtQA6-FLJorOMSU2sqNju2VxQRoZRGDIPtWwSCmAh-yvzUJyUcman-Lyk8kOUGq4mNUAurCKv-rjPdNAXcmgnrIFkQlKjZg5RK5YDrKQpor7k-EYW9KQcuaYHPFAJ6E8JrexkSIdJuZ5MZCTHkKQju5OBoeYvMEaVtBtk-KIvyqxnDXQDCZ-fHz1qUDkpeKgJtBxdlNpTcUKrr-4i5TjbyXvy1Zg1coTRtBxKXkPllz9ZMz0QPDbfqvlIRFjTAVoQeBsl20KBSDp8B00QuV-MD-lTPDIQvFsCU1uCX3nd5DOWhqtsqDbQx71hDMb57HTOKx0CDEYdbneq6zidAkL1AT5ZPMiDjPItNTUuboEBWgJ89g0GXkgZA8dC4IyzTz7sJ5fA7XbAz-BAsf0xzPwqJ_edaNTxlTyAH_Gi5E3AmtBAsDg6kqF6HtCWc1..&spm=a21xtw.29178619.product_shelf.74.41727d6dRCDvul
24. [ ] 添加Debug View https://zhuanlan.zhihu.com/p/668782106
25. [ ] 添加Debug View https://zhuanlan.zhihu.com/p/668782106
1. [ ] UE5.5 自定义/扩展缓冲可视化调试功能 https://zhuanlan.zhihu.com/p/16314329507
25. [ ] [_UE5_ Shader Print系统](https://zhuanlan.zhihu.com/p/637929634)
26. [ ] GBufferView实现。
27. [ ] Toon Debug模式可以让美术在材质进行进行简单的光照计算。
28. [ ] ToonShadow
26. [ ] [_UE5_ Shader Print系统](https://zhuanlan.zhihu.com/p/637929634)
27. [ ] GBufferView实现。
28. [ ] Toon Debug模式可以让美术在材质进行进行简单的光照计算。
29. [ ] ToonShadow
1. ![[星穹铁道中下巴阴影处理.png]]
2. [ ] ToonSDFShadow
1. [ ] TODO: SDF贴图工具
29. [ ] LookDev场景
30. [ ] LookDev场景
1. [ ] https://zhuanlan.zhihu.com/p/394608910
30. [ ] 考虑往GBuffer中添加更多数据考虑Velocity以及SingleLayerWater
31. [ ] 考虑往GBuffer中添加更多数据考虑Velocity以及SingleLayerWater
1. ShaderMaterialDerivedHelpers.cppShader宏、GBufferInfo.cppGBuffer格式BasePassRendering.cpp950行SingleLayerWater写入GBuffer格式相关
2. 确定一下SingleLayerWater中VSMFiter与DistanceFieldShadow对渲染结果的影响之后在文档中说明。
31. [ ] 修复SIngleLayerWater的缩略图渲染渲染错误双击会有一瞬间的错误产生
32. [ ] 添加对应的Stat https://zhuanlan.zhihu.com/p/716644594
33. [ ] ToonLumen、GI以及晕染效果实现。![[卡通渲染晕染效果.mp4]]
34. [ ] 在材质中实现ToonEye相关效果
32. [ ] 修复SIngleLayerWater的缩略图渲染渲染错误双击会有一瞬间的错误产生
33. [ ] 添加对应的Stat https://zhuanlan.zhihu.com/p/716644594
34. [ ] ToonLumen、GI以及晕染效果实现。![[卡通渲染晕染效果.mp4]]
35. [ ] 在材质中实现ToonEye相关效果
1. 【二次元人物眼睛如何变形?】 https://www.bilibili.com/video/BV14M4m1y71A/?share_source=copy_web&vd_source=fe8142e8e12816535feaeabd6f6cdc8e
1. 原视频 https://www.youtube.com/watch?v=euIyX9v8rvw
2. 眼睛建模 https://youtu.be/s2_7Q2IIvNY?si=fWiYjqcLFXzdeQ-B&t=126
35. 尝试实现Forward+
36. 尝试实现Forward+
1. BasePass https://zhuanlan.zhihu.com/p/618698467
36. DX11问题修复
37. DX11问题修复
1. [x] ToonOutline SceneColorTexture为空的问题。 **DX11限制必须CopyTexture**
37. 卡通渲染针对TAA的优化思路 https://zhuanlan.zhihu.com/p/678876237
38. 卡通渲染针对TAA的优化思路 https://zhuanlan.zhihu.com/p/678876237
1. https://www.bilibili.com/video/BV1BK411v7FY/?spm_id_from=333.788&vd_source=ea6df38502a795b7533aa33b78bf1159
2. https://zhuanlan.zhihu.com/p/20786650
38. [ ] Unreal Engine 5.4 Scene Extension https://zhuanlan.zhihu.com/p/706268007
39. [ ] Unreal Engine 5.4 Scene Extension https://zhuanlan.zhihu.com/p/706268007
1. [ ] 通过SceneExtension改进ToonObjectID这样可以减少对应ToonBuffer的精度来存其他数据。
2. [ ] https://www.bilibili.com/video/BV1fM4m1U7Tp/