Skip to content

Commit

Permalink
Merge pull request #1929 from iaomw/sky
Browse files Browse the repository at this point in the history
Sky Composer
  • Loading branch information
iaomw authored Jun 17, 2024
2 parents 28f0efe + 1facdc0 commit c881387
Show file tree
Hide file tree
Showing 34 changed files with 2,018 additions and 558 deletions.
2 changes: 2 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Write-Output "Making minimum build with Optix..."

cmake -G Ninja -B build -DCMAKE_BUILD_TYPE="${b}" `
-DCMAKE_TOOLCHAIN_FILE="${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" `
-DDEACTIVATE_ZLIB=ON `
-DZENO_WITH_zenvdb:BOOL=ON `
-DZENO_SYSTEM_OPENVDB:BOOL=OFF `
-DZENO_WITH_ZenoFX:BOOL=ON `
Expand All @@ -86,6 +87,7 @@ Write-Output "Making full build..."

cmake -G Ninja -B build -DCMAKE_BUILD_TYPE="${b}" `
-DCMAKE_TOOLCHAIN_FILE="${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" `
-DDEACTIVATE_ZLIB=ON `
-DZENO_WITH_CUDA:BOOL=ON `
-DZENO_WITH_ZenoFX:BOOL=ON `
-DZENO_ENABLE_OPTIX:BOOL=ON `
Expand Down
8 changes: 5 additions & 3 deletions misc/graphs/mis.zsg
Original file line number Diff line number Diff line change
Expand Up @@ -4497,7 +4497,7 @@
"enable": {
"link": null,
"type": "bool",
"default-value": false,
"default-value": true,
"control": {
"name": "Boolean"
}
Expand Down Expand Up @@ -4533,7 +4533,7 @@
"strength": {
"link": null,
"type": "float",
"default-value": 1.0,
"default-value": 0.0,
"control": {
"name": "Float"
}
Expand All @@ -4560,7 +4560,9 @@
6656.0884600564509,
487.12836685064578
],
"options": []
"options": [
"VIEW"
]
}
},
"view_rect": {}
Expand Down
2 changes: 1 addition & 1 deletion ui/zenoedit/launch/serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using namespace JsonHelper;

QSet<QString> lightCameraNodes({
"CameraEval", "CameraNode", "CihouMayaCameraFov", "ExtractCameraData", "GetAlembicCamera","MakeCamera",
"LightNode", "BindLight", "ProceduralSky", "HDRSky",
"LightNode", "BindLight", "ProceduralSky", "HDRSky", "SkyComposer"
});

std::set<std::string> matNodeNames = {"ShaderFinalize", "ShaderVolume", "ShaderVolumeHomogeneous"};
Expand Down
4 changes: 2 additions & 2 deletions ui/zenoedit/viewport/optixviewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ void OptixWorker::onSetBackground(bool bShowBg)
ZASSERT_EXIT(session);
auto scene = session->get_scene();
ZASSERT_EXIT(scene);
scene->objectsMan->needUpdateLight = true;
scene->drawOptions->simpleRender = true;
//scene->objectsMan->needUpdateLight = true;
//scene->drawOptions->simpleRender = true;
updateFrame();
}

Expand Down
19 changes: 11 additions & 8 deletions ui/zenoedit/zenomainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1682,14 +1682,6 @@ bool ZenoMainWindow::openFile(QString filePath)
if (!pModel)
return false;

//cleanup
zeno::getSession().globalComm->clearFrameState();
auto views = viewports();
for (auto view : views)
{
view->cleanUpScene();
}

resetTimeline(pGraphs->timeInfo());
recordRecentFile(filePath);
initUserdata(pGraphs->userdataInfo());
Expand Down Expand Up @@ -2014,6 +2006,17 @@ bool ZenoMainWindow::saveQuit() {
return false;
}
}

//cleanup
if (pModel) {
zeno::getSession().globalComm->clearFrameState();
auto views = viewports();
for (auto view : views)
{
view->cleanUpScene();
}
}

pGraphsMgm->clear();
//clear timeline info.
resetTimeline(TIMELINE_INFO());
Expand Down
1 change: 1 addition & 0 deletions zeno/include/zeno/extra/GlobalComm.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct GlobalComm {
ZENO_API bool load_objects(const int frameid,
const std::function<bool(std::map<std::string, std::shared_ptr<zeno::IObject>> const& objs)>& cb,
bool& isFrameValid);
ZENO_API void clear_objects(const std::function<void()>& cb);
ZENO_API bool isFrameCompleted(int frameid) const;
ZENO_API FRAME_STATE getFrameState(int frameid) const;
ZENO_API bool isFrameBroken(int frameid) const;
Expand Down
15 changes: 15 additions & 0 deletions zeno/include/zeno/types/LightObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
#include <zeno/core/IObject.h>
#include <zeno/utils/vec.h>

#else

#ifndef vec3f
#define vec3f vec3
#endif

#endif

namespace zeno {
Expand All @@ -23,6 +29,15 @@ namespace zeno {
LightConfigDoubleside = 2u
};

struct DistantLightData {
vec3f direction;
float angle;
vec3f color;
float intensity;

DistantLightData() = default;
};

#ifndef __CUDACC_RTC__

struct LightData {
Expand Down
27 changes: 27 additions & 0 deletions zeno/include/zeno/utils/pfm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include <vector>
#include <string>
#include <cstring>

#include <zeno/utils/format.h>
#include <zeno/utils/fileio.h>

namespace zeno {

static void write_pfm(const char* path, int w, int h, const float *pixel, bool mono=false) {
std::string header = zeno::format("PF\n{} {}\n-1.0\n", w, h);
char channel = 3;

if (mono) {
header = zeno::format("Pf\n{} {}\n-1.0\n", w, h);
channel = 1;
}

std::vector<char> data(header.size() + w * h * sizeof(float) * channel);
memcpy(data.data(), header.data(), header.size());
memcpy(data.data() + header.size(), pixel, w * h * sizeof(float) * channel);
zeno::file_put_binary(data, path);
}

}
12 changes: 11 additions & 1 deletion zeno/src/extra/GlobalComm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace zeno {
std::vector<std::filesystem::path> cachepath(3);
std::unordered_set<std::string> lightCameraNodes({
"CameraEval", "CameraNode", "CihouMayaCameraFov", "ExtractCameraData", "GetAlembicCamera","MakeCamera",
"LightNode", "BindLight", "ProceduralSky", "HDRSky",
"LightNode", "BindLight", "ProceduralSky", "HDRSky", "SkyComposer"
});
std::set<std::string> matNodeNames = {"ShaderFinalize", "ShaderVolume", "ShaderVolumeHomogeneous"};

Expand Down Expand Up @@ -337,6 +337,16 @@ ZENO_API GlobalComm::ViewObjects const &GlobalComm::getViewObjects() {
return m_frames.back().view_objects;
}

ZENO_API void GlobalComm::clear_objects(const std::function<void()>& callback)
{
std::lock_guard lck(m_mtx);
if (!callback)
return;

callback();
}


ZENO_API bool GlobalComm::load_objects(
const int frameid,
const std::function<bool(std::map<std::string, std::shared_ptr<zeno::IObject>> const& objs)>& callback,
Expand Down
Loading

0 comments on commit c881387

Please sign in to comment.