feat: IBL 预积分 GPU compute 化 + 环境资产入 Assets 层(动态切换)
CPU 逐像素卷积(venice 4k 阻塞 7.36s)→ 4 个 compute shader 一次性 提交:equirect→cube / irradiance / prefilter×5mip / BRDF LUT。 Cubemap 瘦身为纯资源持有类,生成职责移交 IblGenerator; 环境经 AssetManager 缓存(EnvRef),Renderer::SetEnvironment 动态换绑(RenderPass::OnEnvironmentChanged 广播)。 调试视图 +4:EnvCube / Irradiance / Prefilter / BRDF LUT。 性能前后对比(RTX 5060 Laptop,venice_dawn_1_4k.hdr): - 改造前 CPU:7.36 s(主线程阻塞) - 改造后 GPU:HDR decode 127-134ms + 资源 22-35ms + compute 17-19ms ≈ 165-190ms(约 40×);Neutral 兜底 ~6ms - 运行中动态切换环境同量级(ms 级 GPU,decode 占大头) 冒烟:两构建目录 0 警告;运行期 0 validation(含两次环境切换 + 调试视图 9-12 轮播自动化验证)。
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#version 450
|
||||
|
||||
// IBL ①:等距柱状 HDR → 环境 cube(6 面重采样)。
|
||||
// 替代原 CPU 逐像素 SampleEquirect 双线性查表——GPU 上直接用硬件
|
||||
// 线性过滤采样(经度接缝由 S=eRepeat 处理),观感与 CPU 版一致。
|
||||
// 输出为 image2DArray(layer = face),图像本体带 CUBE_COMPATIBLE,
|
||||
// 采样端另建 eCube view。
|
||||
|
||||
#include "ibl_common.glsl"
|
||||
|
||||
layout(local_size_x = 8, local_size_y = 8) in;
|
||||
|
||||
layout(set = 0, binding = 0) uniform sampler2D equirect;
|
||||
layout(set = 0, binding = 1, rgba16f) uniform restrict writeonly image2DArray outCube;
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec3 gid = ivec3(gl_GlobalInvocationID);
|
||||
ivec2 size = imageSize(outCube).xy;
|
||||
if (gid.x >= size.x || gid.y >= size.y) return;
|
||||
|
||||
vec2 uv = (vec2(gid.xy) + 0.5) / vec2(size);
|
||||
vec3 dir = iblFaceDir(uint(gid.z), uv.x, uv.y);
|
||||
vec3 rgb = texture(equirect, iblDirToEquirectUv(dir)).rgb;
|
||||
|
||||
imageStore(outCube, gid, vec4(rgb, 1.0));
|
||||
}
|
||||
Reference in New Issue
Block a user