Ogre-Next StereoRendering Issues

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


Lax
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

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
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

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
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

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: 5433
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1341

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
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

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

Lax
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

Re: Ogre-Next StereoRendering Issues

Post by Lax »

Hi @dark_sylinc ,

I hope I'm not getting on your nerves.

Just wanted to send a ping to you for this topic. It would be really nice, having splitscreen working for quads.
See also the recorded RenderDoc file for proper analysis, what is going wrong on Ogre with quad's.

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: 5433
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1341

Re: Ogre-Next StereoRendering Issues

Post by dark_sylinc »

Lax
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

Re: Ogre-Next StereoRendering Issues

Post by Lax »

Hi @@zxz , @dark_sylinc ,

thanks for pointing to the topic.
I read everything carefully. Yet I have no idea, how to get that working :?

The critical part is:

Well, I looked into this once again, and the solution turned out to be as easy as I had thought at first. Somehow I managed to mess up the details when implementing it before. The trick to get the proper view vector for an asymmetric eye frustum (they often are in VR applications) is to preserve the length differences between the frustum corner vectors before interpolation across the quad. Then the interpolation works properly, and the vector can be normalized in the fragment shader (or used directly for cubemap lookup). Ogre might already be getting this right for the single quad drawn by a PASS_QUAD with CAMERA_DIRECTION. Done this way, the sky aligns perfectly at infinity and there is no longer any left/right offset causing double-vision.

I've created a custom pass to implement this, but the proper solution would be to make PASS_QUAD stereo-aware, then stereo rendering would Just Work for users. I haven't looked into making the changes inside of Ogre.

PASS_QUAD should draw a geometry that spans both eyes with normals calculated by each eye's individual projection matrix (Camera::getVrProjectionMatrix(i)). Of course, two quads can be drawn instead, but that is a bit more wasteful. I suppose that the same thing could be done for the other mFrustumCorners-alternatives, but I haven't looked into those cases. There doesn't seem to be anything complicated to take into account.

But I'm not deep enough in the Ogre's internals in order to understand, what that means.

Can you take me by the hand here :)

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
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

Re: Ogre-Next StereoRendering Issues

Post by Lax »

Hi @dark_sylinc,

Is there any chance, that splitscreen will be fixed for quad rendering in the future and a Ogre demo created?

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

Lax
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

Re: Ogre-Next StereoRendering Issues

Post by Lax »

Ok, what now I did is the following:

I created a custom quad pass and setting for each camera the eye id:

Code: Select all

class SplitQuadPassDef : public Ogre::CompositorPassQuadDef
{
public:
	SplitQuadPassDef(Ogre::CompositorTargetDef* parentTargetDef)
		: Ogre::CompositorPassQuadDef(Ogre::CompositorNodeDef* parentNodeDef, Ogre::CompositorTargetDef* parentTargetDef),
		eyeId(0)
	{
	}
	
void setEyeId(Ogre::uint8 eyeId)
{
	this->eyeId = eyeId;
}

Ogre::uint8 getEyeId(void) const
{
	return this->eyeId;
}
private:
	Ogre::uint8 eyeId;
};

class SplitQuadPass : public Ogre::CompositorPassQuad
{
public:
	SplitQuadPass(const Ogre::CompositorPassQuadDef* definition, Ogre::Camera* defaultCamera,
				  Ogre::CompositorNode* parentNode, const Ogre::RenderTargetViewDef* rtv,
				  Ogre::Real horizonalTexelOffset, Ogre::Real verticalTexelOffset)
		: Ogre::CompositorPassQuad(definition, defaultCamera, parentNode, rtv, horizonalTexelOffset, verticalTexelOffset),
		eyeId(eyeId)
	{
	}

virtual void execute(const Ogre::Camera* lodCamera) override
{
	Ogre::CompositorPassQuad::execute(lodCamera);

	Ogre::RenderSystem* rs = mParentNode->getRenderSystem();

	// Render for the first camera
	rs->_setViewMatrix(mCamera->getViewMatrix(true));
	rs->_setProjectionMatrix(mCamera->getVrProjectionMatrix(this->eyeId));
}

void setEyeId(Ogre::uint8 eyeId)
{
	this->eyeId = eyeId;
}
private:
	Ogre::uint8 eyeId;
};

