@@ -207,8 +207,11 @@ void Ogre2DepthGaussianNoisePass::CreateRenderPass()
207
207
nodeDef->setNumTargetPass (1 );
208
208
Ogre::CompositorTargetDef *inputTargetDef =
209
209
nodeDef->addTargetPass (" rt_output" );
210
- inputTargetDef->setNumPasses (1 );
210
+ inputTargetDef->setNumPasses (2 );
211
211
{
212
+ // clear pass
213
+ inputTargetDef->addPass (Ogre::PASS_CLEAR);
214
+
212
215
// quad pass
213
216
Ogre::CompositorPassQuadDef *passQuad =
214
217
static_cast <Ogre::CompositorPassQuadDef *>(
@@ -467,11 +470,14 @@ void Ogre2DepthCamera::CreateDepthTexture()
467
470
// }
468
471
// target rt0
469
472
// {
473
+ // pass clear
474
+ // {
475
+ // }
470
476
// pass render_quad
471
477
// {
472
478
// material DepthCamera // Use copy instead of original
473
- // input 0 depthTexture0
474
- // input 1 colorTexture0
479
+ // input 0 depthTexture
480
+ // input 1 colorTexture
475
481
// quad_normals camera_far_corners_view_space
476
482
// }
477
483
// }
@@ -586,8 +592,15 @@ void Ogre2DepthCamera::CreateDepthTexture()
586
592
// rt0 target - converts depth to xyz
587
593
Ogre::CompositorTargetDef *inTargetDef =
588
594
baseNodeDef->addTargetPass (" rt0" );
589
- inTargetDef->setNumPasses (1 );
595
+ inTargetDef->setNumPasses (2 );
590
596
{
597
+ // clear pass
598
+ Ogre::CompositorPassClearDef *passClear =
599
+ static_cast <Ogre::CompositorPassClearDef *>(
600
+ inTargetDef->addPass (Ogre::PASS_CLEAR));
601
+ passClear->mColourValue = Ogre::ColourValue (this ->FarClipPlane (),
602
+ this ->FarClipPlane (), this ->FarClipPlane ());
603
+
591
604
// quad pass
592
605
Ogre::CompositorPassQuadDef *passQuad =
593
606
static_cast <Ogre::CompositorPassQuadDef *>(
@@ -613,6 +626,9 @@ void Ogre2DepthCamera::CreateDepthTexture()
613
626
//
614
627
// target rt_output
615
628
// {
629
+ // pass clear
630
+ // {
631
+ // }
616
632
// pass render_quad
617
633
// {
618
634
// material DepthCameraFinal // Use copy instead of original
@@ -636,8 +652,15 @@ void Ogre2DepthCamera::CreateDepthTexture()
636
652
// rt_output target - converts depth to xyz
637
653
Ogre::CompositorTargetDef *outputTargetDef =
638
654
finalNodeDef->addTargetPass (" rt_output" );
639
- outputTargetDef->setNumPasses (1 );
655
+ outputTargetDef->setNumPasses (2 );
640
656
{
657
+ // clear pass
658
+ Ogre::CompositorPassClearDef *passClear =
659
+ static_cast <Ogre::CompositorPassClearDef *>(
660
+ outputTargetDef->addPass (Ogre::PASS_CLEAR));
661
+ passClear->mColourValue = Ogre::ColourValue (this ->FarClipPlane (),
662
+ this ->FarClipPlane (), this ->FarClipPlane ());
663
+
641
664
// quad pass
642
665
Ogre::CompositorPassQuadDef *passQuad =
643
666
static_cast <Ogre::CompositorPassQuadDef *>(
@@ -739,7 +762,7 @@ void Ogre2DepthCamera::PostRender()
739
762
740
763
// blit data from gpu to cpu
741
764
auto rt = this ->dataPtr ->ogreDepthTexture ->getBuffer ()->getRenderTarget ();
742
- rt->copyContentsToMemory (dstBox, Ogre::RenderTarget::FB_FRONT );
765
+ rt->copyContentsToMemory (dstBox, Ogre::RenderTarget::FB_AUTO );
743
766
744
767
if (!this ->dataPtr ->depthImage )
745
768
{
0 commit comments