Skip to content

Commit

Permalink
volume shadow ray flag
Browse files Browse the repository at this point in the history
  • Loading branch information
iaomw committed Sep 24, 2024
1 parent 64d5768 commit 566d8ba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions zenovis/xinxinoptix/CallableVolume.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions zenovis/xinxinoptix/volume.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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<HitGroupData*>( 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<VolumeOut, const float4*, const VolumeIn&>( sbt_data->dc_index, sbt_data->uniforms, vin );
}

Expand Down Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions zenovis/xinxinoptix/volume.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ struct VolumeIn {
float3 pos_world;
float3 pos_view;

bool isShadowRay;

float sigma_t;
uint32_t* seed;

Expand Down

0 comments on commit 566d8ba

Please sign in to comment.