Files
XCEngine/Res/Shader/volume.hlsl
ssdfasd af3b61a45a 实现 NanoVDB 边界框可视化
修改内容:
1. NanoVDBLoader 添加边界框信息读取 (worldBBox[6])
2. BattleFireDirect 添加 Volume 渲染相关函数:
   - InitVolumeRootSignature(): 体积渲染的 root signature
   - CreateVolumePSO(): 线框模式 PSO
3. main.cpp:
   - 打印 NanoVDB 边界框信息
   - 创建立方体网格表示边界框
   - 渲染绿色线框立方体
4. 修复 CreateShaderFromFile 支持 #include
5. 修复 volume.hlsl 使用 32 位地址模式

验证结果:
- 成功显示 NanoVDB 边界框线框
- 着色器能正确读取 NanoVDB 数据
2026-03-11 20:32:54 +08:00

50 lines
1.1 KiB
HLSL

#define PNANOVDB_HLSL
#define PNANOVDB_ADDRESS_32
#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);
}