Ogre-Next StereoRendering Issues

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


Post Reply
Lax
Hobgoblin
Posts: 593
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 50

Ogre-Next StereoRendering Issues

Post by Lax »

Hi,

I'm trying to get splitscreen working for my NOWA-Engine. I followed the documentation and the stereo Ogre example.

I created all compositor nodes just once and using 2x the same workspace name as in the tutorial.
I carefully set the execution mask and the viewport modifier mask.

I'm using a compositor with sky, hence I have 4 passes.

1 Pass: Clear (do not know if this is necessary, as in all other Ogre tutorial compositors, there is no clear pass)
2 Pass: Scene (before sky)
3 Pass: Quad (Sky)
4 Pass: Scene (MyGUI and overlays)

Now, if I call 2x addCompositor for the same workspace name with the corresponding rect:
1) 0 0 0.5 1
2) 0.5 0 0.5 1

My scene is devided into 4 parts instead into 2.
Also on the left side, the scene is not refreshed and there are artifacts.

The MyGUI is rendered correctly

See the attachted picture:
Image

Has anybody an idea, how to fix that?

Best Regards
Lax

Last edited by Lax on Tue Jun 11, 2024 8:33 am, edited 1 time in total.

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62

Lax
Hobgoblin
Posts: 593
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 50

Re: Ogre-Next StereoRendering Issues

Post by Lax »

Got It a bit better version working, at least no more 4 splits. But the left window just the sky is rendered (not visible somehow in the picture).
I have to different cameras for the same workspace.

Image

I have no idea, why the scene is no rendered on the left side.

I created a helper function, to get the flags correctly:

Code: Select all

if (true == this->useSplitScreen)
{
	if (pass->getType() == Ogre::CompositorPassType::PASS_CLEAR)
	{
		// Gets executed on the first eye
		pass->mExecutionMask = 0x01;
		// Don't be affected by the modifier, apply to the whole screen
		// Will be cleared once for all eyes
		pass->mViewportModifierMask = 0x00;
	}
	else if (pass->getType() == Ogre::CompositorPassType::PASS_SCENE && false == isOverlay)
	{
		// Gets executed in all eyes
		pass->mExecutionMask = 0xFF;
		// Be affected by the modifier, so we render just to a portion of the screen.
		// That means one part is rendered on first eye and the other on the second eye
		pass->mViewportModifierMask = 0xFF;
	}
	else if (pass->getType() == Ogre::CompositorPassType::PASS_QUAD)
	{
		// Gets executed in the second eye (rendered last)
		pass->mExecutionMask = WorkspaceModule::getInstance()->getCountCameras();
		// Don't be affected by the modifier, apply to the whole screen
		pass->mViewportModifierMask = 0x00;
	}
	else if (pass->getType() == Ogre::CompositorPassType::PASS_SCENE && true == isOverlay)
	{
		// Gets executed in the second eye (rendered last)
		pass->mExecutionMask = WorkspaceModule::getInstance()->getCountCameras();
		// Don't be affected by the modifier, apply to the whole screen
		pass->mViewportModifierMask = 0x00;
	}
	else if (pass->getType() == Ogre::CompositorPassType::PASS_CUSTOM)
	{
		// Gets executed in the second eye (rendered last)
		pass->mExecutionMask = WorkspaceModule::getInstance()->getCountCameras();
		// Don't be affected by the modifier, apply to the whole screen
		pass->mViewportModifierMask = 0x00;
	}
}

Does anybody have a more complex code example, on which I could take a look?

Best Regards
Lax

Last edited by Lax on Tue Jun 11, 2024 8:33 am, edited 1 time in total.

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62

Lax
Hobgoblin
Posts: 593
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 50

Re: Ogre-Next StereoRendering Issues

Post by Lax »

I'm getting closer to the matter.

I get bad results because of this quad pass:

Code: Select all

