Commit 95909765 authored by Carson Brownlee's avatar Carson Brownlee Committed by David E. DeMarle

removing depth buffer realloc. Adding back conditional composite

parent 00e4278a
Pipeline #24799 passed with stage
......@@ -178,6 +178,8 @@ void vtkOSPRayPass::RenderInternal(const vtkRenderState *s)
int viewportWidth, viewportHeight;
ren->GetTiledSizeAndOrigin(&viewportWidth,&viewportHeight,
&viewportX,&viewportY);
vtkOSPRayRendererNode* oren= vtkOSPRayRendererNode::SafeDownCast
(this->SceneGraph->GetViewNodeFor(ren));
int layer = ren->GetLayer();
if (layer == 0)
{
......@@ -191,7 +193,7 @@ void vtkOSPRayPass::RenderInternal(const vtkRenderState *s)
viewportX+viewportWidth-1,
viewportY+viewportHeight-1,
this->SceneGraph->GetBuffer(),
0, 1 );
0, vtkOSPRayRendererNode::GetCompositeOnGL(ren) );
}
else
{
......@@ -205,8 +207,6 @@ void vtkOSPRayPass::RenderInternal(const vtkRenderState *s)
viewportX+viewportWidth-1,
viewportY+viewportHeight-1,
0);
vtkOSPRayRendererNode* oren= vtkOSPRayRendererNode::SafeDownCast
(this->SceneGraph->GetViewNodeFor(ren));
oren->WriteLayer(ontoRGBA, ontoZ, viewportWidth, viewportHeight, layer);
rwin->SetZbufferData(
viewportX, viewportY,
......@@ -218,7 +218,7 @@ void vtkOSPRayPass::RenderInternal(const vtkRenderState *s)
viewportX+viewportWidth-1,
viewportY+viewportHeight-1,
ontoRGBA,
0, 1 );
0, vtkOSPRayRendererNode::GetCompositeOnGL(ren) );
delete[] ontoZ;
delete[] ontoRGBA;
}
......
......@@ -511,6 +511,10 @@ void vtkOSPRayRendererNode::Render(bool prepass)
this->Buffer = new unsigned char[this->Size[0]*this->Size[1]*4];
delete[] this->ZBuffer;
this->ZBuffer = new float[this->Size[0]*this->Size[1]];
if (this->CompositeOnGL)
{
ODepthBuffer = new float[this->Size[0] * this->Size[1]];
}
}
else if (this->Accumulate)
{
......@@ -565,12 +569,10 @@ void vtkOSPRayRendererNode::Render(bool prepass)
cameraDir.z -= cameraPos[2];
cameraDir = ospray::opengl::normalize(cameraDir);
float *ospDepthBuffer=nullptr;
ospDepthBuffer = new float[viewportWidth * viewportHeight];
glDepthTex = ospray::opengl::getOSPDepthTextureFromOpenGLPerspective
(fovy, aspect, zNear, zFar,
(osp::vec3f&)cameraDir, (osp::vec3f&)cameraUp,
this->GetZBuffer(), ospDepthBuffer, viewportWidth, viewportHeight);
this->GetZBuffer(), ODepthBuffer, viewportWidth, viewportHeight);
ospSetObject(oRenderer, "maxDepthTexture", glDepthTex);
}
......
......@@ -140,6 +140,7 @@ protected:
bool ComputeDepth;
bool Accumulate;
bool CompositeOnGL;
float* ODepthBuffer;
private:
vtkOSPRayRendererNode(const vtkOSPRayRendererNode&) VTK_DELETE_FUNCTION;
......
......@@ -57,7 +57,6 @@ void vtkOSPRayVolumeMapper::Init()
this->InternalRenderer = vtkRenderer::New();
vtkOSPRayRendererNode::SetCompositeOnGL(1, this->InternalRenderer);
this->InternalRenderer->SetLayer(0); //TODO: hacked in for now
this->InternalRenderer->SetErase(0);
this->Initialized = true;
}
......@@ -84,6 +83,8 @@ void vtkOSPRayVolumeMapper::Render(vtkRenderer *ren, vtkVolume *vol)
this->InternalRenderer->SetPass(this->InternalOSPRayPass);
this->InternalRenderer->Render();
this->InternalRenderer->SetPass(0);
vtkOSPRayRendererNode::SetCompositeOnGL(ren->GetNumberOfPropsRendered() > 0, this->InternalRenderer);
this->InternalRenderer->SetErase(ren->GetNumberOfPropsRendered() < 1);
this->InternalRenderer->RemoveVolume(vol); //prevent a mem leak
}
......
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