Cartoon ink and background images

Hello, I’ve a problem. In my application I have a background image and a model that I would show with cartoon ink.

But, when I apply the cartoon ink (in the example, clicking the left mouse button), the image disappears. Surely I’m doing some mistakes. This is the code:

import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from direct.gui.OnscreenImage import OnscreenImage
from direct.filter.CommonFilters import CommonFilters

class World( DirectObject ):

  def __init__( self ):
    base.disableMouse()
    camera.setPos( 0, -20, 2 )
    loader.loadModel( 'teapot' ).reparentTo( render )
    self.setupBackground()
    self.accept( 'mouse1', self.cartoon )

  def setupBackground( self ):
    base.cam2dp.node().getDisplayRegion( 0 ).setSort( -20 )
    OnscreenImage( parent = base.cam2dp, image = 'limba.jpg' )
	  
  def cartoon( self ):
    CommonFilters( base.win, base.cam ).setCartoonInk( separation = 1 )
    self.ignore( 'mouse1' )
	  
w = World()
run()

and here the zip file of the previous example. How can I apply the cartoon ink and maintain the background image? Very thanks!

This is my simpler sample :

base.cam2dp.node().getDisplayRegion( 0 ).setSort( -20 )
OnscreenImage( parent = render2dp, image = 'maps/lilsmiley.rgba' ).setTransparency(1)
CommonFilters( base.win, base.cam ).setCartoonInk( separation = 1 )

The post-process quad covers your lower display regions, so what you see is that opaque quad.
Actually, that quad’s texture already has transparency (from the display region’s clear color), but the devs forgot to enable transparency.
So, insert this line to /direct/filter/FilterManager.py, in renderSceneInto :

        quad.setTransparency(1)

Thanks for the answer! Your solution works perfectly for the scenario described. But I’ve seen a side-effect in my larger application. If I add a particle effect:

import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from direct.gui.OnscreenImage import OnscreenImage
from direct.filter.CommonFilters import CommonFilters
from direct.particles.ParticleEffect import ParticleEffect

class World( DirectObject ):

  def __init__( self ):
    base.disableMouse()
    base.enableParticles()
    camera.setPos( 0, -20, 2 )
    loader.loadModel( 'teapot' ).reparentTo( render )
    self.setupBackground()
    self.accept( 'mouse1', self.cartoon )
    p = ParticleEffect()
    p.loadConfig( 'steam.ptf' )
    p.start( render )
    p.setPos( 2.8, -2, 2.4 )

  def setupBackground( self ):
    base.cam2dp.node().getDisplayRegion( 0 ).setSort( -20 )
    OnscreenImage( parent = base.cam2dp, image = 'limba.jpg' )
	  
  def cartoon( self ):
    CommonFilters( base.win, base.cam ).setCartoonInk( separation = 1 )
    self.ignore( 'mouse1' )
	  
w = World()
run()

the image remains, but now, when I apply the filter (clicking the left mouse button), the particle effect disappears (here the zip file of this second example). But, if I remove your fix, the particle behaves correctly (but obviously I have the previous problem).

So, how can I maintain both image and particle after the filter’s application? Very thanks!