[2.3] Rendering an object above the rest of the scene Topic is solved

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
crjc
Gnoblar
Posts: 14
Joined: Sat Oct 10, 2020 10:19 pm

[2.3] Rendering an object above the rest of the scene

Post by crjc »

Hi - just looking for some general directions on how we can render an object 'on top of' the rest of the scene with Ogre 2.3.

Any suggestions would be appreciated, thanks.
User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 449
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 156

Re: [2.3] Rendering an object above the rest of the scene

Post by sercero »

Hello,

Check out this forum post:
viewtopic.php?t=91735

What you are interested in are Render Queues, search the forum for that term and 2.1.

Best of luck.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.3] Rendering an object above the rest of the scene

Post by dark_sylinc »

I suspect what you want is like FPS games where the hands (and gun) of the character are always drawn on top of everything; and they never go through any wall.

The same with airplane games where the player's plane is drawn on top of everything, and it never really goes through any other geometry, even if physically it is intersecting with something.

If that's the case, then what you want is a combination of setRenderQueueGroup with a bit of compositor setup.

First call MovableObject::setRenderQueueGroup with a large number (make sure to set a valid v2 or v1 render queue group):

Code: Select all

myItem->setRenderQueueGroup( 220 );
Then in the Compositor, you need to clear the depth buffer before rendering RQ 220, so that it truly renders on top of everything:

Code: Select all

target output_rtt
{
	pass render_scene
	{
		load
		{
			all				clear
			clear_colour	0.2 0.4 0.6 1
		}
		store
		{
			colour	store_or_resolve
			depth	dont_care
			stencil	dont_care
		}
		overlays	off
		shadows		PbsMaterialsShadowNode
		
		rq_first	0
		rq_last		220
	}
	
	pass render_scene
	{
		load
		{
			colour	load
			// Clear ONLY depth & stencil
			depth	clear
			stencil	clear
		}
		store
		{
			colour	store_or_resolve
			depth	dont_care
			stencil	dont_care
		}
		overlays	on
		// For performance reasons the keyword 'reuse' forces Ogre
		// to reuse existing shadow maps. I'm not sure if this will
		// produce proper shadows (watch out) but if it looks correct
		// then you'll save a lot of performance (otherwise Ogre
		// may recalculate the shadows and that gets expensive)
		shadows		PbsMaterialsShadowNode reuse
		
		rq_first	220
		rq_last		225
	}
}
Post Reply