Ogre::CompositorPassQuadDef* passQuad;
passQuad = static_cast<Ogre::CompositorPassQuadDef*>(targetDef->addPass(Ogre::PASS_QUAD));
passQuad->setAllLoadActions(Ogre::LoadAction::DontCare);
passQuad->mMaterialName = "Ogre/Copy/4xFP32";
passQuad->addQuadTextureSource(0, "rtN");

Which comes from the post processing effects. But I need this one.

This is the result if I use the quad, but set neither viewportmodifiermask nor exectionmask:

Image

At least on the left side, the second camera does render a scene and on the right side, everything is ok, but the scene is some how 4x splitted and the left side is not refreshed properly.

I also modified the Ogre Stereo Rendering Sample, so that the PostProcessing Sky compositor is used:

Code: Select all

compositor_node StereoSkyRenderingNode
{
	in 0 rt_renderwindow

target rt_renderwindow
{
	pass clear
	{
		//Get executed on the first eye
		execution_mask			0x01
		//Don't be affected by the modifier, apply to the whole screen
		viewport_modifier_mask	0x00

		colour_value			0.2 0.4 0.6 1

		// Only write to the MSAA surface (don't resolve!)
		// because overlays due to a legacy problem break the pass
		// thus if we resolve now, we'll resolve twice
		store
		{
			colour	store
			depth	store
			stencil	store
		}

		profiling_id "Clear both eyes"
	}
	
	//Render opaque stuff
	pass render_scene
	{
		load
		{
			all				clear
			clear_colour	0.2 0.4 0.6 1
		}
		overlays	off
		rq_first	0
		rq_last		2
		
		//Get executed in all eyes
		execution_mask			0xff
		//Be affected by the modifier, so we render just to a portion of the screen.
		viewport_modifier_mask	0xff

		profiling_id "Opaque Objects"
	}
	
	//Render sky after opaque stuff (performance optimization)
	pass render_quad
	{
		quad_normals	camera_direction
		material SkyPostprocess

		profiling_id "Sky"
		
		execution_mask			0x02
		//Be affected by the modifier, so we render just to a portion of the screen.
		viewport_modifier_mask	0x00
	}
	
	//Render transparent stuff after sky
	pass render_scene
	{
		overlays	on
		rq_first	2
		
		//Get executed in all eyes
		execution_mask			0xff
		//Be affected by the modifier, so we render just to a portion of the screen.
		viewport_modifier_mask	0xff

		profiling_id "Transparents"
	}
}
}

workspace StereoSkyRenderingWorkspace
{
	connect_output StereoSkyRenderingNode 0
}

This is the result:

Image

On the left eye no objects are rendered!

I played around with different masks in the Ogre example, but now its clear, that split screen/stereo does not work for quad passes.
Maybe because a quad pass usually uses a material, which does not know anything about stereo?

@dark_sylinc: Could you fix that? And maybe adapt the stereo example, to have a sky, a plane and shadows rendered?

Because I have no idea if also shadows would work...

Best Regards
Lax

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5328
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1295
Contact:

Re: Ogre-Next StereoRendering Issues

Post by dark_sylinc »

This is something that would be much easier to debug in RenderDoc.

I suspect the problem comes from clear/dont_care and family of functions are applying to the whole section rather than the subviewport (which for some APIs it works like that, and there's not much we can do other than workaround it after seeing what's going on in RenderDoc)

Lax
Hobgoblin
Posts: 593
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 50

Re: Ogre-Next StereoRendering Issues

Post by Lax »

Hi,

I captured a scene via Renderdoc for the modified Sample_Stereo_Rendering, which uses a skybox. See the compositor code in my previews posts.
I think, it would be easier for you, if you just create another Sample, like "Sample_Stereo_Sky_Rendering" etc. add a plane and also shadows.

https://www.lukas-kalinowski.com/Homepa ... ng_Sky.rdc

Best Regards
Lax

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62

Post Reply