添加 NanoVDB 体积渲染着色器

1. 复制 PNanoVDB.hlsl 到 Res/Shader/
   - GPU 端读取 NanoVDB 数据的核心库

2. 创建 volume.hlsl 体积渲染着色器
   - 包含 VS 和 PS 入口
   - 读取 NanoVDB 边界框数据
   - 已通过 fxc 编译验证
This commit is contained in:
2026-03-11 20:14:49 +08:00
parent 15a9a31faf
commit bc58abc98f
2 changed files with 3504 additions and 0 deletions

50
Res/Shader/volume.hlsl Normal file
View File

@@ -0,0 +1,50 @@
#define PNANOVDB_HLSL
#define PNANOVDB_ADDRESS_64
#include "PNanoVDB.hlsl"
cbuffer CB0 : register(b1)
{
float4x4 _ViewProjection;
float3 _CameraPos;
float _DensityScale;
};
StructuredBuffer<uint> buf : register(t1);
struct VSInput
{
float3 position : POSITION;
};
struct PSInput
{
float4 position : SV_POSITION;
float3 worldPos : TEXCOORD0;
};
PSInput MainVS(VSInput input)
{
PSInput output;
output.position = mul(_ViewProjection, float4(input.position, 1.0));
output.worldPos = input.position;
return output;
}
float4 MainPS(PSInput input) : SV_TARGET
{
pnanovdb_grid_handle_t grid;
grid.address.byte_offset = 0;
float3 worldBboxMin = float3(
(float)pnanovdb_grid_get_world_bbox(buf, grid, 0),
(float)pnanovdb_grid_get_world_bbox(buf, grid, 1),
(float)pnanovdb_grid_get_world_bbox(buf, grid, 2)
);
float3 worldBboxMax = float3(
(float)pnanovdb_grid_get_world_bbox(buf, grid, 3),
(float)pnanovdb_grid_get_world_bbox(buf, grid, 4),
(float)pnanovdb_grid_get_world_bbox(buf, grid, 5)
);
return float4(0.0, 1.0, 0.0, 1.0);
}