diff --git a/zenovis/xinxinoptix/optixPathTracer.cpp b/zenovis/xinxinoptix/optixPathTracer.cpp index 23d3864c4f..6f5de752b3 100644 --- a/zenovis/xinxinoptix/optixPathTracer.cpp +++ b/zenovis/xinxinoptix/optixPathTracer.cpp @@ -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 ); } diff --git a/zenovis/xinxinoptix/volume.cu b/zenovis/xinxinoptix/volume.cu index 8a07eea7da..ef71a07f1d 100644 --- a/zenovis/xinxinoptix/volume.cu +++ b/zenovis/xinxinoptix/volume.cu @@ -21,8 +21,8 @@ extern "C" __global__ void __intersection__volume() const auto* grid = reinterpret_cast( 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(); @@ -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(sbt_data) }; + VolumeIn vol_in { new_orig+params.cam.eye, sigma_t, &prd->seed, reinterpret_cast(sbt_data) }; vol_out = optixDirectCall( sbt_data->dc_index, sbt_data->uniforms, vol_in); v_density = vol_out.density; @@ -188,7 +188,7 @@ extern "C" __global__ void __closesthit__radiance_volume() return scattering * thisPDF; }; - DirectLighting(prd, shadow_prd, new_orig, ray_dir, evalBxDF); + DirectLighting(prd, shadow_prd, new_orig+params.cam.eye, ray_dir, evalBxDF); prd->depth += 1; prd->radiance += prd->emission; @@ -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(sbt_data) }; + VolumeIn vol_in { test_point+params.cam.eye, sigma_t, &prd->seed, reinterpret_cast(sbt_data) }; VolumeOut vol_out = optixDirectCall( sbt_data->dc_index, sbt_data->uniforms, vol_in ); const auto v_density = vol_out.density;