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

fix offset in a smart way so everything works #1616

Merged
merged 1 commit into from
Dec 11, 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
2 changes: 1 addition & 1 deletion zenovis/xinxinoptix/DeflMatShader.cu
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ extern "C" __global__ void __closesthit__radiance()
auto P_Local = interp(barys, v0, v1, v2);
P = optixTransformPointFromObjectToWorldSpace(P_Local); // this value has precision issue for big float

attrs.pos = P + prd->camPos;
attrs.pos = P;

float3 N_Local = normalize( cross( normalize(v1-v0), normalize(v2-v1) ) ); // this value has precision issue for big float
float3 N_World = normalize(optixTransformNormalFromObjectToWorldSpace(N_Local));
Expand Down
2 changes: 1 addition & 1 deletion zenovis/xinxinoptix/PTKernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ extern "C" __global__ void __raygen__rg()
terminal_point = camera_transform * terminal_point;
eye_shake = camera_transform * eye_shake;

float3 ray_origin = eye_shake;
float3 ray_origin = cam.eye + eye_shake;
float3 ray_direction = terminal_point - eye_shake;
ray_direction = normalize(ray_direction);

Expand Down
6 changes: 4 additions & 2 deletions zenovis/xinxinoptix/TraceStuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,11 @@ struct RadiancePRD
}

void offsetUpdateRay(float3& P, float3 new_dir) {
this->origin = P;
auto beforeOffset = P - this->camPos;
//this->origin = P;
this->direction = new_dir;
offsetRay(this->origin, new_dir);
offsetRay(beforeOffset, new_dir);
this->origin = beforeOffset + this->camPos;
}

uint8_t _mask_ = EverythingMask;
Expand Down
6 changes: 2 additions & 4 deletions zenovis/xinxinoptix/optixPathTracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ static void updateRootIAS()
{
timer.tick();
auto campos = state.params.cam.eye;
const float mat3r4c[12] = {1,0,0,-campos.x, 0,1,0,-campos.y, 0,0,1,-campos.z};
const float mat3r4c[12] = {1,0,0,0, 0,1,0,0, 0,0,1,0};
std::vector<OptixInstance> optix_instances{};
uint sbt_offset = 0u;
{
Expand Down Expand Up @@ -563,9 +563,7 @@ static void handleCameraUpdate( Params& params )
//params.vp4 = cam_vp4;

camera.setAspectRatio( static_cast<float>( params.windowSpace.x ) / static_cast<float>( params.windowSpace.y ) );
CUDA_SYNC_CHECK();
updateRootIAS();
CUDA_SYNC_CHECK();

//params.eye = camera.eye();
//camera.UVWFrame( params.U, params.V, params.W );
}
Expand Down
Loading