From 06fcbf1912e5d77946c2dbca4823ec132cfabbe3 Mon Sep 17 00:00:00 2001 From: littlemine Date: Tue, 4 Jun 2024 17:44:17 +0800 Subject: [PATCH 1/3] for glm log --- zeno/include/zeno/utils/to_string.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/zeno/include/zeno/utils/to_string.h b/zeno/include/zeno/utils/to_string.h index d44309d9ee..da08fa9bee 100644 --- a/zeno/include/zeno/utils/to_string.h +++ b/zeno/include/zeno/utils/to_string.h @@ -52,6 +52,16 @@ struct _to_stream_impl { return _helper_tuple_to_stream(os, t, fms, std::make_index_sequence - 1>{}); } + template + static auto to_stream(Os &os, T const &t, std::string_view fms) -> decltype((std::enable_if_t::value && !_has_range_begin_end::value, void>)(std::declval()[0], std::declval().length())) { + os << "[glm: "; + for (int i = 0; i < t.length(); ++i) { + to_stream(os, t[i], fms); + os << ", "; + } + os << "]"; + } + template ::value && (std::tuple_size::value == 0), int> = 0> static void to_stream(Os &os, T const &t, std::string_view fms) { From 45a42b1625b3e40b1c803ebb0b10f78c89edc8df Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Tue, 4 Jun 2024 20:12:06 +0800 Subject: [PATCH 2/3] fix-optix-lightmap --- zenovis/src/optx/RenderEngineOptx.cpp | 9 +++++++++ zenovis/xinxinoptix/optixPathTracer.cpp | 5 +++++ zenovis/xinxinoptix/xinxinoptixapi.h | 1 + 3 files changed, 15 insertions(+) diff --git a/zenovis/src/optx/RenderEngineOptx.cpp b/zenovis/src/optx/RenderEngineOptx.cpp index b6ba4c66c2..e6287db440 100644 --- a/zenovis/src/optx/RenderEngineOptx.cpp +++ b/zenovis/src/optx/RenderEngineOptx.cpp @@ -1152,6 +1152,15 @@ struct RenderEngineOptx : RenderEngine, zeno::disable_copy { } } } + // add light map + for(auto const &[_, ld]: xinxinoptix::get_lightdats()) { + if (ld.profileKey.size()) { + realNeedTexPaths.emplace_back(ld.profileKey); + } + if (ld.textureKey.size()) { + realNeedTexPaths.emplace_back(ld.textureKey); + } + } std::vector needToRemoveTexPaths; for(auto const &[tex, _]: OptixUtil::g_tex) { if (std::find(realNeedTexPaths.begin(), realNeedTexPaths.end(), tex) != realNeedTexPaths.end()) { diff --git a/zenovis/xinxinoptix/optixPathTracer.cpp b/zenovis/xinxinoptix/optixPathTracer.cpp index 4f4ba44181..41f83e5399 100644 --- a/zenovis/xinxinoptix/optixPathTracer.cpp +++ b/zenovis/xinxinoptix/optixPathTracer.cpp @@ -2099,6 +2099,11 @@ static std::map lightdats; static std::vector triangleLightCoords; static std::vector triangleLightNormals; + +std::map &get_lightdats() { + return lightdats; +} + void unload_light(){ lightdats.clear(); diff --git a/zenovis/xinxinoptix/xinxinoptixapi.h b/zenovis/xinxinoptix/xinxinoptixapi.h index 826145e270..fd40f09ebd 100644 --- a/zenovis/xinxinoptix/xinxinoptixapi.h +++ b/zenovis/xinxinoptix/xinxinoptixapi.h @@ -104,4 +104,5 @@ void using_hdr_sky(bool enable); void show_background(bool enable); // void optixUpdateUniforms(std::vector & inConstants); void optixUpdateUniforms(void *inConstants, std::size_t size); +std::map &get_lightdats(); } From c97314d027e2a6d3672eb99d6517a51b673d5325 Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Fri, 7 Jun 2024 16:20:36 +0800 Subject: [PATCH 3/3] fix-camera --- ui/zenoedit/viewport/displaywidget.cpp | 4 +--- zenovis/include/zenovis/Camera.h | 1 + zenovis/src/Camera.cpp | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ui/zenoedit/viewport/displaywidget.cpp b/ui/zenoedit/viewport/displaywidget.cpp index 5a01efa4ef..46fcc826e1 100644 --- a/ui/zenoedit/viewport/displaywidget.cpp +++ b/ui/zenoedit/viewport/displaywidget.cpp @@ -1383,12 +1383,10 @@ void DisplayWidget::onNodeSelected(const QModelIndex &subgIdx, const QModelIndex Zenovis *pZenovis = m_glView->getZenoVis(); ZASSERT_EXIT(pZenovis && pZenovis->getSession()); auto scene = pZenovis->getSession()->get_scene(); - auto _near = scene->camera->m_near; - auto _far = scene->camera->m_far; auto fov = scene->camera->m_fov; auto cz = glm::length(scene->camera->m_lodcenter); if (depth != 0) { - cz = scene->camera->m_near / depth; + cz = scene->camera->inf_z_near / depth; } auto w = scene->camera->m_nx; auto h = scene->camera->m_ny; diff --git a/zenovis/include/zenovis/Camera.h b/zenovis/include/zenovis/Camera.h index 00126d5de2..c6b1983006 100644 --- a/zenovis/include/zenovis/Camera.h +++ b/zenovis/include/zenovis/Camera.h @@ -20,6 +20,7 @@ struct ZOptixCameraSettingInfo { }; struct Camera { + float inf_z_near = 0.001f; int m_nx{512}, m_ny{512}; glm::mat4x4 m_view{1}, m_proj{1}; diff --git a/zenovis/src/Camera.cpp b/zenovis/src/Camera.cpp index 56a0354de5..232d820946 100644 --- a/zenovis/src/Camera.cpp +++ b/zenovis/src/Camera.cpp @@ -82,7 +82,7 @@ void Camera::placeCamera(glm::vec3 pos, glm::vec3 front, glm::vec3 up) { m_proj = glm::orthoZO(-radius * getAspect(), radius * getAspect(), -radius, radius, m_far, m_near); } else { - m_proj = MakeInfReversedZProjRH(glm::radians(m_fov), getAspect(), 0.001); + m_proj = MakeInfReversedZProjRH(glm::radians(m_fov), getAspect(), inf_z_near); } } @@ -107,7 +107,7 @@ void Camera::updateMatrix() { void Camera::setResolution(int nx, int ny) { m_nx = nx; m_ny = ny; - m_proj = MakeInfReversedZProjRH(glm::radians(m_fov), getAspect(), m_near); + m_proj = MakeInfReversedZProjRH(glm::radians(m_fov), getAspect(), inf_z_near); } void Camera::setResolutionInfo(bool block, int nx, int ny) {