透明来源: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 多实例不做实例级排序。
54 lines
1.9 KiB
C++
54 lines
1.9 KiB
C++
//
|
||
// Created by atdunbg on 2026/9/23.
|
||
//
|
||
|
||
#include <Engine/Renderer/VulkanAssetUploader.h>
|
||
#include <Engine/Renderer/Model.h>
|
||
#include <Engine/Renderer/IblGenerator.h>
|
||
|
||
namespace Engine {
|
||
|
||
Scope<Model> VulkanAssetUploader::LoadModel(const std::string& path)
|
||
{
|
||
// GPU 上传在此发生:解析(assimp)+ buffer/image 创建一步完成
|
||
return CreateScope<Model>(
|
||
m_Device, m_Allocator, m_Descriptors, m_TextureLayout, path);
|
||
}
|
||
|
||
Scope<Model> VulkanAssetUploader::LoadModel(const std::string& path,
|
||
ParsedModel&& parsed)
|
||
{
|
||
// 异步路径:assimp 解析已在 worker 线程完成,此处只剩 GPU 构建
|
||
return Model::FromParsed(m_Device, m_Allocator, m_Descriptors,
|
||
m_TextureLayout, std::move(parsed));
|
||
}
|
||
|
||
Scope<Model> VulkanAssetUploader::CreatePlane(f32 halfSize, u8 r, u8 g, u8 b)
|
||
{
|
||
return Model::CreatePlane(m_Device, m_Allocator, m_Descriptors,
|
||
m_TextureLayout, halfSize, r, g, b);
|
||
}
|
||
|
||
Scope<Model> VulkanAssetUploader::CreateTransparentPlane(
|
||
f32 halfSize, u8 r, u8 g, u8 b, u8 a)
|
||
{
|
||
return Model::CreateTransparentPlane(m_Device, m_Allocator,
|
||
m_Descriptors, m_TextureLayout,
|
||
halfSize, r, g, b, a);
|
||
}
|
||
|
||
Scope<Cubemap> VulkanAssetUploader::LoadEnvironment(const std::string& path)
|
||
{
|
||
// compute 预积分(毫秒级):HDR → cube + irradiance/prefilter/LUT
|
||
return m_Ibl.FromHdrEquirect(path, 1024);
|
||
}
|
||
|
||
Scope<Cubemap> VulkanAssetUploader::LoadEnvironment(
|
||
const std::string& path, DecodedEquirect&& decoded)
|
||
{
|
||
// 异步路径:decode 已在 worker 线程完成,此处只剩 GPU 段
|
||
return m_Ibl.FromDecoded(decoded, 1024, path);
|
||
}
|
||
|
||
} // namespace Engine
|