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

Panorama camera + VR180 #1889

Merged
merged 9 commits into from
Dec 6, 2024
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
26 changes: 26 additions & 0 deletions ui/zenoedit/dialog/ZOptixCameraSetting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ ZOptixCameraSetting::ZOptixCameraSetting(zenovis::ZOptixCameraSettingInfo &info,
m_exposure->setStyleSheet("color: white;");
m_exposure->setChecked(info.exposure);

QCheckBox *m_panorama_camera = new QCheckBox(tr("PanoramaCamera"));
m_panorama_camera->setStyleSheet("color: white;");
m_panorama_camera->setChecked(info.panorama_camera);

QCheckBox *m_panorama_vr180 = new QCheckBox(tr("PanoramaVR180"));
m_panorama_vr180->setStyleSheet("color: white;");
m_panorama_vr180->setChecked(info.panorama_vr180);

QDoubleSpinBox* m_pupillary_distance = new QDoubleSpinBox();
m_pupillary_distance->setDecimals(3);
m_pupillary_distance->setRange(0.0, 10000);
m_pupillary_distance->setValue(info.pupillary_distance);

mainLayout->addWidget(new QLabel("Aperture"));
mainLayout->addWidget(m_aperture);
mainLayout->addWidget(new QLabel("ShutterSpeed"));
Expand All @@ -52,6 +65,10 @@ ZOptixCameraSetting::ZOptixCameraSetting(zenovis::ZOptixCameraSettingInfo &info,
mainLayout->addWidget(m_iso);
mainLayout->addWidget(m_aces);
mainLayout->addWidget(m_exposure);
mainLayout->addWidget(m_panorama_camera);
mainLayout->addWidget(m_panorama_vr180);
mainLayout->addWidget(new QLabel("PupillaryDistance"));
mainLayout->addWidget(m_pupillary_distance);

mainLayout->addLayout(buttonLayout);

Expand All @@ -78,5 +95,14 @@ ZOptixCameraSetting::ZOptixCameraSetting(zenovis::ZOptixCameraSettingInfo &info,
connect(m_exposure, &QCheckBox::stateChanged, this, [&](int state) {
info.exposure = state == Qt::Checked;
});
connect(m_panorama_camera, &QCheckBox::stateChanged, this, [&](int state) {
info.panorama_camera = state == Qt::Checked;
});
connect(m_panorama_vr180, &QCheckBox::stateChanged, this, [&](int state) {
info.panorama_vr180 = state == Qt::Checked;
});
connect(m_pupillary_distance, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, [&](double value) {
info.pupillary_distance = value;
});

}
13 changes: 11 additions & 2 deletions ui/zenoedit/viewport/optixviewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,10 @@ void OptixWorker::onSetData(
float shutter_speed,
float iso,
bool aces,
bool exposure
bool exposure,
bool panorama_camera,
bool panorama_vr180,
float pupillary_distance
) {
// zeno::log_info("I am in optix thread, now I want to set value {}", iso);
auto scene = m_zenoVis->getSession()->get_scene();
Expand All @@ -365,6 +368,9 @@ void OptixWorker::onSetData(
scene->camera->zOptixCameraSettingInfo.iso = iso;
scene->camera->zOptixCameraSettingInfo.aces = aces;
scene->camera->zOptixCameraSettingInfo.exposure = exposure;
scene->camera->zOptixCameraSettingInfo.panorama_camera = panorama_camera;
scene->camera->zOptixCameraSettingInfo.panorama_vr180 = panorama_vr180;
scene->camera->zOptixCameraSettingInfo.pupillary_distance = pupillary_distance;
scene->drawOptions->needRefresh = true;
}

Expand Down Expand Up @@ -460,7 +466,10 @@ void ZOptixViewport::setdata_on_optix_thread(zenovis::ZOptixCameraSettingInfo va
value.shutter_speed,
value.iso,
value.aces,
value.exposure
value.exposure,
value.panorama_camera,
value.panorama_vr180,
value.pupillary_distance
);
}

Expand Down
4 changes: 2 additions & 2 deletions ui/zenoedit/viewport/optixviewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public slots:
void onCleanUpView();
void onSetBackground(bool bShowBg);

void onSetData(float, float, float, bool, bool);
void onSetData(float, float, float, bool, bool, bool, bool, float);

private:
Zenovis *m_zenoVis;
Expand Down Expand Up @@ -111,7 +111,7 @@ class ZOptixViewport : public QWidget
void sig_cleanUpScene();
void sig_cleanUpView();
void sig_setBackground(bool bShowBg);
void sig_setdata_on_optix_thread(float, float, float, bool, bool);
void sig_setdata_on_optix_thread(float, float, float, bool, bool, bool, bool, float);

public slots:
void onFrameRunFinished(int frame);
Expand Down
7 changes: 7 additions & 0 deletions zeno/src/nodes/CameraNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ struct SetPhysicalCamera : INode {
ud.set2("iso", get_input2<float>("iso"));
ud.set2("aces", get_input2<bool>("aces"));
ud.set2("exposure", get_input2<bool>("exposure"));
ud.set2("panorama_camera", get_input2<bool>("panorama_camera"));
ud.set2("panorama_vr180", get_input2<bool>("panorama_vr180"));
ud.set2("pupillary_distance", get_input2<float>("pupillary_distance"));

set_output("camera", std::move(camera));
}
Expand All @@ -119,6 +122,10 @@ ZENO_DEFNODE(SetPhysicalCamera)({
{"float", "iso", "150"},
{"bool", "aces", "0"},
{"bool", "exposure", "0"},
{"bool", "exposure", "0"},
{"bool", "panorama_camera", "0"},
{"bool", "panorama_vr180", "0"},
{"float", "pupillary_distance", "0.06"},
},
{
{"CameraObject", "camera"},
Expand Down
5 changes: 4 additions & 1 deletion zenovis/include/zenovis/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ struct ZOptixCameraSettingInfo {
float iso = 150;
bool aces = false;
bool exposure = false;
bool panorama_camera = false;
bool panorama_vr180 = false;
float pupillary_distance = 0.06;
};

struct Camera {
Expand Down Expand Up @@ -89,7 +92,7 @@ struct Camera {
float get_safe_frames() const;
bool is_locked_window() const;
void setCamera(zeno::CameraData const &cam);
void setPhysicalCamera(float aperture, float shutter_speed, float iso, bool aces, bool exposure);
void setPhysicalCamera(float aperture, float shutter_speed, float iso, bool aces, bool exposure, bool panorama_camera, bool panorama_vr180, float pupillary_distance);
void placeCamera(glm::vec3 pos, glm::vec3 view, glm::vec3 up);
void placeCamera(glm::vec3 pos, glm::quat rotation);
void focusCamera(float cx, float cy, float cz, float radius);
Expand Down
5 changes: 4 additions & 1 deletion zenovis/src/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ void Camera::setCamera(zeno::CameraData const &cam) {
}
}

void Camera::setPhysicalCamera(float aperture, float shutter_speed, float iso, bool aces, bool exposure) {
void Camera::setPhysicalCamera(float aperture, float shutter_speed, float iso, bool aces, bool exposure, bool panorama_camera, bool panorama_vr180, float pupillary_distance) {
this->zOptixCameraSettingInfo.aperture = aperture;
this->zOptixCameraSettingInfo.shutter_speed = shutter_speed;
this->zOptixCameraSettingInfo.iso = iso;
this->zOptixCameraSettingInfo.aces = aces;
this->zOptixCameraSettingInfo.exposure = exposure;
this->zOptixCameraSettingInfo.panorama_camera = panorama_camera;
this->zOptixCameraSettingInfo.panorama_vr180 = panorama_vr180;
this->zOptixCameraSettingInfo.pupillary_distance = pupillary_distance;
}

void Camera::placeCamera(glm::vec3 pos, glm::vec3 view, glm::vec3 up) {
Expand Down
15 changes: 12 additions & 3 deletions zenovis/src/optx/RenderEngineOptx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,10 @@ struct GraphicsManager {
ud.get2<float>("shutter_speed"),
ud.get2<float>("iso"),
ud.get2<bool>("aces"),
ud.get2<bool>("exposure")
ud.get2<bool>("exposure"),
ud.get2<bool>("panorama_camera"),
ud.get2<bool>("panorama_vr180"),
ud.get2<float>("pupillary_distance")
);
}
}
Expand Down Expand Up @@ -1068,7 +1071,10 @@ struct GraphicsManager {
ud.get2<float>("shutter_speed"),
ud.get2<float>("iso"),
ud.get2<bool>("aces"),
ud.get2<bool>("exposure")
ud.get2<bool>("exposure"),
ud.get2<bool>("panorama_camera"),
ud.get2<bool>("panorama_vr180"),
ud.get2<float>("pupillary_distance")
);
}
}
Expand Down Expand Up @@ -1328,7 +1334,10 @@ struct RenderEngineOptx : RenderEngine, zeno::disable_copy {
cam.zOptixCameraSettingInfo.shutter_speed,
cam.zOptixCameraSettingInfo.iso,
cam.zOptixCameraSettingInfo.aces,
cam.zOptixCameraSettingInfo.exposure
cam.zOptixCameraSettingInfo.exposure,
cam.zOptixCameraSettingInfo.panorama_camera,
cam.zOptixCameraSettingInfo.panorama_vr180,
cam.zOptixCameraSettingInfo.pupillary_distance
);
}

Expand Down
25 changes: 25 additions & 0 deletions zenovis/xinxinoptix/PTKernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,31 @@ extern "C" __global__ void __raygen__rg()
float3 ray_origin = eye_shake;
float3 ray_direction = terminal_point - eye_shake;
ray_direction = normalize(ray_direction);
if (params.physical_camera_panorama_camera) {
ray_origin = make_float3(0.0f, 0.0f, 0.0f);
float phi = (float(idx.x) + subpixel_jitter.x) / float(w) * 2.0f * M_PIf;
mat3 camera_transform = mat3(
cam.right.x, cam.up.x, -cam.front.x,
cam.right.y, cam.up.y, -cam.front.y,
cam.right.z, cam.up.z, -cam.front.z
);
if (params.physical_camera_panorama_vr180) {
int idxx = idx.x >= w/2? idx.x - w/2 : idx.x;
phi = ((float(idxx) + subpixel_jitter.x) / float(w / 2) + 0.5f) * M_PIf;
if (idx.x < w / 2) {
ray_origin = camera_transform * make_float3(-params.physical_camera_pupillary_distance / 2.0f, 0.0f, 0.0f);
}
else {
ray_origin = camera_transform * make_float3(params.physical_camera_pupillary_distance / 2.0f, 0.0f, 0.0f);
}
}
float theta = (float(idx.y) + subpixel_jitter.y) / float(h) * M_PIf;
float y = -cosf(theta);
float z = sinf(theta) * cosf(phi);
float x = sinf(theta) * sinf(-phi);

ray_direction = camera_transform * make_float3(x, y, z);
}

RadiancePRD prd;
prd.pixel_area = cam.height/(float)(h)/(cam.focal_length);
Expand Down
6 changes: 5 additions & 1 deletion zenovis/xinxinoptix/optixPathTracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2870,12 +2870,16 @@ void set_window_size(int nx, int ny) {
camera_changed = true;
resize_dirty = true;
}
void set_physical_camera_param(float aperture, float shutter_speed, float iso, bool aces, bool exposure) {

void set_physical_camera_param(float aperture, float shutter_speed, float iso, bool aces, bool exposure, bool panorama_camera, bool panorama_vr180, float pupillary_distance) {
state.params.physical_camera_aperture = aperture;
state.params.physical_camera_shutter_speed = shutter_speed;
state.params.physical_camera_iso = iso;
state.params.physical_camera_aces = aces;
state.params.physical_camera_exposure = exposure;
state.params.physical_camera_panorama_camera = panorama_camera;
state.params.physical_camera_panorama_vr180 = panorama_vr180;
state.params.physical_camera_pupillary_distance = pupillary_distance;
}
void set_perspective(float const *U, float const *V, float const *W, float const *E, float aspect, float fov, float fpd, float aperture) {
set_perspective_by_fov(U,V,W,E,aspect,fov,0,0.024f,fpd,aperture,0.0f,0.0f,0.0f,0.0f);
Expand Down
3 changes: 3 additions & 0 deletions zenovis/xinxinoptix/optixPathTracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ struct Params
float physical_camera_iso;
bool physical_camera_aces;
bool physical_camera_exposure;
bool physical_camera_panorama_camera;
bool physical_camera_panorama_vr180;
float physical_camera_pupillary_distance;
};


Expand Down
2 changes: 1 addition & 1 deletion zenovis/xinxinoptix/xinxinoptixapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void optixupdateend();
void set_window_size(int nx, int ny);
void set_outside_random_number(int32_t outside_random_number);
void set_perspective(float const *U, float const *V, float const *W, float const *E, float aspect, float fov, float fpd, float aperture);
void set_physical_camera_param(float aperture, float shutter_speed, float iso, bool aces, bool exposure);
void set_physical_camera_param(float aperture, float shutter_speed, float iso, bool aces, bool exposure, bool panorama_camera, bool panorama_vr180, float pupillary_distance);
void set_perspective_by_fov(float const *U, float const *V, float const *W, float const *E, float aspect, float fov, int fov_type, float L, float focal_distance, float aperture, float pitch, float yaw, float h_shift, float v_shift);
void set_perspective_by_focal_length(float const *U, float const *V, float const *W, float const *E, float aspect, float focal_length, float w, float h, float focal_distance, float aperture, float pitch, float yaw, float h_shift, float v_shift);

Expand Down
Loading