完成步骤2:读取 NanoVDB 密度并渲染体积云 修改内容: 1. NanoVDBLoader: 添加 voxel_size 输出用于调试 2. volume.hlsl: 实现完整的 ray marching 体积渲染 - 初始化 NanoVDB 访问器 - 密度采样函数 - 光线步进和累积 3. wireframe.hlsl: 新增边界框线框着色器 4. main.cpp: - 移动相机到云的外部 - 添加独立的常量缓冲区避免冲突 - 同时渲染体积云和边界框 已知问题: - 边界框位置计算需要改进 - bunny.nvdb 渲染效果不佳 - 需要进一步优化密度和步进参数
26 lines
402 B
HLSL
26 lines
402 B
HLSL
cbuffer CB0 : register(b1)
|
|
{
|
|
float4x4 _ViewProjection;
|
|
};
|
|
|
|
struct VSInput
|
|
{
|
|
float3 position : POSITION;
|
|
};
|
|
|
|
struct PSInput
|
|
{
|
|
float4 position : SV_POSITION;
|
|
};
|
|
|
|
PSInput MainVS(VSInput input)
|
|
{
|
|
PSInput output;
|
|
output.position = mul(_ViewProjection, float4(input.position, 1.0));
|
|
return output;
|
|
}
|
|
|
|
float4 MainPS(PSInput input) : SV_TARGET
|
|
{
|
|
return float4(0.0, 1.0, 0.0, 1.0);
|
|
} |