Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
iaomw committed Jun 3, 2024
1 parent 56ac178 commit 946a08f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
4 changes: 2 additions & 2 deletions ui/zenoedit/viewport/optixviewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,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
1 change: 1 addition & 0 deletions zenovis/src/ObjectsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ bool ObjectsManager::load_objects(std::map<std::string, std::shared_ptr<zeno::IO

void ObjectsManager::clear_objects() {
objects.clear();
lightObjects.clear();
}

std::optional<zeno::IObject* > ObjectsManager::get(std::string nid) {
Expand Down
9 changes: 3 additions & 6 deletions zenovis/xinxinoptix/OptiXStuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,7 @@ inline void calc_sky_cdf_map(int nx, int ny, int nc, std::function<float(uint32_
sky_pdf.assign(nx*ny, 0);
sky_start.resize(nx*ny);
sky_start.assign(nx*ny, 0);
std::vector<double> skypdf(nx*ny);
skypdf.assign(nx*ny,0);

for(int jj=0; jj<ny;jj++)
{
for(int ii=0;ii<nx;ii++)
Expand All @@ -672,21 +671,19 @@ inline void calc_sky_cdf_map(int nx, int ny, int nc, std::function<float(uint32_
size_t idx = jj*nx + ii;
float illum = 0.0f;
auto color = zeno::vec3f(look(idx2+0), look(idx2+1), look(idx2+2));
illum = zeno::dot(color, zeno::vec3f(0.33333333f,0.33333333f, 0.33333333f));
illum = zeno::dot(color, zeno::vec3f(0.2722287, 0.6740818, 0.0536895));
//illum = illum > 0.5? illum : 0.0f;
illum = abs(illum) * sinf(3.1415926f*((float)jj + 0.5f)/(float)ny);

sky_cdf[idx] += illum + (idx>0? sky_cdf[idx-1]:0);
skypdf[idx] = illum;
}
}
float total_illum = sky_cdf[sky_cdf.size()-1];
sky_avg = total_illum / ((float)nx * (float)ny);
for(int ii=0;ii<sky_cdf.size();ii++)
{
sky_cdf[ii] /= total_illum;
skypdf[ii] = skypdf[ii] * (double)nx * (double)ny / (double)total_illum;
sky_pdf[ii] = skypdf[ii];

if(ii>0)
{
if(sky_cdf[ii]>sky_cdf[ii-1])
Expand Down
11 changes: 3 additions & 8 deletions zenovis/xinxinoptix/optixPathTracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2170,9 +2170,7 @@ void updateDistantLights(std::vector<zeno::DistantLightData>& dldl)
c /= power;
}

state.dlights.list = dldl;
state.dlights.cdf = cdf;

state.dlights = DistantLightList {dldl, cdf};
state.params.dlights_ptr = (void*)state.dlights.upload();
}

Expand Down Expand Up @@ -2761,18 +2759,15 @@ OptixUtil::_compile_group.wait();
state.params.envavg = tex->average;

CUDA_CHECK( cudaMalloc( reinterpret_cast<void**>( &state.sky_cdf_p.reset() ),
sizeof(float2)*tex->cdf.size() ) );
sizeof(float)*tex->cdf.size() ) );
CUDA_CHECK( cudaMalloc( reinterpret_cast<void**>( &state.sky_start.reset() ),
sizeof(int)*tex->start.size() ) );

cudaMemcpy(reinterpret_cast<char *>((CUdeviceptr)state.sky_cdf_p),
tex->cdf.data(),
sizeof(float)*tex->cdf.size(),
cudaMemcpyHostToDevice);
cudaMemcpy(reinterpret_cast<char *>((CUdeviceptr)state.sky_cdf_p) + sizeof(float)*tex->cdf.size(),
tex->pdf.data(),
sizeof(float)*tex->pdf.size(),
cudaMemcpyHostToDevice);

cudaMemcpy(reinterpret_cast<char *>((CUdeviceptr)state.sky_start),
tex->start.data(),
sizeof(int)*tex->start.size(),
Expand Down

0 comments on commit 946a08f

Please sign in to comment.