透明来源:glTF alphaMode=BLEND(解析期读取,OBJ/FBX 恒不透明—— 资产格式定义写死);MASK 后续演进。Material 加透明语义(入缓存键), 程序化测试资产 CreateTransparentPlane(RGBA 纯色纹理)。 SceneRenderer:透明材质实例收集进独立 scratch(仅主视图,不投 阴影——alpha 阴影后续演进),batch 按平均距离降序排序(远→近, batchMats 同步重排),SSBO 扁平化顺序 = 排序后顺序。 ForwardPass 两段绘制:不透明(无混合 + 深度写)→ 透明(Shader Object 动态状态切 SRC_ALPHA/ONE_MINUS_SRC_ALPHA 线性 over + 深度 只测不写);velocity 附件透明段直写(透明表面 velocity 即自身运动)。 frag alpha = albedo 贴图 a 直通,预乘在 tonemap 段(hard constraint 不变)。已知边界:TAA alpha 时域混合(透明边缘几帧渐显);同 batch 多实例不做实例级排序。
75 lines
2.9 KiB
C++
75 lines
2.9 KiB
C++
//
|
||
// Created by atdunbg on 2026/9/22.
|
||
//
|
||
|
||
#include <Engine/Assets/AssetManager.h>
|
||
#include <Engine/Core/Log.h>
|
||
|
||
namespace Engine::Assets {
|
||
|
||
AssetManager::AssetManager(IAssetUploader& uploader)
|
||
: m_Uploader(uploader)
|
||
{
|
||
ENGINE_INFO("AssetManager created");
|
||
}
|
||
|
||
ModelRef AssetManager::LoadModel(const std::string& path)
|
||
{
|
||
// GPU 上传经接口发生在渲染层实现里,本层只管缓存与句柄
|
||
return m_Models.Load(path,
|
||
[this](const std::string& p) { return m_Uploader.LoadModel(p); });
|
||
}
|
||
|
||
ModelRef AssetManager::LoadModel(const std::string& path,
|
||
ParsedModel&& parsed)
|
||
{
|
||
// 预解析数据移交 loader(Load 同步调用 lambda,引用捕获安全);
|
||
// 路径已缓存则 loader 不执行,parsed 自然丢弃(去重)
|
||
return m_Models.Load(path,
|
||
[this, &parsed](const std::string& p) {
|
||
return m_Uploader.LoadModel(p, std::move(parsed));
|
||
});
|
||
}
|
||
|
||
ModelRef AssetManager::CreatePlane(f32 halfSize, u8 r, u8 g, u8 b)
|
||
{
|
||
// 程序化资产复用同一缓存:键 = 伪路径 + 参数
|
||
std::string key = "procedural://plane/" + std::to_string(halfSize) +
|
||
"/" + std::to_string(r) + "," + std::to_string(g) +
|
||
"," + std::to_string(b);
|
||
return m_Models.Load(key,
|
||
[&](const std::string&) { return m_Uploader.CreatePlane(halfSize, r, g, b); });
|
||
}
|
||
|
||
ModelRef AssetManager::CreateTransparentPlane(f32 halfSize,
|
||
u8 r, u8 g, u8 b, u8 a)
|
||
{
|
||
std::string key = "procedural://transparent-plane/" +
|
||
std::to_string(halfSize) + "/" +
|
||
std::to_string(r) + "," + std::to_string(g) + "," +
|
||
std::to_string(b) + "," + std::to_string(a);
|
||
return m_Models.Load(key, [&](const std::string&) {
|
||
return m_Uploader.CreateTransparentPlane(halfSize, r, g, b, a);
|
||
});
|
||
}
|
||
|
||
EnvRef AssetManager::LoadEnvironment(const std::string& path)
|
||
{
|
||
// GPU 生成(compute 预积分)经接口发生在渲染层实现里
|
||
return m_Environments.Load(path,
|
||
[this](const std::string& p) { return m_Uploader.LoadEnvironment(p); });
|
||
}
|
||
|
||
EnvRef AssetManager::LoadEnvironment(const std::string& path,
|
||
DecodedEquirect&& decoded)
|
||
{
|
||
// 预解码数据移交 loader(Load 同步调用 lambda,引用捕获安全);
|
||
// 路径已缓存则 loader 不执行,decoded 自然丢弃(去重)
|
||
return m_Environments.Load(path,
|
||
[this, &decoded](const std::string& p) {
|
||
return m_Uploader.LoadEnvironment(p, std::move(decoded));
|
||
});
|
||
}
|
||
|
||
} // namespace Engine::Assets
|