class OgreCompositorPassProvider : public Ogre::CompositorPassProvider
{
public:
	Ogre::CompositorPassDef* addPassDef(Ogre::CompositorPassType passType,
										Ogre::IdString customId,
										Ogre::CompositorTargetDef* parentTargetDef,
										Ogre::CompositorNodeDef* parentNodeDef)
	{
		if (customId == "SPLIT_PASS")
			return OGRE_NEW SplitQuadPassDef(parentNodeDef, parentTargetDef);
		return nullptr;
	};

Ogre::CompositorPass* addPass(const Ogre::CompositorPassDef* definition, Ogre::Camera* defaultCamera,
							  Ogre::CompositorNode* parentNode, const Ogre::RenderTargetViewDef* target,
							  Ogre::SceneManager* sceneManager)
{
	Ogre::CompositorPassQuadDef* passQuadDef = (Ogre::CompositorPassQuadDef*)(definition);
		
	auto pass = OGRE_NEW SplitQuadPass(passQuadDef, defaultCamera, parentNode, target, 0, 0);
	pass->setEyeId(this->splitQuadPassDef->getEyeId());
	return pass;
}
};

Now on each to be added quat pass, I check if useSplitScreen is set to true and I'm using this function to get the quad pass:

Code: Select all

Ogre::CompositorPassQuadDef* WorkspaceBaseComponent::getPassQuad(Ogre::CompositorTargetDef* targetDef)
{
	Ogre::CompositorPassQuadDef* passQuad;
	if (true == this->useSplitScreen)
	{

	passQuad = static_cast<Ogre::CompositorPassQuadDef*>(targetDef->addPass(Ogre::PASS_CUSTOM, "SPLIT_PASS"));
	SplitQuadPassDef* splitQuadPassDef = static_cast<SplitQuadPassDef*>(passQuad);
	splitQuadPassDef->setEyeId(this->cameraComponent->getEyeId());
}
else
{
	passQuad = static_cast<Ogre::CompositorPassQuadDef*>(targetDef->addPass(Ogre::PASS_QUAD));
}
return passQuad;
}

Usage:

Code: Select all

// Sky quad
{
				Ogre::CompositorPassQuadDef* passQuad = this->getPassQuad(targetDef);
				passQuad->mMaterialName = "NOWASkyPostprocess";
				passQuad->mFrustumCorners = Ogre::CompositorPassQuadDef::CAMERA_DIRECTION;

			passQuad->mProfilingId = "NOWA_Sky_PlanarReflections_Pass_Quad";

			this->applySplitScreenModifier(passQuad);
}

But I still get bad artifacts.
Is this the correct way??

And what about:

rs->setViewMatrix(mCamera->getViewMatrix(true));
rs->
setProjectionMatrix(mCamera->getVrProjectionMatrix(this->eyeId));

How can I set, that a quad shall only by set for half of the screen?

AND

I have no idea why:

Code: Select all

void SplitQuadPass::execute(const Ogre::Camera* lodCamera)
{
	Ogre::CompositorPassQuad::execute(lodCamera);

Ogre::RenderSystem* rs = mParentNode->getRenderSystem();

// Render for the first camera
rs->_setViewMatrix(mCamera->getViewMatrix(true));
rs->_setProjectionMatrix(mCamera->getVrProjectionMatrix(this->eyeId));
}

Is not called.

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

Lax
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

Re: Ogre-Next StereoRendering Issues

Post by Lax »

I think I know why execute is not called.

I created a custom Quad Pass, but the constructor of the base class is this one:

Code: Select all

 CompositorPassQuadDef( CompositorNodeDef *parentNodeDef, CompositorTargetDef *parentTargetDef ) :
     CompositorPassDef( PASS_QUAD, parentTargetDef ),

That means, no matter which type I set, it will be overridden with PASS_QUAD. But I need PASS_CUSTOM to be set.

For testing, I set the mType Variable protected, so that my derived class can set it to PASS_CUSTOM.

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
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

Re: Ogre-Next StereoRendering Issues

Post by Lax »

Nope, I changed the type, but now no splitscreen is working anymore and I get a crash if closing Ogre.

