This snippet covers producing the following effect as originally discussed in this forum thread:

When an object (e.g. a character) is behind a certain other object (e.g. a wall or the roof), the occluded object will appear visible, but have a different appearance than it would have had when being visible in the normal way. This is often used in games such as Torchlight - when your character is behind a wall from the point of view of the camera, he or she will be displayed as a faint blue silhouette.

screenshots

The first image shows the scene as it looked before applying the effect: Half of the Ogre head is occluded by the black plane and therefore invisible from the camera's point of view. On the second screenhot, the below listed material has been applied to the Ogre skin. On the third and last shot, you see a modified version of the listed material, to better understand the previous screenshots since it offers more "3D feeling".
ghosted_entity_snippet_no_effect.jpg ghosted_entity_snippet_effect_applied.jpg ghosted_entity_snippet_effect_applied_modif.jpg

material script

material behindmat
{
   technique
   {
      pass behind
      {
         ambient 1 0 0
         diffuse 0 0 0
         depth_write off
         depth_check off
      }

      pass infront
      {
         ambient 0 0 1
         diffuse 0 0 0
         depth_write on
         depth_check on
      }
   }
}


The {LEX()}material{LEX} {LEX()}pass{LEX} "infront" will define the appearence of the normal visible parts of the object. The pass "behind" will be used for parts of the object that are occluded.

Then in your code, set the ghoster / occluder entity (e.g. wall or roof) to "RENDER_QUEUE_WORLD_GEOMETRY_1" and the ghosted / occluded entity (character, etc.) to "RENDER_QUEUE_6":

pRoofEnt->setRenderQueueGroup(RENDER_QUEUE_WORLD_GEOMETRY_1);
pCharacterEnt->setRenderQueueGroup(RENDER_QUEUE_6);


There is no need to implement RenderTargetListener or have the entity in dual queues or anything that complicated.