feat: OBJ 全量贴图接入——Material 加 AO 槽 + OBJ 工作流适配

- Material 槽位 4→5(+AO),参数 UBO binding 4→5;shader ambient
  diffuse 项乘 ao(IBL 遮蔽),AO 默认纹理白色
- OBJ 槽落点补全:map_Bump→HEIGHT(5)、map_Ns→SHININESS(7)、
  map_Ka→AMBIENT(3)(assimp OBJ importer 约定)——backpack 的
  法线贴图此前也从未加载
- MTL 导出遗漏(roughness.jpg/ao.jpg 在目录未被引用):约定文件名
  探测补槽(roughness/ao/occlusion × jpg/png),命中留 INFO 锚点
- 因子按工作流分支:glTF 用声明因子(MR 合图 B=金属度);
  OBJ metallic=0(specular 工作流无金属概念),roughness 有图→1,
  无图→Blinn-Phong Ns 换算 R=sqrt(2/(Ns+2))(补偿默认贴图 G=0.5)
This commit is contained in:
2026-09-23 19:49:36 +08:00
parent 9cc36af3f0
commit 2b875c9284
4 changed files with 81 additions and 26 deletions
+10 -7
View File
@@ -3,15 +3,17 @@
//
// Material:PBR 材质 = 纹理槽组 + 因子参数 UBO + 一个描述符集。
//
// 槽位(binding = 槽位序号,与 simple_shader.frag 契约一致,glTF
// metallic-roughness 工作流):
// 槽位(binding = 槽位序号,与 simple_shader.frag 契约一致):
// 0 albedo(BaseColor,sRGB) 1 normal(切线空间法线,线性)
// 2 metallicRoughness(线性:G=粗糙度,B=金属度,glTF 约定)
// 3 emissive(自发光,sRGB) 4 材质参数 UBO(fragment)
// 3 emissive(自发光,sRGB) 4 ao(环境光遮蔽,线性)
// 5 材质参数 UBO(fragment,kParamsBinding)
//
// 纹理非拥有(Model 的纹理缓存持有);缺槽由调用方传默认纹理。
// 因子(metallicFactor/roughnessFactor)乘在 MR 贴图上——无 MR 图的
// 旧资产退化为纯因子(电介质 + 常数粗糙度)。
// 因子(metallicFactor/roughnessFactor)乘在 MR 贴图上:
// glTF(MR 合图 B=金属度语义)→ 因子取 glTF 声明(默认 1/1)
// OBJ(specular 工作流,独立 roughness 图或无图)→ metallic=0,
// roughness 因子按贴图有无/Ns 换算——金属度强制 0
//
#ifndef HELLOVULKAN_MATERIAL_H
@@ -44,8 +46,9 @@ namespace Engine {
Normal = 1,
MetallicRoughness = 2,
Emissive = 3,
kSlotCount = 4, // 纹理槽数
kParamsBinding = 4, // 参数 UBO binding
Ao = 4,
kSlotCount = 5, // 纹理槽数
kParamsBinding = 5, // 参数 UBO binding
};
Material(Device& device, MemoryAllocator& allocator,
+1
View File
@@ -84,6 +84,7 @@ namespace Engine
std::vector<Scope<Mesh>> m_Meshes;
std::string m_ModelPath;
bool m_IsGltf = false; // glTF 家族:MR 合图语义 + 不翻转 UV
};
} // namespace Engine