I think I have to give up the topic. I have no clue anymore. :(

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
Crystal Hammer
Gnome
Posts: 388
Joined: Sat Jun 23, 2007 5:16 pm
x 99

Re: Ogre-Next StereoRendering Issues

Post by Crystal Hammer »

IDK if I can help here. My setup is quite different.
But I got split screen for up to 6 players, so here it goes.
I have still a .compositor file:
https://github.com/stuntrally/stuntrall ... sitor#L748
older is easier to check, main is SR3_RenderAbsOld
and then each player has own number:
compositor_node SR3_RenderOld0 : SR3_RenderAbsOld

Then in code I'm adding shadows and Gui, mainly in AppGui::SetupCompositor()
more interesting for split screen here:
https://github.com/stuntrally/stuntrall ... r.cpp#L219

As for VR I only have basic stuff there, didn't continue. Tutorial_OpenVR had more for OgreNext.

Lax
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

Re: Ogre-Next StereoRendering Issues

Post by Lax »

hi @Crystal Hammer ,

thanks for giving me some help!

I will investigate you code and took a short look.
But how do deal with quad_pass'es?
I mean, skybox uses a quad pass, hdr several and postprocessing several to.

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
Crystal Hammer
Gnome
Posts: 388
Joined: Sat Jun 23, 2007 5:16 pm
x 99

Re: Ogre-Next StereoRendering Issues

Post by Crystal Hammer »

I think this is dealing by itself.
I mean, I set viewport dimensions in addWorkspace call as argument Vector4 &vpOffsetScale, as Vector4(left, top, width, height).
I got in ViewDim::SetDim for my split screen configurations for 2 to 6 players.
But for VR I got some code above (based on Ogre)

Code: Select all

		// left eye
		ws1 = mgr->addWorkspace( mSceneMgr, ext,
				camL->cam, wsName,
				true, -1, 0, 0,
				Vector4( 0.0f, 0.0f, 0.5f, 1.0f ),
				0x01, 0x01 );

		// right eye
		ws2 = mgr->addWorkspace( mSceneMgr, ext, 
				camR->cam, wsName,
				true, -1, 0, 0,
				Vector4( 0.5f, 0.0f, 0.5f, 1.0f ),
				0x02, 0x02 );

So width is only 0.5 and right eye has offset 0.5.
I assume this means any quad pass etc inside compositor_node will only render by these given dimension.
So left eye is first and does clear, and right is second and does not clear.

On top of that I have Gui pass added from code (in ::AddGuiShadows) that will render only once, and on full screen

Code: Select all

		pass->mExecutionMask = 0x02;
		pass->mViewportModifierMask = 0x00;

There is good info in ogre-next/OgreMain/include/Compositor/OgreCompositorManager2.h before addWorkspace declaration:

Code: Select all

        @param vpOffsetScale
            The viewport of every pass from every node will be offseted and scaled by
            the following formula:
                left    += vpOffsetScale.x;
                top     += vpOffsetScale.y;
                width   *= vpOffsetScale.z;
                height  *= vpOffsetScale.w;
            This affects both the viewport dimensions as well as the scissor rect.
        @param vpModifierMask
        @parblock
            An 8-bit mask that will be AND'ed with the viewport modifier mask of each pass
            from every node. When the result is zero, the previous parameter "viewportModifier"
            isn't applied to that pass.

            This is useful when you want to apply a pass (like Clear) to the whole render
            target and not just to the scaled region.
        @endparblock
        @param executionMask
        @parblock
            An 8-bit mask that will be AND'ed with the execution mask of each pass from
            every node. When the result is zero, the pass isn't executed. See remarks
            on how to use this for efficient Stereo or split screen.

            This is useful when you want to skip a pass (like Clear) when rendering the second
            eye (or the second split from the second player).
        @endparblock
Lax
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

Re: Ogre-Next StereoRendering Issues

Post by Lax »

hm, I also create for each splitt its own workspace, so each player has its own quad_passes, render_scene
and addWorkspace is also done several times.

I also read the Compositor Documentation and Ogre documentation carefully, in order to set the viewportModifierMask and executionMask properly.

But I will examine your code carefully.

It's hard to keep track of everything, using compositor nodes and workspace via C++ code, as Hdr, Cubemap, Sky, Reflection etc. can be involved.

What I do not understand, where are your quad_passes, are they created by code?
You also use HDR e.g.? Or Skybox?

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
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

Re: Ogre-Next StereoRendering Issues

Post by Lax »

What I do not understand:

  • In your compositor code, you use for each player its own compositor node and workspace.
  • But in your C++ code, you use for all players the same "SR3_Workspace".

What is now correct?

Here is my result:

  • First (Main) Camera has the rect:
    0.0f, 0.0f, 0.5f, 1.0f

this->viewportModifierMask = 0x01;
this->executionMask = 0x01;

  • Second camera has the rect:
    0.5f, 0.0f, 0.5f, 1.0f

this->viewportModifierMask = 0x02;
this->executionMask = 0x02;

QUAD_PASS'es are unattached with viewportModifierMask and executionMask.

I'm creating 2 workspaces. One for each camera.

Image

Somehow: The mouse can not be moved to the left side. On the right side, the left split is empty. Instead on the whole left side the scene is weird rendered with artifacts.

My Monitor resolution: 2560x1080.

What about texture definitions for compositor nodes?

I'm using:

Code: Select all

Ogre::TextureDefinitionBase::TextureDefinition* texDef = compositorNodeDefinition->addTextureDefinition("rt0");
texDef->width = 0; // target_width
texDef->height = 0; // target_height

Or do I need to set a half width, because splitted?

Do I have to use:

this->camera->setWindow(...)?

What about the external channel for each workspace. Do the workspaces for each split use the same one? Like:

Code: Select all

this->externalChannels[0] = Core::getSingletonPtr()->getOgreRenderWindow()->getTexture();

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
Crystal Hammer
Gnome
Posts: 388
Joined: Sat Jun 23, 2007 5:16 pm
x 99

Re: Ogre-Next StereoRendering Issues

Post by Crystal Hammer »

I don't have HDR. The sky I have has nodes, mesh is sphere/dome.
I have workspace SR3_Workspace0..6 and String AppGui::getWorkspace(int plr) gets it for player.
SR3_RenderAbsOld doesn't have render_quad.
I'm using the new SR3_RenderAbs for refractions, and depthBuffer too now. It has render_quad used (by material Ogre/Copy/4xFP32) for refractions.
I don't create textures like you compositorNodeDefinition->addTextureDefinition at all in code.
I'm using this createShadowNodeWithSettings in src/common/AppGui_Shadows.cpp for shadows setup, sadly only PCF works for me, ESM does not.
I don't have camera->setWindow call either.
As for external channel IDK probably yes, I didn't yet check this, I have it for cube map reflections.

Lax
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

Re: Ogre-Next StereoRendering Issues

Post by Lax »

Ok then there is the difference. You do not use pass_quad and you also not creating input textures.

If quad_pass is used, this must be done:

Well, I looked into this once again, and the solution turned out to be as easy as I had thought at first. Somehow I managed to mess up the details when implementing it before. The trick to get the proper view vector for an asymmetric eye frustum (they often are in VR applications) is to preserve the length differences between the frustum corner vectors before interpolation across the quad. Then the interpolation works properly, and the vector can be normalized in the fragment shader (or used directly for cubemap lookup). Ogre might already be getting this right for the single quad drawn by a PASS_QUAD with CAMERA_DIRECTION. Done this way, the sky aligns perfectly at infinity and there is no longer any left/right offset causing double-vision.

I've created a custom pass to implement this, but the proper solution would be to make PASS_QUAD stereo-aware, then stereo rendering would Just Work for users. I haven't looked into making the changes inside of Ogre.

PASS_QUAD should draw a geometry that spans both eyes with normals calculated by each eye's individual projection matrix (Camera::getVrProjectionMatrix(i)). Of course, two quads can be drawn instead, but that is a bit more wasteful. I suppose that the same thing could be done for the other mFrustumCorners-alternatives, but I haven't looked into those cases. There doesn't seem to be anything complicated to take into account.

But I have no idea how to accomplish that, Im really clueless.

And I also adapted the Ogre sample postprocessing sky to be stereo and there splitscreen also does not work. See my post above with screenshot

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: 5433
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1341

Re: Ogre-Next StereoRendering Issues

Post by dark_sylinc »

I think you are not accounting this info which was on my first post:

dark_sylinc wrote: Tue Jun 11, 2024 3:17 pm

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)

Even if you define a limit to the viewport (e.g. draw to the first half 960x1080 from a full 1920x1080 texture) dont_care and clear will apply to the whole 1920x1080 texture; so you must use load and store instead (and do clears separately in the first eye's pass).

This is very important or else the second eye's drawing will delete what the first eye's drew.

Lax
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

Re: Ogre-Next StereoRendering Issues

Post by Lax »

Oh boy, I totally got lost in details and had not thought about that.

I will check that, thanks for your investigation dark_sylinc!

I set now all store actions in pass_clear, pass_quad, pass_scene to 'store'.
Its now a bit better, but still there are to many splits.

How can I deal the exectutionMask and viewportmodifiermask for a quad_pass?

Or shall quad_passes be unattached?

How can I find out which pass is rendering the whole screen, even if it should not?

In my Engine the Pass_Quad "Ogre/Copy/4xFP32" is involved. This pass could be causing the trouble, I even forgot, why I need this pass^^

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
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

Re: Ogre-Next StereoRendering Issues

Post by Lax »

I now set each pass to:

Code: Select all

pass->setAllStoreActions(Ogre::StoreAction::Store);

Code: Select all

I create workspace 2 times for the different viewport and the 		if (false == this->useSplitScreen)
		{
			this->workspace = WorkspaceModule::getInstance()->getCompositorManager()->addWorkspace(this->gameObjectPtr->getSceneManager(), externalChannels,
																								   this->cameraComponent->getCamera(), this->workspaceName, true);
		}
		else
		{

		this->workspace = WorkspaceModule::getInstance()->getCompositorManager()->addWorkspace(this->gameObjectPtr->getSceneManager(), externalChannels,
																							   this->cameraComponent->getCamera(), this->workspaceName,
																							   true, -1, (Ogre::UavBufferPackedVec*)0, (Ogre::ResourceStatusMap*)0, this->viewportRect->getVector4(), this->viewportModifierMask, this->executionMask);
	}

I also attached an Ogre::LogMessage to setRenderPassDescToCurrent in OgreCompositorPass.cpp and this this the result:

Code: Select all

21:15:16: Pass: Shadow Node SCENE 7 has viewport count: 1 size: 0 0 1 0.285714
21:15:16: Pass: Shadow Node SCENE 8 has viewport count: 1 size: 0 0.285714 0.5 0.142857
21:15:16: Pass: Shadow Node SCENE 9 has viewport count: 1 size: 0.5 0.285714 0.5 0.142857
21:15:16: Pass: NOWA_Pbs_Render_Scene_Pass_Scene_0 has viewport count: 1 size: 0 0 0.5 1
21:15:16: Pass: NOWA_Final_rtN_Pass_Quad_0 has viewport count: 1 size: 0 0 0.5 1
21:15:16: Pass: Shadow Node SCENE 7 has viewport count: 1 size: 0 0 1 0.285714
21:15:16: Pass: Shadow Node SCENE 8 has viewport count: 1 size: 0 0.285714 0.5 0.142857
21:15:16: Pass: Shadow Node SCENE 9 has viewport count: 1 size: 0.5 0.285714 0.5 0.142857
21:15:16: Pass: NOWA_Pbs_Render_Scene_Pass_Scene_1 has viewport count: 1 size: 0.5 0 0.5 1
21:15:16: Pass: NOWA_Final_rtN_Pass_Quad_1 has viewport count: 1 size: 0.5 0 0.5 1
21:15:16: Pass: NOWA_Final_Render_Overlay_Pass_Scene_1 has viewport count: 1 size: 0 0 1 1

What I do not understand:

  • There is no Pass Clear! Why?, just scene, shadow nodes, quad
  • The viewport count is always 1
  • The viewport sizes, seems to be correct (do not know if also for shadow nodes, as there are created not by code but in a compositor file separately
  • The mousepointer cannot be moved to the left side

So what is wrong here??

Image

  • On the picture, during rendering, the empty screen is black, I do not know, why its here white (maybe transparent?)

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
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

Re: Ogre-Next StereoRendering Issues

Post by Lax »

Hi @dark_sylinc ,

any chance, that you could look into the issue I mentioned the post above?

I still can get this working and I'm out of ideas.
I followed your instructions concerning clear/dont_care

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

Lax
Gnoll
Posts: 644
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 59

Re: Ogre-Next StereoRendering Issues

Post by Lax »

I started a new round, in trying fixing the issue. And I think I tracked it down to the quad pass, which uses this material:

Code: Select all

Ogre/Copy/4xFP32

It comes from:

...\media\2.0\scripts\materials\Common\Copyback.material

I need that pass, because I'm using screen space reflections:

Code: Select all

pass render_quad
		{
			load { all dont_care }
			material Ogre/Copy/4xFP32
			input 0 rtt
			//input 0 reflectionBuffer
		}

I changed the:

Code: Select all

load { all dont_care }

to:

Code: Select all

load { all load }

But it does now work.

This is the result so far:

Image

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
Crystal Hammer
Gnome
Posts: 388
Joined: Sat Jun 23, 2007 5:16 pm
x 99

Re: Ogre-Next StereoRendering Issues

Post by Crystal Hammer »

I'm almost sure I have the same issue too now.
E.g. like so, for 3 way split: download/file.php?id=7373
But only since I added refractions, split rendering and started using load/store too.
(mentioned here viewtopic.php?p=556432#p556432)
If I use my old compositor I have it rendered normally.
I think it's a bug in OgreNext, it'd be good if to fix this finally.