From 566d8ba263c3a22af8f3ad71ec2f7caebb9516a6 Mon Sep 17 00:00:00 2001 From: iaomw Date: Tue, 24 Sep 2024 20:01:25 +0800 Subject: [PATCH] volume shadow ray flag --- zenovis/xinxinoptix/CallableVolume.cu | 5 +++++ zenovis/xinxinoptix/volume.cu | 8 ++++++-- zenovis/xinxinoptix/volume.h | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/zenovis/xinxinoptix/CallableVolume.cu b/zenovis/xinxinoptix/CallableVolume.cu index 55b220e542..91c4aead54 100644 --- a/zenovis/xinxinoptix/CallableVolume.cu +++ b/zenovis/xinxinoptix/CallableVolume.cu @@ -105,8 +105,11 @@ struct VolumeIn2 { float3 pos_world; float3 pos_view; + bool isShadowRay; + float sigma_t; uint32_t* seed; + void* sbt_ptr; float* world2object; @@ -238,6 +241,8 @@ extern "C" __device__ VolumeOut __direct_callable__evalmat(const float4* uniform auto vdb_grids = sbt_data->vdb_grids; auto vdb_max_v = sbt_data->vdb_max_v; + auto att_isShadowRay = attrs.isShadowRay ? 1.0f:0.0f; + #ifndef _FALLBACK_ //GENERATED_BEGIN_MARK diff --git a/zenovis/xinxinoptix/volume.cu b/zenovis/xinxinoptix/volume.cu index 7e7408f719..2131272c85 100644 --- a/zenovis/xinxinoptix/volume.cu +++ b/zenovis/xinxinoptix/volume.cu @@ -96,19 +96,23 @@ extern "C" __global__ void __intersection__volume() } } -__forceinline__ __device__ auto EvalVolume(uint32_t* seed, float* m16, float sigma_t, float3& pos) { +__forceinline__ __device__ auto EvalVolume(uint32_t* seed, float* m16, float sigma_t, float3& pos, bool isShadowRay=false) { const HitGroupData* sbt_data = reinterpret_cast( optixGetSbtDataPointer() ); VolumeIn vin; vin.pos_view = pos; vin.pos_world = pos + params.cam.eye; + + vin.isShadowRay = isShadowRay; + vin.seed = seed; vin.sigma_t = sigma_t; vin.sbt_ptr = (void*)sbt_data; vin.world2object = m16; + return optixDirectCall( sbt_data->dc_index, sbt_data->uniforms, vin ); } @@ -408,7 +412,7 @@ extern "C" __global__ void __anyhit__occlusion_volume() break; } // over shoot, outside of volume - VolumeOut vol_out = EvalVolume(&prd->seed, m16, sigma_t, test_point); + VolumeOut vol_out = EvalVolume(&prd->seed, m16, sigma_t, test_point, true); const auto v_density = vol_out.density / sigma_t; diff --git a/zenovis/xinxinoptix/volume.h b/zenovis/xinxinoptix/volume.h index 7d5313cbbd..88d63eed6d 100644 --- a/zenovis/xinxinoptix/volume.h +++ b/zenovis/xinxinoptix/volume.h @@ -14,6 +14,8 @@ struct VolumeIn { float3 pos_world; float3 pos_view; + bool isShadowRay; + float sigma_t; uint32_t* seed;