Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust volume sampling for camera position #1675

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading