Commit 8d2f8d45 authored by Carson Brownlee's avatar Carson Brownlee
Browse files

removing dummy instance from renderer

parent c2654cdd
......@@ -451,7 +451,6 @@ vtkOSPRayRendererNode::~vtkOSPRayRendererNode()
if (this->Internal->Backend != nullptr)
{
RTW::Backend* backend = this->Internal->Backend;
ospRelease(this->ODummyInstanceData);
ospRelease(this->OWorld);
ospRelease(this->ORenderer);
ospRelease(this->OFrameBuffer);
......@@ -1227,35 +1226,6 @@ void vtkOSPRayRendererNode::Render(bool prepass)
{
if (this->Lights.size())
{
auto data = ospNewSharedData1D(this->Lights.data(), OSP_LIGHT, this->Lights.size());
ospCommit(data);
ospSetObject(oWorld, "light", data);
ospRelease(data);
}
auto instanceData =
ospNewCopyData1D(this->Instances.size(), OSP_INSTANCE, this->Instances.data());
ospCommit(instanceData);
ospSetObject(oWorld, "instance", instanceData);
ospRelease(instanceData);
this->OInstanceData = instanceData;
}
else
{
// ospray crashes with empty scene, create dummy instance
if (!this->ODummyInstanceData)
{
OSPGroup group = ospNewGroup();
auto instance = ospNewInstance(group);
ospCommit(group);
ospCommit(instance);
this->ODummyInstanceData = ospNewCopyData1D(1, OSP_INSTANCE, &instance);
ospCommit(this->ODummyInstanceData);
ospSetObject(oWorld, "instance", this->ODummyInstanceData);
}
else
{
ospSetObject(oWorld, "instance", this->ODummyInstanceData);
}
}
ospCommit(oWorld);
......@@ -1476,8 +1446,8 @@ void vtkOSPRayRendererNode::Render(bool prepass)
cameraDir.z -= cameraPos[2];
cameraDir = ospray::opengl::normalize(cameraDir);
OSPTexture glDepthTex = ospray::opengl::getOSPDepthTextureFromOpenGLPerspective(fovy, aspect,
zNear, zFar, (osp::vec3f&)cameraDir, (osp::vec3f&)cameraUp, this->GetZBuffer(),
OSPTexture glDepthTex = ospray::opengl::getOSPDepthTextureFromOpenGLPerspective(fovy,
aspect, zNear, zFar, (osp::vec3f&)cameraDir, (osp::vec3f&)cameraUp, this->GetZBuffer(),
this->ODepthBuffer.data(), viewportWidth, viewportHeight, this->Internal->Backend);
ospSetObject(oRenderer, "map_maxDepth", glDepthTex);
......@@ -1597,10 +1567,10 @@ void vtkOSPRayRendererNode::Render(bool prepass)
}
}
}
}
}
void vtkOSPRayRendererNode::Denoise()
{
void vtkOSPRayRendererNode::Denoise()
{
#ifdef VTKOSPRAY_ENABLE_DENOISER
RTW::Backend* backend = this->Internal->Backend;
this->DenoisedBuffer = this->ColorBuffer;
......@@ -1609,11 +1579,11 @@ void vtkOSPRayRendererNode::Denoise()
this->DenoiserFilter.setImage("color", (void*)this->ColorBuffer.data(), oidn::Format::Float3,
this->ImageX, this->ImageY, 0, sizeof(osp::vec4f));
this->DenoiserFilter.setImage("normal", (void*)this->NormalBuffer.data(), oidn::Format::Float3,
this->ImageX, this->ImageY, 0, sizeof(osp::vec3f));
this->DenoiserFilter.setImage("normal", (void*)this->NormalBuffer.data(),
oidn::Format::Float3, this->ImageX, this->ImageY, 0, sizeof(osp::vec3f));
this->DenoiserFilter.setImage("albedo", (void*)this->AlbedoBuffer.data(), oidn::Format::Float3,
this->ImageX, this->ImageY, 0, sizeof(osp::vec3f));
this->DenoiserFilter.setImage("albedo", (void*)this->AlbedoBuffer.data(),
oidn::Format::Float3, this->ImageX, this->ImageY, 0, sizeof(osp::vec3f));
this->DenoiserFilter.setImage("output", (void*)this->DenoisedBuffer.data(),
oidn::Format::Float3, this->ImageX, this->ImageY, 0, sizeof(osp::vec4f));
......@@ -1640,12 +1610,12 @@ void vtkOSPRayRendererNode::Denoise()
// Carson: not sure we need two buffers
this->ColorBuffer = this->DenoisedBuffer;
#endif
}
}
//----------------------------------------------------------------------------
void vtkOSPRayRendererNode::WriteLayer(
//----------------------------------------------------------------------------
void vtkOSPRayRendererNode::WriteLayer(
unsigned char* buffer, float* Z, int buffx, int buffy, int layer)
{
{
if (layer == 0)
{
for (int j = 0; j < buffy && j < this->Size[1]; j++)
......@@ -1710,22 +1680,20 @@ void vtkOSPRayRendererNode::WriteLayer(
}
}
}
}
}
//------------------------------------------------------------------------------
vtkRenderer* vtkOSPRayRendererNode::GetRenderer()
{
//------------------------------------------------------------------------------
vtkRenderer* vtkOSPRayRendererNode::GetRenderer()
{
return vtkRenderer::SafeDownCast(this->GetRenderable());
}
}
//------------------------------------------------------------------------------
vtkOSPRayRendererNode* vtkOSPRayRendererNode::GetRendererNode(vtkViewNode* self)
{
return static_cast<vtkOSPRayRendererNode*>(self->GetFirstAncestorOfType("vtkOSPRayRendererNode"));
}
//------------------------------------------------------------------------------
vtkOSPRayRendererNode* vtkOSPRayRendererNode::GetRendererNode(vtkViewNode * self)
{
return static_cast<vtkOSPRayRendererNode*>(
self->GetFirstAncestorOfType("vtkOSPRayRendererNode"));
}
//------------------------------------------------------------------------------
RTW::Backend* vtkOSPRayRendererNode::GetBackend()
{
return this->Internal->Backend;
}
//------------------------------------------------------------------------------
RTW::Backend* vtkOSPRayRendererNode::GetBackend() { return this->Internal->Backend; }
......@@ -366,7 +366,6 @@ protected:
OSPData OLightArray{ nullptr };
OSPCamera OCamera{ nullptr };
OSPData OInstanceData{ nullptr };
OSPData ODummyInstanceData{ nullptr };
int ImageX, ImageY;
std::vector<OSPLight> Lights;
int NumActors;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment