Skip to content

Commit

Permalink
Merge pull request #1675 from iaomw/volin
Browse files Browse the repository at this point in the history
Adjust volume sampling for camera position
  • Loading branch information
zhxx1987 authored Dec 29, 2023
2 parents 9be0bd9 + 3e4463e commit d178294
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions zenovis/xinxinoptix/optixPathTracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,10 @@ static void updateRootIAS()
optix_instance.traversableHandle = list_volume_accel[i]->handle;
getOptixTransform( *(list_volume[i]), optix_instance.transform ); // transform as stored in Grid

optix_instance.transform[3] -= campos.x;
optix_instance.transform[7] -= campos.y;
optix_instance.transform[11] -= campos.z;

optix_instances.push_back( optix_instance );
}

Expand Down
10 changes: 5 additions & 5 deletions zenovis/xinxinoptix/volume.cu
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ extern "C" __global__ void __intersection__volume()
const auto* grid = reinterpret_cast<const GridTypeNVDB0*>( sbt_data->vdb_grids[0] );
if ( grid == nullptr) { return; }

const float3 ray_orig = optixGetWorldRayOrigin(); //optixGetObjectRayOrigin();
const float3 ray_dir = optixGetWorldRayDirection(); //optixGetObjectRayDirection();
const float3 ray_orig = optixGetWorldRayOrigin() + params.cam.eye;
const float3 ray_dir = optixGetWorldRayDirection();

auto dbox = grid->worldBBox(); //grid->indexBBox();
float t0 = optixGetRayTmin();
Expand Down Expand Up @@ -129,7 +129,7 @@ extern "C" __global__ void __closesthit__radiance_volume()

new_orig = ray_orig + (t0+t_ele) * ray_dir;

VolumeIn vol_in { new_orig, sigma_t, &prd->seed, reinterpret_cast<unsigned long long>(sbt_data) };
VolumeIn vol_in { new_orig+params.cam.eye, sigma_t, &prd->seed, reinterpret_cast<unsigned long long>(sbt_data) };

vol_out = optixDirectCall<VolumeOut, const float4*, const VolumeIn&>( sbt_data->dc_index, sbt_data->uniforms, vol_in);
v_density = vol_out.density;
Expand Down Expand Up @@ -188,7 +188,7 @@ extern "C" __global__ void __closesthit__radiance_volume()
return scattering * thisPDF;
};

DirectLighting<true>(prd, shadow_prd, new_orig, ray_dir, evalBxDF);
DirectLighting<true>(prd, shadow_prd, new_orig+params.cam.eye, ray_dir, evalBxDF);

prd->depth += 1;
prd->radiance += prd->emission;
Expand Down Expand Up @@ -227,7 +227,7 @@ extern "C" __global__ void __anyhit__occlusion_volume()
break;
} // over shoot, outside of volume

VolumeIn vol_in { test_point, sigma_t, &prd->seed, reinterpret_cast<unsigned long long>(sbt_data) };
VolumeIn vol_in { test_point+params.cam.eye, sigma_t, &prd->seed, reinterpret_cast<unsigned long long>(sbt_data) };
VolumeOut vol_out = optixDirectCall<VolumeOut, const float4*, const VolumeIn&>( sbt_data->dc_index, sbt_data->uniforms, vol_in );

const auto v_density = vol_out.density;
Expand Down

0 comments on commit d178294

Please sign in to comment.