From 686806645a4f667a31b5d56a9bd275aab72f7690 Mon Sep 17 00:00:00 2001 From: luzh Date: Mon, 15 Aug 2022 20:30:29 +0800 Subject: [PATCH 01/10] [dev] cameranode custom edit control. --- ui/zenoedit/nodesys/cameranode.cpp | 81 +++++++++++++++++++++++ ui/zenoedit/nodesys/cameranode.h | 21 ++++++ ui/zenoedit/nodesys/zenonode.cpp | 7 +- ui/zenoedit/nodesys/zenosubgraphscene.cpp | 5 ++ 4 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 ui/zenoedit/nodesys/cameranode.cpp create mode 100644 ui/zenoedit/nodesys/cameranode.h diff --git a/ui/zenoedit/nodesys/cameranode.cpp b/ui/zenoedit/nodesys/cameranode.cpp new file mode 100644 index 0000000000..6ff274de42 --- /dev/null +++ b/ui/zenoedit/nodesys/cameranode.cpp @@ -0,0 +1,81 @@ +#include "cameranode.h" +#include "util/log.h" +#include +#include "zenoapplication.h" +#include "graphsmanagment.h" + + +CameraNode::CameraNode(const NodeUtilParam& params, QGraphicsItem* parent) + : ZenoNode(params, parent) +{ + +} + +CameraNode::~CameraNode() +{ + +} + +QGraphicsLinearLayout* CameraNode::initCustomParamWidgets() +{ + QGraphicsLinearLayout* pHLayout = new QGraphicsLinearLayout(Qt::Horizontal); + + ZenoTextLayoutItem* pNameItem = new ZenoTextLayoutItem("sync", m_renderParams.paramFont, m_renderParams.paramClr.color()); + pHLayout->addItem(pNameItem); + + ZenoParamPushButton* pEditBtn = new ZenoParamPushButton("Edit", -1, QSizePolicy::Expanding); + pHLayout->addItem(pEditBtn); + connect(pEditBtn, SIGNAL(clicked()), this, SLOT(onEditClicked())); + + return pHLayout; +} + +void CameraNode::onEditClicked() +{ + INPUT_SOCKETS inputs = index().data(ROLE_INPUTS).value(); + ZASSERT_EXIT(inputs.find("pos") != inputs.end() && + inputs.find("up") != inputs.end() && + inputs.find("view") != inputs.end() && + inputs.find("frame") != inputs.end()); + + const QString& nodeid = this->nodeId(); + IGraphsModel* pModel = zenoApp->graphsManagment()->currentModel(); + ZASSERT_EXIT(pModel); + + UI_VECTYPE vec({ 0., 0., 0. }); + + PARAM_UPDATE_INFO info; + + pModel->beginTransaction("update camera info"); + + INPUT_SOCKET pos = inputs["pos"]; + //TODO: get pos from viewport camera. + //vec = ... + info.name = "pos"; + info.oldValue = pos.info.defaultValue; + info.newValue = QVariant::fromValue(vec); + pModel->updateSocketDefl(nodeid, info, this->subgIndex(), true); + + INPUT_SOCKET up = inputs["up"]; + //TODO: get pos from viewport camera. + //vec = ... + info.name = "up"; + info.oldValue = up.info.defaultValue; + info.newValue = QVariant::fromValue(vec); + pModel->updateSocketDefl(nodeid, info, this->subgIndex(), true); + + INPUT_SOCKET view = inputs["view"]; + //TODO: get view from viewport camera. + //vec = ... + info.name = "view"; + info.oldValue = view.info.defaultValue; + info.newValue = QVariant::fromValue(vec); + pModel->updateSocketDefl(nodeid, info, this->subgIndex(), true); + + INPUT_SOCKET frame = inputs["frame"]; + //TODO: get frame from viewport camera. + //frame = ... + info.name = "frame"; + info.oldValue = frame.info.defaultValue; + frame.info.defaultValue = QVariant::fromValue(vec); +} \ No newline at end of file diff --git a/ui/zenoedit/nodesys/cameranode.h b/ui/zenoedit/nodesys/cameranode.h new file mode 100644 index 0000000000..a8fbce2512 --- /dev/null +++ b/ui/zenoedit/nodesys/cameranode.h @@ -0,0 +1,21 @@ +#ifndef __CAMERA_NODE_H__ +#define __CAMERA_NODE_H__ + +#include "zenonode.h" + +class CameraNode : public ZenoNode +{ + Q_OBJECT +public: + CameraNode(const NodeUtilParam& params, QGraphicsItem* parent = nullptr); + ~CameraNode(); + +protected: + QGraphicsLinearLayout* initCustomParamWidgets() override; + +private slots: + void onEditClicked(); +}; + + +#endif \ No newline at end of file diff --git a/ui/zenoedit/nodesys/zenonode.cpp b/ui/zenoedit/nodesys/zenonode.cpp index 016097eac2..a0530ccd07 100644 --- a/ui/zenoedit/nodesys/zenonode.cpp +++ b/ui/zenoedit/nodesys/zenonode.cpp @@ -349,8 +349,13 @@ QGraphicsLayout* ZenoNode::initParams() } } QGraphicsLinearLayout* pCustomParams = initCustomParamWidgets(); - if (pParamsLayout && pCustomParams) + if (pCustomParams) + { + if (!pParamsLayout) + pParamsLayout = new QGraphicsLinearLayout(Qt::Vertical); + ZASSERT_EXIT(pParamsLayout, nullptr); pParamsLayout->addItem(pCustomParams); + } return pParamsLayout; } diff --git a/ui/zenoedit/nodesys/zenosubgraphscene.cpp b/ui/zenoedit/nodesys/zenosubgraphscene.cpp index aac6f73770..a4e51bddff 100644 --- a/ui/zenoedit/nodesys/zenosubgraphscene.cpp +++ b/ui/zenoedit/nodesys/zenosubgraphscene.cpp @@ -3,6 +3,7 @@ #include "subnetnode.h" #include "heatmapnode.h" #include "curvenode.h" +#include "cameranode.h" #include "dynamicnumbernode.h" #include "zenolink.h" #include @@ -144,6 +145,10 @@ ZenoNode* ZenoSubGraphScene::createNode(const QModelIndex& idx, const NodeUtilPa { return new BlackboardNode(params); } + else if (descName == "CameraNode") + { + return new CameraNode(params); + } else { return new ZenoNode(params); From f08a6d37fac895391e79bfec00be539541cc5e3c Mon Sep 17 00:00:00 2001 From: Aaron <910854285@qq.com> Date: Mon, 15 Aug 2022 21:41:04 +0800 Subject: [PATCH 02/10] camera prop --- projects/FBX/dem-bones-bin | 2 +- ui/zenoedit/nodesys/cameranode.cpp | 34 ++++++++++++++++++++++-------- zenovis/include/zenovis/Scene.h | 1 + zenovis/src/Scene.cpp | 15 +++++++++++++ 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/projects/FBX/dem-bones-bin b/projects/FBX/dem-bones-bin index c370986871..8ea5472c87 160000 --- a/projects/FBX/dem-bones-bin +++ b/projects/FBX/dem-bones-bin @@ -1 +1 @@ -Subproject commit c3709868715fd23081e9f618b43808b454469ae0 +Subproject commit 8ea5472c87a6fb96e58e3ab6f78d88c765f8fc05 diff --git a/ui/zenoedit/nodesys/cameranode.cpp b/ui/zenoedit/nodesys/cameranode.cpp index 6ff274de42..d844963a5e 100644 --- a/ui/zenoedit/nodesys/cameranode.cpp +++ b/ui/zenoedit/nodesys/cameranode.cpp @@ -4,6 +4,14 @@ #include "zenoapplication.h" #include "graphsmanagment.h" +#include +#include "zenovis/Session.h" +#include +#include + +// FIXME fatal error C1189: #error: OpenGL header already included, +// remove this include, glad already provides it +//#include "zenovis/Camera.h" CameraNode::CameraNode(const NodeUtilParam& params, QGraphicsItem* parent) : ZenoNode(params, parent) @@ -42,6 +50,13 @@ void CameraNode::onEditClicked() IGraphsModel* pModel = zenoApp->graphsManagment()->currentModel(); ZASSERT_EXIT(pModel); + auto &inst = Zenovis::GetInstance(); + auto sess = inst.getSession(); + ZASSERT_EXIT(sess); + + auto scene = sess->get_scene(); + ZASSERT_EXIT(scene); + UI_VECTYPE vec({ 0., 0., 0. }); PARAM_UPDATE_INFO info; @@ -49,33 +64,34 @@ void CameraNode::onEditClicked() pModel->beginTransaction("update camera info"); INPUT_SOCKET pos = inputs["pos"]; - //TODO: get pos from viewport camera. - //vec = ... + //vec = {scene->camera->m_lodcenter.x, scene->camera->m_lodcenter.y, scene->camera->m_lodcenter.z}; + std::vector camProp = scene->getCameraProp(); + vec = {camProp[0], camProp[1], camProp[2]}; info.name = "pos"; info.oldValue = pos.info.defaultValue; info.newValue = QVariant::fromValue(vec); pModel->updateSocketDefl(nodeid, info, this->subgIndex(), true); INPUT_SOCKET up = inputs["up"]; - //TODO: get pos from viewport camera. - //vec = ... + vec = {camProp[6], camProp[7], camProp[8]}; info.name = "up"; info.oldValue = up.info.defaultValue; info.newValue = QVariant::fromValue(vec); pModel->updateSocketDefl(nodeid, info, this->subgIndex(), true); INPUT_SOCKET view = inputs["view"]; - //TODO: get view from viewport camera. - //vec = ... + vec = {camProp[3], camProp[4], camProp[5]}; info.name = "view"; info.oldValue = view.info.defaultValue; info.newValue = QVariant::fromValue(vec); pModel->updateSocketDefl(nodeid, info, this->subgIndex(), true); INPUT_SOCKET frame = inputs["frame"]; - //TODO: get frame from viewport camera. - //frame = ... + // FIXME Not work + int frameId = sess->get_curr_frameid(); + frameId = zeno::getSession().globalState->frameid; + info.name = "frame"; info.oldValue = frame.info.defaultValue; - frame.info.defaultValue = QVariant::fromValue(vec); + frame.info.defaultValue = QVariant::fromValue(frameId); } \ No newline at end of file diff --git a/zenovis/include/zenovis/Scene.h b/zenovis/include/zenovis/Scene.h index dba68870b5..522f9b0de0 100644 --- a/zenovis/include/zenovis/Scene.h +++ b/zenovis/include/zenovis/Scene.h @@ -36,6 +36,7 @@ struct Scene : zeno::disable_copy { std::vector record_frame_offline(int nsamples = 1, int hdrSize = 1, int rgbComps = 3); bool cameraFocusOnNode(std::string const &nodeid, zeno::vec3f ¢er, float &radius); static void loadGLAPI(void *procaddr); + std::vector getCameraProp(); }; } // namespace zenovis diff --git a/zenovis/src/Scene.cpp b/zenovis/src/Scene.cpp index 6ff179e6ec..4174e15ea8 100644 --- a/zenovis/src/Scene.cpp +++ b/zenovis/src/Scene.cpp @@ -46,6 +46,21 @@ void Scene::switchRenderEngine(std::string const &name) { renderMan->switchDefaultEngine(name); } +std::vector Scene::getCameraProp(){ + std::vector camProp; + camProp.push_back(this->camera->m_lodcenter.x); + camProp.push_back(this->camera->m_lodcenter.y); + camProp.push_back(this->camera->m_lodcenter.z); + camProp.push_back(this->camera->m_lodfront.x); + camProp.push_back(this->camera->m_lodfront.y); + camProp.push_back(this->camera->m_lodfront.z); + camProp.push_back(this->camera->m_lodup.x); + camProp.push_back(this->camera->m_lodup.y); + camProp.push_back(this->camera->m_lodup.z); + + return camProp; +} + bool Scene::cameraFocusOnNode(std::string const &nodeid, zeno::vec3f ¢er, float &radius) { for (auto const &[key, ptr]: this->objectsMan->pairs()) { if (nodeid == key.substr(0, key.find_first_of(':'))) { From 94a559a3c17f60dc77b8fc284e81feb8f7cbdd3d Mon Sep 17 00:00:00 2001 From: Aaron <910854285@qq.com> Date: Mon, 15 Aug 2022 23:40:31 +0800 Subject: [PATCH 03/10] ReadLightFromFile and submodule dem-bones-bin --- projects/FBX/Definition.h | 21 ++++++++++ projects/FBX/ReadFBX.cpp | 80 +++++++++++++++++++++++++++++++++++++- projects/FBX/dem-bones-bin | 2 +- 3 files changed, 101 insertions(+), 2 deletions(-) diff --git a/projects/FBX/Definition.h b/projects/FBX/Definition.h index 4cc5c5d563..5c4f9240c7 100644 --- a/projects/FBX/Definition.h +++ b/projects/FBX/Definition.h @@ -39,6 +39,15 @@ inline namespace ZenoFBXDefinition { #define COMMON_DEFAULT_strokeTint aiColor4D(0.0f, 0.0f, 0.0f, 1.0f) #define COMMON_DEFAULT_opacity aiColor4D(0.0f, 0.0f, 0.0f, 1.0f) +#define LIGHT_STR_SPLIT_V3F \ + auto sl = Helper::splitStr(l, ','); \ + zeno::vec3f tmp{ \ + (float)atof(sl[0].c_str()), \ + (float)atof(sl[1].c_str()), \ + (float)atof(sl[2].c_str())}; \ + auto no = std::make_shared(); \ + no->set(tmp); + struct SKeyPosition { aiVector3D position; float timeStamp; @@ -504,6 +513,18 @@ struct Helper{ std::cout << "\t"; std::cout << root->name <<"\n"; } + + static std::vector splitStr(std::string str, char c){ + std::stringstream test(str); + std::string segment; + std::vector seglist; + + while(std::getline(test, segment, c)) + { + seglist.push_back(segment); + } + return seglist; + } }; } diff --git a/projects/FBX/ReadFBX.cpp b/projects/FBX/ReadFBX.cpp index 16e3e10abe..12bb4fe303 100644 --- a/projects/FBX/ReadFBX.cpp +++ b/projects/FBX/ReadFBX.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -29,6 +30,7 @@ #include #include #include +#include #include #include @@ -401,7 +403,10 @@ struct Mesh{ SMaterial mat; mat.matName = matName; - std::string vmPath = createTexDir("valueTex/" + matName); + + std::string tmpMatName = matName; + std::replace(matName.begin(), matName.end(), ':', '_'); + std::string vmPath = createTexDir("valueTex/" + tmpMatName); zeno::log_info("FBX: Mesh name {} Mat name {}", relMeshName, matName); @@ -1009,4 +1014,77 @@ ZENDEFNODE(ReadFBXPrim, } }); +struct ReadLightFromFile : zeno::INode { + virtual void apply() override { + auto path = get_input("path")->get(); + zeno::log_info("Light: File path {}", path); + + auto posList = std::make_shared(); + auto rotList = std::make_shared(); + auto sclList = std::make_shared(); + auto colList = std::make_shared(); + auto intList = std::make_shared(); + + std::ifstream infile(path); + if (infile.is_open()) { + std::string line; + int num = 0; + while (std::getline(infile, line)) { + // using printf() in all tests for consistency + std::string l = line.c_str(); + printf("Light: Processing %s\n", l.c_str()); + if(num%6==0){ + LIGHT_STR_SPLIT_V3F + //printf("Light: Pos %.2f %.2f %.2f\n", tmp[0], tmp[1], tmp[2]); + posList->arr.push_back(no); + } + if(num%6==1){ + LIGHT_STR_SPLIT_V3F + //printf("Light: Rot %.2f %.2f %.2f\n", tmp[0], tmp[1], tmp[2]); + rotList->arr.push_back(no); + } + if(num%6==2){ + LIGHT_STR_SPLIT_V3F + //printf("Light: Scl %.2f %.2f %.2f\n", tmp[0], tmp[1], tmp[2]); + sclList->arr.push_back(no); + } + if(num%6==3){ + LIGHT_STR_SPLIT_V3F + //printf("Light: Col %.2f %.2f %.2f\n", tmp[0], tmp[1], tmp[2]); + colList->arr.push_back(no); + } + if(num%6==4){ + auto no = std::make_shared(); + float tmp = (float)atof(l.c_str()); + no->set(tmp); + //printf("Light: Int %.2f\n", tmp); + intList->arr.push_back(no); + } + + num++; + } + infile.close(); + } + + set_output("posList", std::move(posList)); + set_output("rotList", std::move(rotList)); + set_output("sclList", std::move(sclList)); + set_output("colList", std::move(colList)); + set_output("intList", std::move(intList)); + } +}; +ZENDEFNODE(ReadLightFromFile, + { /* inputs: */ + { + {"readpath", "path"}, + }, /* outputs: */ + { + "posList", "rotList", "sclList", "colList", "intList" + }, /* params: */ + { + }, /* category: */ + { + "FBX", + } + }); } diff --git a/projects/FBX/dem-bones-bin b/projects/FBX/dem-bones-bin index 8ea5472c87..c370986871 160000 --- a/projects/FBX/dem-bones-bin +++ b/projects/FBX/dem-bones-bin @@ -1 +1 @@ -Subproject commit 8ea5472c87a6fb96e58e3ab6f78d88c765f8fc05 +Subproject commit c3709868715fd23081e9f618b43808b454469ae0 From 94a61b7f7464fab7ab9589625cb6f19bf1034bfc Mon Sep 17 00:00:00 2001 From: Aaron <910854285@qq.com> Date: Mon, 15 Aug 2022 23:59:01 +0800 Subject: [PATCH 04/10] fix fbx namespace --- projects/FBX/ReadFBX.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/FBX/ReadFBX.cpp b/projects/FBX/ReadFBX.cpp index 12bb4fe303..8defcd81a8 100644 --- a/projects/FBX/ReadFBX.cpp +++ b/projects/FBX/ReadFBX.cpp @@ -405,7 +405,7 @@ struct Mesh{ std::string tmpMatName = matName; - std::replace(matName.begin(), matName.end(), ':', '_'); + std::replace(tmpMatName.begin(), tmpMatName.end(), ':', '_'); std::string vmPath = createTexDir("valueTex/" + tmpMatName); zeno::log_info("FBX: Mesh name {} Mat name {}", relMeshName, matName); From adedf0aa4e8b3142de282a160a4368b83c7e7a60 Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Tue, 16 Aug 2022 02:14:13 +0800 Subject: [PATCH 05/10] search-improve --- ui/zenoedit/model/graphsmodel.cpp | 48 ++++++++++++++++++++++++++- ui/zenoedit/nodesys/zenosearchbar.cpp | 3 ++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/ui/zenoedit/model/graphsmodel.cpp b/ui/zenoedit/model/graphsmodel.cpp index 8e2f5c6f85..89571f1099 100644 --- a/ui/zenoedit/model/graphsmodel.cpp +++ b/ui/zenoedit/model/graphsmodel.cpp @@ -1774,7 +1774,53 @@ void GraphsModel::onModelInited() QModelIndexList GraphsModel::searchInSubgraph(const QString& objName, const QModelIndex& subgIdx) { SubGraphModel* pModel = subGraph(subgIdx.row()); - return pModel->match(pModel->index(0, 0), ROLE_OBJNAME, objName, -1, Qt::MatchContains); + QModelIndexList list; + auto count = pModel->rowCount(); + + for (auto i = 0; i < count; i++) { + auto index = pModel->index(i, 0); + auto item = pModel->itemData(index); + if (item[ROLE_OBJID].toString().contains(objName)) { + list.append(index); + } + else { + QString _type("string"); + bool inserted = false; + { + auto params = item[ROLE_PARAMETERS].value(); + auto iter = params.begin(); + while (iter != params.end()) { + if (iter.value().typeDesc == _type) { + if (iter.value().value.toString().contains(objName)) { + list.append(index); + inserted = true; + break; + } + } + ++iter; + } + } + if (inserted) { + continue; + } + { + auto inputs = item[ROLE_INPUTS].value(); + auto iter = inputs.begin(); + while (iter != inputs.end()) { + if (iter->value().info.type == _type) { + if (iter->value().info.defaultValue.toString().contains(objName)) { + list.append(index); + inserted = true; + break; + } + } + ++iter; + } + + } + } + } + return list; } QModelIndexList GraphsModel::subgraphsIndice() const diff --git a/ui/zenoedit/nodesys/zenosearchbar.cpp b/ui/zenoedit/nodesys/zenosearchbar.cpp index 3c4c50587f..b70a377bff 100644 --- a/ui/zenoedit/nodesys/zenosearchbar.cpp +++ b/ui/zenoedit/nodesys/zenosearchbar.cpp @@ -69,6 +69,9 @@ SEARCH_RECORD ZenoSearchBar::_getRecord() void ZenoSearchBar::onSearchExec(const QString& content) { + if (content.isEmpty()) { + return; + } IGraphsModel* pGraphsModel = zenoApp->graphsManagment()->currentModel(); m_results = pGraphsModel->searchInSubgraph(content, m_index); From b97d174b16e2c78de9a0afa9edf00c20b43dd727 Mon Sep 17 00:00:00 2001 From: littlemine Date: Tue, 16 Aug 2022 02:58:13 +0800 Subject: [PATCH 06/10] +accd threshold, fix gd (fric), stable surf gen --- projects/CUDA/fem/Ccds.hpp | 4 +- projects/CUDA/fem/Codim.cu | 351 ++++++++++++++++++------------- projects/CUDA/fem/Generation.cpp | 279 ++++++++++++------------ projects/CUDA/mpm/Generation.cu | 2 +- 4 files changed, 347 insertions(+), 289 deletions(-) diff --git a/projects/CUDA/fem/Ccds.hpp b/projects/CUDA/fem/Ccds.hpp index 3bc2e70276..bfc82bb685 100644 --- a/projects/CUDA/fem/Ccds.hpp +++ b/projects/CUDA/fem/Ccds.hpp @@ -92,7 +92,7 @@ ptccd(VecT p, VecT t0, VecT t1, VecT t2, VecT dp, VecT dt0, VecT dt1, VecT dt2, T toc_prev = toc; toc = tStart; int iter = 0; - while (++iter < 20000) { + while (++iter < 1000000) { // while (true) { T tocLowerBound = (1 - eta) * (dist2_cur - thickness * thickness) / ((dist_cur + thickness) * maxDispMag); @@ -155,7 +155,7 @@ eeccd(VecT ea0, VecT ea1, VecT eb0, VecT eb1, VecT dea0, VecT dea1, VecT deb0, T toc_prev = toc; toc = tStart; int iter = 0; - while (++iter < 20000) { + while (++iter < 1000000) { // while (true) { T tocLowerBound = (1 - eta) * dFunc / ((dist_cur + thickness) * maxDispMag); if (tocLowerBound < 0) diff --git a/projects/CUDA/fem/Codim.cu b/projects/CUDA/fem/Codim.cu index 98f9b5a72e..3c19479e86 100644 --- a/projects/CUDA/fem/Codim.cu +++ b/projects/CUDA/fem/Codim.cu @@ -331,6 +331,9 @@ struct CodimStepping : INode { surfEdges{ zsprim.getQuadraturePoints()}, // all elements are surface edges surfVerts{zsprim[ZenoParticles::s_surfVertTag]}, vOffset{vOffset}, + svtemp{zsprim.getQuadraturePoints().get_allocator(), + {{"H", 3 * 3}, {"fn", 1}}, + zsprim[ZenoParticles::s_surfVertTag].size()}, sfOffset{sfOffset}, seOffset{seOffset}, svOffset{svOffset}, category{zsprim.category} { if (category != ZenoParticles::curve) @@ -351,6 +354,9 @@ struct CodimStepping : INode { surfTris{zsprim.getQuadraturePoints()}, surfEdges{zsprim[ZenoParticles::s_surfEdgeTag]}, surfVerts{zsprim[ZenoParticles::s_surfVertTag]}, vOffset{vOffset}, + svtemp{zsprim.getQuadraturePoints().get_allocator(), + {{"H", 3 * 3}, {"fn", 1}}, + zsprim[ZenoParticles::s_surfVertTag].size()}, sfOffset{sfOffset}, seOffset{seOffset}, svOffset{svOffset}, category{zsprim.category} { if (category != ZenoParticles::surface) @@ -371,6 +377,9 @@ struct CodimStepping : INode { surfTris{zsprim[ZenoParticles::s_surfTriTag]}, surfEdges{zsprim[ZenoParticles::s_surfEdgeTag]}, surfVerts{zsprim[ZenoParticles::s_surfVertTag]}, vOffset{vOffset}, + svtemp{zsprim.getQuadraturePoints().get_allocator(), + {{"H", 3 * 3}, {"fn", 1}}, + zsprim[ZenoParticles::s_surfVertTag].size()}, sfOffset{sfOffset}, seOffset{seOffset}, svOffset{svOffset}, category{zsprim.category} { if (category != ZenoParticles::tet) @@ -465,6 +474,7 @@ struct CodimStepping : INode { typename ZenoParticles::particles_t &surfEdges; // not required for codim obj typename ZenoParticles::particles_t &surfVerts; + typename ZenoParticles::dtiles_t svtemp; const std::size_t vOffset, sfOffset, seOffset, svOffset; ZenoParticles::category_e category; }; @@ -1220,19 +1230,27 @@ struct CodimStepping : INode { edge_edge_tangent_basis(ea0, ea1, eb0, eb1); }); if (s_enableGround) { - pol(range(coOffset), - [vtemp = proxy({}, vtemp), tempPB = proxy({}, tempPB), - kappa = kappa, xi2 = xi * xi, activeGap2, - gn = s_groundNormal] ZS_LAMBDA(int vi) mutable { - auto x = vtemp.pack<3>("xn", vi); - auto dist = gn.dot(x); - auto dist2 = dist * dist; - if (dist2 < activeGap2) { - auto bGrad = barrier_gradient(dist2 - xi2, activeGap2, kappa); - tempPB("fn", vi) = -bGrad * 2 * dist; - } else - tempPB("fn", vi) = 0; - }); + for (auto &primHandle : prims) { + if (primHandle.isBoundary()) // skip soft boundary + continue; + const auto &svs = primHandle.getSurfVerts(); + pol(range(svs.size()), + [vtemp = proxy({}, vtemp), svs = proxy({}, svs), + svtemp = proxy({}, primHandle.svtemp), kappa = kappa, + xi2 = xi * xi, activeGap2, gn = s_groundNormal, + svOffset = primHandle.svOffset] ZS_LAMBDA(int svi) mutable { + const auto vi = + reinterpret_bits(svs("inds", svi)) + svOffset; + auto x = vtemp.pack<3>("xn", vi); + auto dist = gn.dot(x); + auto dist2 = dist * dist; + if (dist2 < activeGap2) { + auto bGrad = barrier_gradient(dist2 - xi2, activeGap2, kappa); + svtemp("fn", svi) = -bGrad * 2 * dist; + } else + svtemp("fn", svi) = 0; + }); + } } } bool checkSelfIntersection(zs::CudaExecutionPolicy &pol) { @@ -1529,104 +1547,119 @@ struct CodimStepping : INode { bool includeHessian = true) { using namespace zs; constexpr auto space = execspace_e::cuda; - pol(range(coOffset), - [vtemp = proxy({}, vtemp), tempPB = proxy({}, tempPB), - gTag, gn = s_groundNormal, dHat2 = dHat * dHat, kappa = kappa, - projectDBC = projectDBC, includeHessian] ZS_LAMBDA(int vi) mutable { - auto x = vtemp.pack<3>("xn", vi); - auto dist = gn.dot(x); - auto dist2 = dist * dist; - auto t = dist2 - dHat2; - auto g_b = t * zs::log(dist2 / dHat2) * -2 - (t * t) / dist2; - auto H_b = (zs::log(dist2 / dHat2) * -2.0 - t * 4.0 / dist2) + - 1.0 / (dist2 * dist2) * (t * t); - if (dist2 < dHat2) { - auto grad = -gn * (kappa * g_b * 2 * dist); - for (int d = 0; d != 3; ++d) - atomic_add(exec_cuda, &vtemp(gTag, d, vi), grad(d)); - } - - if (!includeHessian) - return; - auto param = 4 * H_b * dist2 + 2 * g_b; - auto hess = mat3::zeros(); - if (dist2 < dHat2 && param > 0) { - auto nn = dyadic_prod(gn, gn); - hess = (kappa * param) * nn; - } - - // make_pd(hess); - mat3 BCbasis[1] = {vtemp.pack<3, 3>("BCbasis", vi)}; - int BCorder[1] = {(int)vtemp("BCorder", vi)}; - int BCfixed[1] = {(int)vtemp("BCfixed", vi)}; - rotate_hessian(hess, BCbasis, BCorder, BCfixed, projectDBC); - tempPB.tuple<9>("H", vi) = hess; - for (int i = 0; i != 3; ++i) - for (int j = 0; j != 3; ++j) { - atomic_add(exec_cuda, &vtemp("P", i * 3 + j, vi), hess(i, j)); - } - }); - -#if s_enableFriction - if (fricMu != 0) { - pol(range(coOffset), - [vtemp = proxy({}, vtemp), tempPB = proxy({}, tempPB), - gTag, epsvh = epsv * dt, gn = s_groundNormal, fricMu = fricMu, - projectDBC = projectDBC, - includeHessian] ZS_LAMBDA(int vi) mutable { - auto dx = vtemp.pack<3>("xn", vi) - vtemp.pack<3>("xhat", vi); - auto fn = tempPB("fn", vi); - if (fn == 0) { - return; + for (auto &primHandle : prims) { + if (primHandle.isBoundary()) // skip soft boundary + continue; + const auto &svs = primHandle.getSurfVerts(); + pol(range(svs.size()), + [vtemp = proxy({}, vtemp), + svtemp = proxy({}, primHandle.svtemp), + svs = proxy({}, svs), gTag, gn = s_groundNormal, + dHat2 = dHat * dHat, kappa = kappa, projectDBC = projectDBC, + includeHessian, + svOffset = primHandle.svOffset] ZS_LAMBDA(int svi) mutable { + const auto vi = + reinterpret_bits(svs("inds", svi)) + svOffset; + auto x = vtemp.pack<3>("xn", vi); + auto dist = gn.dot(x); + auto dist2 = dist * dist; + auto t = dist2 - dHat2; + auto g_b = t * zs::log(dist2 / dHat2) * -2 - (t * t) / dist2; + auto H_b = (zs::log(dist2 / dHat2) * -2.0 - t * 4.0 / dist2) + + 1.0 / (dist2 * dist2) * (t * t); + if (dist2 < dHat2) { + auto grad = -gn * (kappa * g_b * 2 * dist); + for (int d = 0; d != 3; ++d) + atomic_add(exec_cuda, &vtemp(gTag, d, vi), grad(d)); } - auto coeff = fn * fricMu; - auto relDX = dx - gn.dot(dx) * gn; - auto relDXNorm2 = relDX.l2NormSqr(); - auto relDXNorm = zs::sqrt(relDXNorm2); - - vec3 grad{}; - if (relDXNorm2 >= epsvh * epsvh) - grad = -relDX * (coeff / relDXNorm); - else - grad = -relDX * (coeff / epsvh); - for (int d = 0; d != 3; ++d) - atomic_add(exec_cuda, &vtemp(gTag, d, vi), grad(d)); if (!includeHessian) return; - + auto param = 4 * H_b * dist2 + 2 * g_b; auto hess = mat3::zeros(); - if (relDXNorm2 >= epsvh * epsvh) { - zs::vec mat{ - relDX[0] * relDX[0] * -coeff / relDXNorm2 / relDXNorm + - coeff / relDXNorm, - relDX[0] * relDX[2] * -coeff / relDXNorm2 / relDXNorm, - relDX[0] * relDX[2] * -coeff / relDXNorm2 / relDXNorm, - relDX[2] * relDX[2] * -coeff / relDXNorm2 / relDXNorm + - coeff / relDXNorm}; - make_pd(mat); - hess(0, 0) = mat(0, 0); - hess(0, 2) = mat(0, 1); - hess(2, 0) = mat(1, 0); - hess(2, 2) = mat(1, 1); - } else { - hess(0, 0) = coeff / epsvh; - hess(2, 2) = coeff / epsvh; + if (dist2 < dHat2 && param > 0) { + auto nn = dyadic_prod(gn, gn); + hess = (kappa * param) * nn; } + // make_pd(hess); mat3 BCbasis[1] = {vtemp.pack<3, 3>("BCbasis", vi)}; int BCorder[1] = {(int)vtemp("BCorder", vi)}; int BCfixed[1] = {(int)vtemp("BCfixed", vi)}; rotate_hessian(hess, BCbasis, BCorder, BCfixed, projectDBC); - tempPB.template tuple<9>("H", vi) = - tempPB.template pack<3, 3>("H", vi) + hess; + svtemp.tuple<9>("H", svi) = hess; for (int i = 0; i != 3; ++i) for (int j = 0; j != 3; ++j) { atomic_add(exec_cuda, &vtemp("P", i * 3 + j, vi), hess(i, j)); } }); - } + +#if s_enableFriction + if (fricMu != 0) { + pol(range(svs.size()), + [vtemp = proxy({}, vtemp), + svtemp = proxy({}, primHandle.svtemp), + svs = proxy({}, svs), gTag, epsvh = epsv * dt, + gn = s_groundNormal, fricMu = fricMu, projectDBC = projectDBC, + includeHessian, + svOffset = primHandle.svOffset] ZS_LAMBDA(int svi) mutable { + const auto vi = + reinterpret_bits(svs("inds", svi)) + svOffset; + auto dx = vtemp.pack<3>("xn", vi) - vtemp.pack<3>("xhat", vi); + auto fn = svtemp("fn", svi); + if (fn == 0) { + return; + } + auto coeff = fn * fricMu; + auto relDX = dx - gn.dot(dx) * gn; + auto relDXNorm2 = relDX.l2NormSqr(); + auto relDXNorm = zs::sqrt(relDXNorm2); + + vec3 grad{}; + if (relDXNorm2 >= epsvh * epsvh) + grad = -relDX * (coeff / relDXNorm); + else + grad = -relDX * (coeff / epsvh); + for (int d = 0; d != 3; ++d) + atomic_add(exec_cuda, &vtemp(gTag, d, vi), grad(d)); + + if (!includeHessian) + return; + + auto hess = mat3::zeros(); + if (relDXNorm2 >= epsvh * epsvh) { + zs::vec mat{ + relDX[0] * relDX[0] * -coeff / relDXNorm2 / relDXNorm + + coeff / relDXNorm, + relDX[0] * relDX[2] * -coeff / relDXNorm2 / relDXNorm, + relDX[0] * relDX[2] * -coeff / relDXNorm2 / relDXNorm, + relDX[2] * relDX[2] * -coeff / relDXNorm2 / relDXNorm + + coeff / relDXNorm}; + make_pd(mat); + hess(0, 0) = mat(0, 0); + hess(0, 2) = mat(0, 1); + hess(2, 0) = mat(1, 0); + hess(2, 2) = mat(1, 1); + } else { + hess(0, 0) = coeff / epsvh; + hess(2, 2) = coeff / epsvh; + } + + mat3 BCbasis[1] = {vtemp.pack<3, 3>("BCbasis", vi)}; + int BCorder[1] = {(int)vtemp("BCorder", vi)}; + int BCfixed[1] = {(int)vtemp("BCfixed", vi)}; + rotate_hessian(hess, BCbasis, BCorder, BCfixed, projectDBC); + svtemp.template tuple<9>("H", svi) = + svtemp.template pack<3, 3>("H", svi) + hess; + for (int i = 0; i != 3; ++i) + for (int j = 0; j != 3; ++j) { + atomic_add(exec_cuda, &vtemp("P", i * 3 + j, vi), + hess(i, j)); + } + }); + } #endif + } return; } template @@ -2461,52 +2494,66 @@ struct CodimStepping : INode { } #endif if (s_enableGround) { - // boundary - es.resize(count_warps(coOffset)); - es.reset(0); - pol(range(coOffset), - [vtemp = proxy({}, vtemp), es = proxy(es), - gn = s_groundNormal, dHat2 = dHat * dHat, - n = coOffset] ZS_LAMBDA(int vi) mutable { - auto x = vtemp.pack<3>("xn", vi); - auto dist = gn.dot(x); - auto dist2 = dist * dist; - T E; - if (dist2 < dHat2) - E = -zs::sqr(dist2 - dHat2) * zs::log(dist2 / dHat2); - else - E = 0; - reduce_to(vi, n, E, es[vi / 32]); - }); - Es.push_back(reduce(pol, es) * kappa); + for (auto &primHandle : prims) { + if (primHandle.isBoundary()) // skip soft boundary + continue; + const auto &svs = primHandle.getSurfVerts(); + // boundary + es.resize(count_warps(svs.size())); + es.reset(0); + pol(range(svs.size()), + [vtemp = proxy({}, vtemp), svs = proxy({}, svs), + es = proxy(es), gn = s_groundNormal, + dHat2 = dHat * dHat, n = svs.size(), + svOffset = primHandle.svOffset] ZS_LAMBDA(int svi) mutable { + const auto vi = + reinterpret_bits(svs("inds", svi)) + svOffset; + auto x = vtemp.pack<3>("xn", vi); + auto dist = gn.dot(x); + auto dist2 = dist * dist; + T E; + if (dist2 < dHat2) + E = -zs::sqr(dist2 - dHat2) * zs::log(dist2 / dHat2); + else + E = 0; + reduce_to(svi, n, E, es[svi / 32]); + }); + Es.push_back(reduce(pol, es) * kappa); #if s_enableFriction - if (fricMu != 0) { - es.resize(count_warps(coOffset)); - es.reset(0); - pol(range(coOffset), - [vtemp = proxy({}, vtemp), es = proxy(es), - gn = s_groundNormal, dHat2 = dHat * dHat, epsvh = epsv * dt, - fricMu = fricMu, n = coOffset] ZS_LAMBDA(int vi) mutable { - auto fn = vtemp("fn", vi); - T E = 0; - if (fn != 0) { - auto dx = - vtemp.pack<3>("xn", vi) - vtemp.pack<3>("xhat", vi); - auto relDX = dx - gn.dot(dx) * gn; - auto relDXNorm2 = relDX.l2NormSqr(); - auto relDXNorm = zs::sqrt(relDXNorm2); - if (relDXNorm2 >= epsvh * epsvh) { - E = fn * (relDXNorm - epsvh / 2); - } else { - E = fn * relDXNorm2 / epsvh / 2; + if (fricMu != 0) { + es.resize(count_warps(svs.size())); + es.reset(0); + pol(range(svs.size()), + [vtemp = proxy({}, vtemp), + svtemp = proxy({}, primHandle.svtemp), + svs = proxy({}, svs), es = proxy(es), + gn = s_groundNormal, dHat = dHat, epsvh = epsv * dt, + fricMu = fricMu, n = svs.size(), + svOffset = primHandle.svOffset] ZS_LAMBDA(int svi) mutable { + const auto vi = + reinterpret_bits(svs("inds", svi)) + svOffset; + auto fn = svtemp("fn", svi); + auto x = vtemp.pack<3>("xn", vi); + auto dist = gn.dot(x); + T E = 0; + if (fn != 0 && dist < dHat) { + auto dx = x - vtemp.pack<3>("xhat", vi); + auto relDX = dx - gn.dot(dx) * gn; + auto relDXNorm2 = relDX.l2NormSqr(); + auto relDXNorm = zs::sqrt(relDXNorm2); + if (relDXNorm2 >= epsvh * epsvh) { + E = fn * (relDXNorm - epsvh / 2); + } else { + E = fn * relDXNorm2 / epsvh / 2; + } } - } - reduce_to(vi, n, E, es[vi / 32]); - }); - Es.push_back(reduce(pol, es)); - } + reduce_to(svi, n, E, es[svi / 32]); + }); + Es.push_back(reduce(pol, es)); + } #endif + } } } // constraints @@ -4036,15 +4083,24 @@ struct CodimStepping : INode { #endif if (s_enableGround) { // boundary - pol(range(coOffset), [execTag, vtemp = proxy({}, vtemp), - tempPB = proxy({}, tempPB), dxTag, - bTag] ZS_LAMBDA(int vi) mutable { - auto dx = vtemp.template pack<3>(dxTag, vi); - auto pbHess = tempPB.template pack<3, 3>("H", vi); - dx = pbHess * dx; - for (int d = 0; d != 3; ++d) - atomic_add(execTag, &vtemp(bTag, d, vi), dx(d)); - }); + for (auto &primHandle : prims) { + if (primHandle.isBoundary()) // skip soft boundary + continue; + const auto &svs = primHandle.getSurfVerts(); + pol(range(svs.size()), + [execTag, vtemp = proxy({}, vtemp), dxTag, bTag, + svtemp = proxy({}, primHandle.svtemp), + svs = proxy({}, svs), + svOffset = primHandle.svOffset] ZS_LAMBDA(int svi) mutable { + const auto vi = + reinterpret_bits(svs("inds", svi)) + svOffset; + auto dx = vtemp.template pack<3>(dxTag, vi); + auto pbHess = svtemp.template pack<3, 3>("H", svi); + dx = pbHess * dx; + for (int d = 0; d != 3; ++d) + atomic_add(execTag, &vtemp(bTag, d, vi), dx(d)); + }); + } } } // end contacts @@ -4552,9 +4608,8 @@ struct CodimStepping : INode { {"p", 3}, {"q", 3}}, numDofs}; - // ground + inertial hessian - tempPB = dtiles_t{ - vtemp.get_allocator(), {{"H", 9}, {"Hi", 9}, {"fn", 1}}, coOffset}; + // inertial hessian + tempPB = dtiles_t{vtemp.get_allocator(), {{"Hi", 9}}, coOffset}; nPP.setVal(0); nPE.setVal(0); nPT.setVal(0); diff --git a/projects/CUDA/fem/Generation.cpp b/projects/CUDA/fem/Generation.cpp index 9d7dea96ec..3b9d97b53f 100644 --- a/projects/CUDA/fem/Generation.cpp +++ b/projects/CUDA/fem/Generation.cpp @@ -80,40 +80,41 @@ struct ExtractMeshSurface : INode { std::vector lines; std::vector lineAreas; std::vector tris; -#if 1 - { - using namespace zs; - zs::HashTable surfTable{0}; - constexpr auto space = zs::execspace_e::openmp; - - surfTable.resize(ompExec, 4 * numEles); - surfTable.reset(ompExec, true); - // compute getsurface - // std::vector tri2tet(4 * numEles); - ompExec(range(numEles), [table = proxy(surfTable), - &quads](int ei) mutable { - using table_t = RM_CVREF_T(table); - using vec3i = zs::vec; - auto record = [&table, ei](const vec3i &triInds) mutable { - if (auto sno = table.insert(triInds); sno != table_t::sentinel_v) - ; // tri2tet[sno] = ei; - else - printf("ridiculous, more than one tet share the same " - "surface!"); - }; - auto inds = quads[ei]; - record(vec3i{inds[0], inds[2], inds[1]}); - record(vec3i{inds[0], inds[3], inds[2]}); - record(vec3i{inds[0], inds[1], inds[3]}); - record(vec3i{inds[1], inds[2], inds[3]}); - }); - // - tris.resize(numEles * 4); - Vector surfCnt{1, memsrc_e::host}; - surfCnt.setVal(0); - ompExec(range(surfTable.size()), - [table = proxy(surfTable), surfCnt = surfCnt.data(), - &tris](int i) mutable { +#if 0 + { + using namespace zs; + zs::HashTable surfTable{0}; + constexpr auto space = zs::execspace_e::openmp; + + surfTable.resize(ompExec, 4 * numEles); + surfTable.reset(ompExec, true); + // compute getsurface + // std::vector tri2tet(4 * numEles); + ompExec(range(numEles), [table = proxy(surfTable), + &quads](int ei) mutable { + using table_t = RM_CVREF_T(table); + using vec3i = zs::vec; + auto record = [&table, ei](const vec3i &triInds) mutable { + if (auto sno = table.insert(triInds); + sno != table_t::sentinel_v) + ; // tri2tet[sno] = ei; + else + printf("ridiculous, more than one tet share the same " + "surface!"); + }; + auto inds = quads[ei]; + record(vec3i{inds[0], inds[2], inds[1]}); + record(vec3i{inds[0], inds[3], inds[2]}); + record(vec3i{inds[0], inds[1], inds[3]}); + record(vec3i{inds[1], inds[2], inds[3]}); + }); + // + tris.resize(numEles * 4); + Vector surfCnt{1, memsrc_e::host}; + surfCnt.setVal(0); + ompExec(range(surfTable.size()), [table = proxy(surfTable), + surfCnt = surfCnt.data(), + &tris](int i) mutable { using vec3i = zs::vec; auto triInds = table._activeKeys[i]; using table_t = RM_CVREF_T(table); @@ -123,78 +124,80 @@ struct ExtractMeshSurface : INode { table_t::sentinel_v && table.query(vec3i{triInds[0], triInds[2], triInds[1]}) == table_t::sentinel_v) - tris[atomic_add(exec_omp, surfCnt, 1)] = - zeno::vec3i{triInds[0], triInds[1], triInds[2]}; - }); - auto scnt = surfCnt.getVal(); - tris.resize(scnt); - fmt::print("{} surfaces\n", scnt); - - // surface points - HashTable vertTable{numVerts}; - HashTable edgeTable{3 * numEles}; - vertTable.reset(ompExec, true); - edgeTable.reset(ompExec, true); - ompExec(tris, - [vertTable = proxy(vertTable), - edgeTable = proxy(edgeTable)](vec3i triInds) mutable { + tris[atomic_add(exec_omp, surfCnt, 1)] = + zeno::vec3i{triInds[0], triInds[1], triInds[2]}; + }); + auto scnt = surfCnt.getVal(); + tris.resize(scnt); + fmt::print("{} surfaces\n", scnt); + + // surface points + HashTable vertTable{numVerts}; + HashTable edgeTable{3 * numEles}; + vertTable.reset(ompExec, true); + edgeTable.reset(ompExec, true); + ompExec(tris, [vertTable = proxy(vertTable), + edgeTable = + proxy(edgeTable)](vec3i triInds) mutable { using vec1i = zs::vec; using vec2i = zs::vec; for (int d = 0; d != 3; ++d) { - vertTable.insert(vec1i{triInds[d]}); - edgeTable.insert(vec2i{triInds[d], triInds[(d + 1) % 3]}); + vertTable.insert(vec1i{triInds[d]}); + edgeTable.insert(vec2i{triInds[d], triInds[(d + 1) % 3]}); } - }); - auto svcnt = vertTable.size(); - points.resize(svcnt); - pointAreas.resize(svcnt, 0.f); - copy(mem_host, points.data(), vertTable._activeKeys.data(), - sizeof(int) * svcnt); - fmt::print("{} surface verts\n", svcnt); - - // surface edges - Vector surfEdgeCnt{1}; - surfEdgeCnt.setVal(0); - auto dupEdgeCnt = edgeTable.size(); - std::vector dupEdgeToSurfEdge(dupEdgeCnt, -1); - lines.resize(dupEdgeCnt); - ompExec(range(dupEdgeCnt), [edgeTable = proxy(edgeTable), &lines, - surfEdgeCnt = surfEdgeCnt.data(), - &dupEdgeToSurfEdge](int edgeNo) mutable { - using vec2i = zs::vec; - vec2i edge = edgeTable._activeKeys[edgeNo]; - using table_t = RM_CVREF_T(edgeTable); - if (auto eno = edgeTable.query(vec2i{edge[1], edge[0]}); - eno == table_t::sentinel_v || // opposite edge not exists - (eno != table_t::sentinel_v && - edge[0] < edge[1])) { // opposite edge does exist - auto no = atomic_add(exec_omp, surfEdgeCnt, 1); - lines[no] = zeno::vec2i{edge[0], edge[1]}; - dupEdgeToSurfEdge[edgeNo] = no; - } - }); - auto secnt = surfEdgeCnt.getVal(); - lines.resize(secnt); - lineAreas.resize(secnt, 0.f); - fmt::print("{} surface edges\n", secnt); - - ompExec(tris, - [&, vertTable = proxy(vertTable), - edgeTable = proxy(edgeTable)](vec3i triInds) mutable { + }); + auto svcnt = vertTable.size(); + points.resize(svcnt); + pointAreas.resize(svcnt, 0.f); + copy(mem_host, points.data(), vertTable._activeKeys.data(), + sizeof(int) * svcnt); + fmt::print("{} surface verts\n", svcnt); + + // surface edges + Vector surfEdgeCnt{1}; + surfEdgeCnt.setVal(0); + auto dupEdgeCnt = edgeTable.size(); + std::vector dupEdgeToSurfEdge(dupEdgeCnt, -1); + lines.resize(dupEdgeCnt); + ompExec( + range(dupEdgeCnt), [edgeTable = proxy(edgeTable), &lines, + surfEdgeCnt = surfEdgeCnt.data(), + &dupEdgeToSurfEdge](int edgeNo) mutable { + using vec2i = zs::vec; + vec2i edge = edgeTable._activeKeys[edgeNo]; + using table_t = RM_CVREF_T(edgeTable); + if (auto eno = edgeTable.query(vec2i{edge[1], edge[0]}); + eno == + table_t::sentinel_v || // opposite edge not exists + (eno != table_t::sentinel_v && + edge[0] < edge[1])) { // opposite edge does exist + auto no = atomic_add(exec_omp, surfEdgeCnt, 1); + lines[no] = zeno::vec2i{edge[0], edge[1]}; + dupEdgeToSurfEdge[edgeNo] = no; + } + }); + auto secnt = surfEdgeCnt.getVal(); + lines.resize(secnt); + lineAreas.resize(secnt, 0.f); + fmt::print("{} surface edges\n", secnt); + + ompExec(tris, [&, vertTable = proxy(vertTable), + edgeTable = + proxy(edgeTable)](vec3i triInds) mutable { using vec3 = zs::vec; using vec1i = zs::vec; using vec2i = zs::vec; for (int d = 0; d != 3; ++d) { - auto p0 = vec3::from_array(pos[triInds[0]]); - auto p1 = vec3::from_array(pos[triInds[1]]); - auto p2 = vec3::from_array(pos[triInds[2]]); - float area = (p1 - p0).cross(p2 - p0).norm() / 2; - // surface vert - using vtable_t = RM_CVREF_T(vertTable); - auto vno = vertTable.query(vec1i{triInds[d]}); - atomic_add(exec_omp, &pointAreas[vno], area / 3); - // surface edge - using etable_t = RM_CVREF_T(edgeTable); + auto p0 = vec3::from_array(pos[triInds[0]]); + auto p1 = vec3::from_array(pos[triInds[1]]); + auto p2 = vec3::from_array(pos[triInds[2]]); + float area = (p1 - p0).cross(p2 - p0).norm() / 2; + // surface vert + using vtable_t = RM_CVREF_T(vertTable); + auto vno = vertTable.query(vec1i{triInds[d]}); + atomic_add(exec_omp, &pointAreas[vno], area / 3); + // surface edge + using etable_t = RM_CVREF_T(edgeTable); #if 0 auto eno = edgeTable.query(vec2i{triInds[d], triInds[(d + 1) % 3]}); if (eno == etable_t::sentinel_v) @@ -212,8 +215,8 @@ struct ExtractMeshSurface : INode { atomic_add(exec_omp, &lineAreas[seNo], area / 3); #endif } - }); - } + }); + } #else { /// surfaces @@ -379,7 +382,7 @@ struct ToBoundaryPrimitive : INode { fmt::print("checking tri! {}-th tri<{}, {}, {}>\n", ii, tri[0], tri[1], tri[2]); } #endif -#if 1 +#if 0 zs::HashTable surfEdgeTable{3 * tris.size(), memsrc_e::host, -1}; surfEdgeTable.resize(ompExec, 3 * tris.size()); @@ -957,43 +960,43 @@ struct ToZSSurfaceMesh : INode { atomic_add(zs::exec_omp, &pars("m", tri[d]), vmass); }); -#if 1 - zs::HashTable surfEdgeTable{0}; - surfEdgeTable.resize(ompExec, 3 * tris.size()); - surfEdgeTable.reset(ompExec, true); - - auto seTable = proxy(surfEdgeTable); - using table_t = RM_CVREF_T(seTable); - using vec3i = zs::vec; - using vec2i = zs::vec; - ompExec(range(tris.size()), [&](int ei) { - auto tri = tris[ei]; - seTable.insert(vec2i{tri[0], tri[1]}); - seTable.insert(vec2i{tri[1], tri[2]}); - seTable.insert(vec2i{tri[2], tri[0]}); - }); - Vector surfEdgeCnt{1, memsrc_e::host}; - surfEdgeCnt.setVal(0); - auto &surfEdges = (*zstris)[ZenoParticles::s_surfEdgeTag]; - surfEdges = typename ZenoParticles::particles_t({{ "inds", - 2 }}, - tris.size() * 3, - zs::memsrc_e::host); - ompExec(range(seTable.size()), - [&, edges = proxy({}, surfEdges), - cnt = proxy(surfEdgeCnt)](int i) mutable { - auto edgeInds = seTable._activeKeys[i]; - if (auto no = seTable.query(vec2i{edgeInds[1], edgeInds[0]}); - no == table_t::sentinel_v || - (no != table_t::sentinel_v && edgeInds[0] < edgeInds[1])) { - auto id = atomic_add(exec_omp, &cnt[0], 1); - edges("inds", 0, id) = reinterpret_bits(edgeInds[0]); - edges("inds", 1, id) = reinterpret_bits(edgeInds[1]); - } - }); - auto seCnt = surfEdgeCnt.getVal(); - surfEdges.resize(seCnt); - surfEdges = surfEdges.clone({zs::memsrc_e::device, 0}); +#if 0 + zs::HashTable surfEdgeTable{0}; + surfEdgeTable.resize(ompExec, 3 * tris.size()); + surfEdgeTable.reset(ompExec, true); + + auto seTable = proxy(surfEdgeTable); + using table_t = RM_CVREF_T(seTable); + using vec3i = zs::vec; + using vec2i = zs::vec; + ompExec(range(tris.size()), [&](int ei) { + auto tri = tris[ei]; + seTable.insert(vec2i{tri[0], tri[1]}); + seTable.insert(vec2i{tri[1], tri[2]}); + seTable.insert(vec2i{tri[2], tri[0]}); + }); + Vector surfEdgeCnt{1, memsrc_e::host}; + surfEdgeCnt.setVal(0); + auto &surfEdges = (*zstris)[ZenoParticles::s_surfEdgeTag]; + surfEdges = typename ZenoParticles::particles_t({{ "inds", + 2 }}, + tris.size() * 3, + zs::memsrc_e::host); + ompExec(range(seTable.size()), [&, edges = proxy({}, surfEdges), + cnt = proxy(surfEdgeCnt)]( + int i) mutable { + auto edgeInds = seTable._activeKeys[i]; + if (auto no = seTable.query(vec2i{edgeInds[1], edgeInds[0]}); + no == table_t::sentinel_v || + (no != table_t::sentinel_v && edgeInds[0] < edgeInds[1])) { + auto id = atomic_add(exec_omp, &cnt[0], 1); + edges("inds", 0, id) = reinterpret_bits(edgeInds[0]); + edges("inds", 1, id) = reinterpret_bits(edgeInds[1]); + } + }); + auto seCnt = surfEdgeCnt.getVal(); + surfEdges.resize(seCnt); + surfEdges = surfEdges.clone({zs::memsrc_e::device, 0}); #else auto comp = [](const auto &x, const auto &y) { return x[0] < y[0] ? 1 : (x[0] == y[0] && x[1] < y[1] ? 1 : 0); diff --git a/projects/CUDA/mpm/Generation.cu b/projects/CUDA/mpm/Generation.cu index ac8c0cd387..9f5dd75917 100644 --- a/projects/CUDA/mpm/Generation.cu +++ b/projects/CUDA/mpm/Generation.cu @@ -1401,7 +1401,7 @@ struct MakeZSLevelSet : INode { tmp.reset(zs::cuda_exec(), 0); ls->getLevelSet() = std::move(tmp); } else if (cateStr == "const_velocity") { - auto v = get_input("aux")->get(); + auto v = get_input2("aux"); ls->getLevelSet() = typename ZenoLevelSet::uniform_vel_ls_t{ zs::vec{v[0], v[1], v[2]}}; } else From d976b5254cdeecda923397ad293c33e4537e3d29 Mon Sep 17 00:00:00 2001 From: littlemine Date: Tue, 16 Aug 2022 13:02:42 +0800 Subject: [PATCH 07/10] minor fix fastflip --- projects/FastFLIP/nosys/WriteBgeo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/FastFLIP/nosys/WriteBgeo.cpp b/projects/FastFLIP/nosys/WriteBgeo.cpp index f332d222e8..bbb7c5f722 100644 --- a/projects/FastFLIP/nosys/WriteBgeo.cpp +++ b/projects/FastFLIP/nosys/WriteBgeo.cpp @@ -23,7 +23,7 @@ static void outputBgeo(std::string path, const std::vector &pos, _v[1] = vel[i][1]; _v[2] = vel[i][2]; } - printf("writing particles to %s\n", path); + printf("writing particles to %s\n", path.c_str()); Partio::write(path.c_str(), *parts, /*force compresse*/ false); parts->release(); } From 2a3d4bd5a1d54a63428746ef96ed17dc7d40be8e Mon Sep 17 00:00:00 2001 From: Aaron <910854285@qq.com> Date: Tue, 16 Aug 2022 16:24:30 +0800 Subject: [PATCH 08/10] fbx subsurface --- projects/FBX/Definition.h | 10 ++++++---- projects/FBX/assimp | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/projects/FBX/Definition.h b/projects/FBX/Definition.h index 5c4f9240c7..4f9ccb9e21 100644 --- a/projects/FBX/Definition.h +++ b/projects/FBX/Definition.h @@ -310,25 +310,27 @@ struct SMaterial : zeno::IObjectClone{ // FIXME (aiTextureType_BASE_COLOR 12 basecolor `aiStandardSurface`) // or (aiTextureType_DIFFUSE 1 diffuse `lambert`) // aiTextureType_NORMALS or aiTextureType_NORMAL_CAMERA + // TODO trick - We use some unused tex properties to set some tex + // val.emplace("basecolor", SMaterialProp{0, false, aiColor4D(), {aiTextureType_BASE_COLOR, aiTextureType_DIFFUSE}, {"$ai.base", "$clr.diffuse"}}); // texOk val.emplace("metallic", SMaterialProp{1, false, aiColor4D(), {aiTextureType_METALNESS}, {"$ai.metalness"}}); // texOk val.emplace("roughness", SMaterialProp{2, false, aiColor4D(), {aiTextureType_DIFFUSE_ROUGHNESS}, {"$ai.specularRoughness", "$ai.diffuseRoughness"}}); val.emplace("specular", SMaterialProp{3, false, aiColor4D(), {aiTextureType_SPECULAR}, {"$ai.specular", "$clr.specular"}}); - val.emplace("subsurface", SMaterialProp{4, true, aiColor4D(), {aiTextureType_NONE}, {"$ai.subsurface"}}); + val.emplace("subsurface", SMaterialProp{4, false, aiColor4D(), {aiTextureType_NONE}, {"$ai.subsurfaceFactor"}}); val.emplace("thinkness", SMaterialProp{5, true, aiColor4D(), {aiTextureType_NONE}, {"", /*"$ai.thinFilmThickness"*/}}); val.emplace("sssParam", SMaterialProp{6, false, aiColor4D(), {aiTextureType_NONE}, {""}}); - val.emplace("sssColor", SMaterialProp{7, false, aiColor4D(), {aiTextureType_NONE}, {""}}); + val.emplace("sssColor", SMaterialProp{7, false, aiColor4D(), {aiTextureType_REFLECTION}, {"$ai.subsurface"}}); val.emplace("foliage", SMaterialProp{8, false, aiColor4D(), {aiTextureType_NONE}, {""}}); val.emplace("skin", SMaterialProp{9, false, aiColor4D(), {aiTextureType_NONE}, {""}}); val.emplace("curvature", SMaterialProp{10, false, aiColor4D(), {aiTextureType_NONE}, {""}}); val.emplace("specularTint", SMaterialProp{11, false, aiColor4D(), {aiTextureType_NONE}, {""}}); val.emplace("anisotropic", SMaterialProp{12, false, aiColor4D(), {aiTextureType_NONE}, {""}}); - val.emplace("sheen", SMaterialProp{13, true, aiColor4D(), {aiTextureType_SHININESS}, {"$ai.sheen"}}); + val.emplace("sheen", SMaterialProp{13, false, aiColor4D(), {aiTextureType_SHININESS}, {"$ai.sheen"}}); val.emplace("sheenTint", SMaterialProp{14, false, aiColor4D(), {aiTextureType_NONE}, {""}}); val.emplace("clearcoat", SMaterialProp{15, false, aiColor4D(), {aiTextureType_NONE}, {"$ai.coat"}}); val.emplace("clearcoatGloss", SMaterialProp{16, true, aiColor4D(), {aiTextureType_NONE}, {""}}); val.emplace("normal", SMaterialProp{17, false, aiColor4D(), {aiTextureType_NORMAL_CAMERA, aiTextureType_NORMALS}, {"",}}); // texOk - val.emplace("emission", SMaterialProp{18, true, aiColor4D(), {aiTextureType_EMISSIVE, aiTextureType_EMISSION_COLOR}, {"$ai.emission", "$clr.emissive"}}); + val.emplace("emission", SMaterialProp{18, false, aiColor4D(), {aiTextureType_EMISSIVE, aiTextureType_EMISSION_COLOR}, {"$ai.emission", "$clr.emissive"}}); val.emplace("exposure", SMaterialProp{19, false, aiColor4D(), {aiTextureType_NONE}, {""}}); val.emplace("ao", SMaterialProp{20, false, aiColor4D(), {aiTextureType_AMBIENT_OCCLUSION}, {""}}); val.emplace("toon", SMaterialProp{21, false, aiColor4D(), {aiTextureType_NONE}, {""}}); diff --git a/projects/FBX/assimp b/projects/FBX/assimp index 9d300700bd..95380f5515 160000 --- a/projects/FBX/assimp +++ b/projects/FBX/assimp @@ -1 +1 @@ -Subproject commit 9d300700bd812beb8b99e5a6a5c778eeddd49fa1 +Subproject commit 95380f55159328a14d16621b6198ca2d5bed07a4 From 28b53104ae76792da3c05b300953152daf4c4102 Mon Sep 17 00:00:00 2001 From: Aaron <910854285@qq.com> Date: Tue, 16 Aug 2022 16:57:20 +0800 Subject: [PATCH 09/10] update node ReadLightFromFile --- projects/FBX/ReadFBX.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/projects/FBX/ReadFBX.cpp b/projects/FBX/ReadFBX.cpp index 8defcd81a8..a3acf8929f 100644 --- a/projects/FBX/ReadFBX.cpp +++ b/projects/FBX/ReadFBX.cpp @@ -1024,42 +1024,51 @@ struct ReadLightFromFile : zeno::INode { auto sclList = std::make_shared(); auto colList = std::make_shared(); auto intList = std::make_shared(); + auto expList = std::make_shared(); std::ifstream infile(path); if (infile.is_open()) { std::string line; int num = 0; + int dl = 7; while (std::getline(infile, line)) { // using printf() in all tests for consistency std::string l = line.c_str(); printf("Light: Processing %s\n", l.c_str()); - if(num%6==0){ + if(num%dl==0){ LIGHT_STR_SPLIT_V3F //printf("Light: Pos %.2f %.2f %.2f\n", tmp[0], tmp[1], tmp[2]); posList->arr.push_back(no); } - if(num%6==1){ + if(num%dl==1){ LIGHT_STR_SPLIT_V3F //printf("Light: Rot %.2f %.2f %.2f\n", tmp[0], tmp[1], tmp[2]); rotList->arr.push_back(no); } - if(num%6==2){ + if(num%dl==2){ LIGHT_STR_SPLIT_V3F //printf("Light: Scl %.2f %.2f %.2f\n", tmp[0], tmp[1], tmp[2]); sclList->arr.push_back(no); } - if(num%6==3){ + if(num%dl==3){ LIGHT_STR_SPLIT_V3F //printf("Light: Col %.2f %.2f %.2f\n", tmp[0], tmp[1], tmp[2]); colList->arr.push_back(no); } - if(num%6==4){ + if(num%dl==4){ auto no = std::make_shared(); float tmp = (float)atof(l.c_str()); no->set(tmp); //printf("Light: Int %.2f\n", tmp); intList->arr.push_back(no); } + if(num%dl==5){ + auto no = std::make_shared(); + float tmp = (float)atof(l.c_str()); + no->set(tmp); + //printf("Light: Exp %.2f\n", tmp); + expList->arr.push_back(no); + } num++; } @@ -1071,6 +1080,7 @@ struct ReadLightFromFile : zeno::INode { set_output("sclList", std::move(sclList)); set_output("colList", std::move(colList)); set_output("intList", std::move(intList)); + set_output("expList", std::move(expList)); } }; ZENDEFNODE(ReadLightFromFile, @@ -1079,7 +1089,7 @@ ZENDEFNODE(ReadLightFromFile, {"readpath", "path"}, }, /* outputs: */ { - "posList", "rotList", "sclList", "colList", "intList" + "posList", "rotList", "sclList", "colList", "intList", "expList" }, /* params: */ { }, /* category: */ From 4d636b6219f827d45a6ebf4dc4a5a2c13eb328ee Mon Sep 17 00:00:00 2001 From: teachmain Date: Tue, 16 Aug 2022 20:08:54 +0800 Subject: [PATCH 10/10] update ssscolor --- zenovis/xinxinoptix/DeflMatShader.cu | 5 ++-- zenovis/xinxinoptix/DisneyBSDF.h | 23 +++++++--------- zenovis/xinxinoptix/PTKernel.cu | 36 ++++++++++++++----------- zenovis/xinxinoptix/TraceStuff.h | 1 + zenovis/xinxinoptix/optixPathTracer.cpp | 2 +- 5 files changed, 36 insertions(+), 31 deletions(-) diff --git a/zenovis/xinxinoptix/DeflMatShader.cu b/zenovis/xinxinoptix/DeflMatShader.cu index 8960f40805..30ad9753e2 100644 --- a/zenovis/xinxinoptix/DeflMatShader.cu +++ b/zenovis/xinxinoptix/DeflMatShader.cu @@ -449,7 +449,7 @@ extern "C" __global__ void __closesthit__radiance() { prd->countEmitted = true; //hit light, emit - float dist = length(P - optixGetWorldRayOrigin()); + float dist = length(P - optixGetWorldRayOrigin()) + 1e-5; float3 lv1 = v1-v0; float3 lv2 = v2-v0; float A = 0.5 * length(cross(lv1, lv2)); @@ -526,7 +526,7 @@ extern "C" __global__ void __closesthit__radiance() rPdf = 0.0f; fPdf = 0.0f; reflectance = vec3(0.0f); - flag == DisneyBSDF::scatterEvent; + flag = DisneyBSDF::scatterEvent; } pdf = fPdf; @@ -578,6 +578,7 @@ extern "C" __global__ void __closesthit__radiance() prd->origin = P; prd->direction = wi; prd->countEmitted = false; prd->attenuation *= reflectance; + prd->depth++; //if(flag==DisneyBSDF::transmissionEvent && ( !prd->is_inside)){ // return; //} diff --git a/zenovis/xinxinoptix/DisneyBSDF.h b/zenovis/xinxinoptix/DisneyBSDF.h index bdac54612e..42625542eb 100644 --- a/zenovis/xinxinoptix/DisneyBSDF.h +++ b/zenovis/xinxinoptix/DisneyBSDF.h @@ -51,10 +51,11 @@ namespace DisneyBSDF{ static __inline__ __device__ vec3 CalculateExtinction(vec3 apparantColor, float scatterDistance) { - vec3 a = apparantColor; - vec3 s = vec3(1.9f) - a + 3.5f * (a - vec3(0.8f)) * (a - vec3(0.8f)); + //vec3 a = apparantColor; + //vec3 s = vec3(1.9f) - a + 3.5f * (a - vec3(0.8f)) * (a - vec3(0.8f)); - return vec3(1.0f / (s*scatterDistance)); + //return vec3(1.0f / (a*scatterDistance)); + return 1/apparantColor; } static __inline__ __device__ @@ -820,7 +821,7 @@ namespace DisneyBSDF{ float pLobe = 0.0f; float p = rnd(seed); - if( p<= pSpecular){ + if( p<= pSpecular){ success = SampleDisneyBRDF( seed, baseColor, @@ -840,19 +841,15 @@ namespace DisneyBSDF{ rPdf); pLobe = pSpecular; - }else if(pClearcoat >0.001f&& p <= (pSpecular + pClearcoat)){ + }else if(pClearcoat >0.001f && p <= (pSpecular + pClearcoat)){ success = SampleDisneyClearCoat(seed, clearCoat, clearcoatGloss, T, B, N, wo, wi, reflectance, fPdf, rPdf); pLobe = pClearcoat; - }else if( p <= (pSpecular + pClearcoat + pDiffuse)){ - success = SampleDisneyDiffuse(seed, baseColor, transmiianceColor, scatterDistance, sheen, sheenTint, roughness, flatness, subsurface, thin, wo, T, B, N, wi, fPdf, rPdf, reflectance, flag, phaseFuncion, extinction,is_inside); - pLobe = pDiffuse; - }else if( pSpecTrans > 0.0f){ + }else if(pSpecTrans > 0.001f && p <= (pSpecular + pClearcoat + pSpecTrans)){ success = SampleDisneySpecTransmission(seed, ior, roughness, anisotropic, baseColor, transmiianceColor, scatterDistance, wo, wi, rPdf, fPdf, reflectance, flag, phaseFuncion, extinction, thin, is_inside, T, B, N); pLobe = pSpecTrans; - }else{ - reflectance = vec3(100000.0f,0.0f,0.0f); - fPdf = 0.000000001f; - rPdf = 0.000000001f; + }else { + success = SampleDisneyDiffuse(seed, baseColor, transmiianceColor, scatterDistance, sheen, sheenTint, roughness, flatness, subsurface, thin, wo, T, B, N, wi, fPdf, rPdf, reflectance, flag, phaseFuncion, extinction,is_inside); + pLobe = pDiffuse; } //reflectance = clamp(reflectance, vec3(0,0,0), vec3(1,1,1)); if(pLobe > 0.0f){ diff --git a/zenovis/xinxinoptix/PTKernel.cu b/zenovis/xinxinoptix/PTKernel.cu index f95ee74f1c..cbeab14881 100644 --- a/zenovis/xinxinoptix/PTKernel.cu +++ b/zenovis/xinxinoptix/PTKernel.cu @@ -55,7 +55,8 @@ extern "C" __global__ void __raygen__rg() prd.is_inside = false; prd.maxDistance = 1e16f; prd.medium = DisneyBSDF::PhaseFunctions::vacuum; - int depth = 0; + + prd.depth = 0; for( ;; ) { traceRadiance( @@ -67,19 +68,20 @@ extern "C" __global__ void __raygen__rg() &prd ); //result += prd.emitted; - if(prd.countEmitted==false || depth>0) + if(prd.countEmitted==false || prd.depth>0) result += prd.radiance * prd.attenuation2/(prd.prob2); - if(prd.countEmitted==true && depth>0){ + if(prd.countEmitted==true && prd.depth>0){ prd.done = true; } - if( prd.done ){ + if( prd.done ){ + break; } - if(depth>5){ - float RRprob = clamp(length(prd.attenuation)/1.732f,0.01f,0.99f); - if(rnd(prd.seed) > RRprob || depth>15){ - prd.attenuation = make_float3(0.0f); - break; + if(prd.depth>4){ + //float RRprob = clamp(length(prd.attenuation)/1.732f,0.01f,0.9f); + float RRprob = 0.9; + if(rnd(prd.seed) > RRprob || prd.depth>8){ + prd.done=true; } prd.attenuation = prd.attenuation / RRprob; } @@ -87,11 +89,11 @@ extern "C" __global__ void __raygen__rg() prd.passed = true; ray_origin = prd.origin; ray_direction = prd.direction; - if(prd.passed == false){ - ++depth; - }else{ - prd.passed = false; - } + // if(prd.passed == false) + // ++depth; + //}else{ + //prd.passed = false; + //} } } while( --i ); @@ -119,6 +121,9 @@ extern "C" __global__ void __miss__radiance() { MissData* rt_data = reinterpret_cast( optixGetSbtDataPointer() ); RadiancePRD* prd = getPRD(); + + prd->passed = false; + prd->countEmitted = false; if(prd->medium != DisneyBSDF::isotropic){ prd->radiance = make_float3( rt_data->bg_color ); @@ -130,8 +135,9 @@ extern "C" __global__ void __miss__radiance() float tmpPDF; prd->maxDistance = DisneyBSDF::SampleDistance(prd->seed,prd->extinction,tmpPDF); prd->scatterPDF= tmpPDF; + prd->depth++; - if(length(prd->attenuation)<1e-5f){ + if(length(prd->attenuation)<1e-4f){ prd->done = true; } diff --git a/zenovis/xinxinoptix/TraceStuff.h b/zenovis/xinxinoptix/TraceStuff.h index 47f2e66b22..3e1c3d17bc 100644 --- a/zenovis/xinxinoptix/TraceStuff.h +++ b/zenovis/xinxinoptix/TraceStuff.h @@ -50,6 +50,7 @@ struct RadiancePRD vec3 extinction; float scatterPDF; float maxDistance; + int depth; }; diff --git a/zenovis/xinxinoptix/optixPathTracer.cpp b/zenovis/xinxinoptix/optixPathTracer.cpp index a55d91fce1..cbed5cd770 100644 --- a/zenovis/xinxinoptix/optixPathTracer.cpp +++ b/zenovis/xinxinoptix/optixPathTracer.cpp @@ -1577,7 +1577,7 @@ void optixrender(int fbo, int samples) { if (!output_buffer_o) throw sutil::Exception("no output_buffer_o"); if (!gl_display_o) throw sutil::Exception("no gl_display_o"); updateState( *output_buffer_o, state.params ); - const int max_samples_once = 16; + const int max_samples_once = 1; //std::cout<<"samples"<