[3.0.0] Using compositor global textures

Problems building or running the engine, queries about how to use features etc.
Nimble
Gnoblar
Posts: 2
Joined: Mon Aug 04, 2025 1:54 pm

[3.0.0] Using compositor global textures

Post by Nimble »

Ogre Version: 3.0.0

I'm trying to use a global texture in a compositor. Defining the texture seems to work fine but I can't work out how to use it as a render target.

This is what I'm trying:

Code: Select all

compositor_node Final
{
	in 0 rt_out
	target global_rt
	{
		pass clear {}
	}
	target rt_out
	{
		pass clear {}
	}
}

workspace ExampleWorkspace
{
	texture global_rt target_width target_height PFG_RGBA16_FLOAT msaa_auto
	connect_external 0 Final 0
}

Code: Select all

An exception has occured: OGRE EXCEPTION(5:ItemIdentityException): Could not find RenderTargetView with name global_rt in CompositorNodeDef::getRenderTargetViewDef at ~/ogre-next/OgreMain/src/Compositor/OgreTextureDefinition.cpp (line 255)
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5534
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1394

Re: [3.0.0] Using compositor global textures

Post by dark_sylinc »

It's been a while since I've used global textures: Since global textures are everywhere and RTVs need to be defined explicitly, OgreNext is currently not autogenerating the RTVs for the nodes that need it. But you can write one yourself:

Code: Select all

compositor_node Final
{
	in 0 rt_out

   rtv my_rtv
   {
          color global_rt
   }

target my_rtv
{
	pass clear {}
}
target rt_out
{
	pass clear {}
}
}

workspace ExampleWorkspace
{
	texture global_rt target_width target_height PFG_RGBA16_FLOAT msaa_auto
	connect_external 0 Final 0
}

See the full syntax in the manual.

HINT: Rather than using a global texture you may find it more useful to create an empty node that just defines textures and outputs them, like this:

Code: Select all

compositor_node TextureOwner
{
	texture my_own_rt target_width target_height PFG_RGBA16_FLOAT msaa_auto
	out 0 my_own_rt
}

compositor_node Final
{
	in 0 rt_out
	in 1 my_own_rt

target my_own_rt
{
	pass clear {}
}
target rt_out
{
	pass clear {}
}
}

workspace ExampleWorkspace
{
	connect 0 TextureOwner 1 Final
	connect_external 0 Final 0
}

This is more flexible because when you need to modify your graphics settings and thus the Compositor, you can rewire some nodes with the additional textures (specially true for MSAA because MSAA often requires extra textures to be handled as a special case). Having global texture names means that if you suddenly wish Node A and Node B to have a different texture, you must change the script for both nodes. But with this approach, you can just rewire Node B to source its texture from a different node; which can happen at runtime if graphics settings change.

Nimble
Gnoblar
Posts: 2
Joined: Mon Aug 04, 2025 1:54 pm

Re: [3.0.0] Using compositor global textures

Post by Nimble »

Ah, okay, that helps. I get this error:

Code: Select all

An exception has occured: OGRE EXCEPTION(5:ItemIdentityException): Can't find texture with name: 'global_rt' If it's a global texture, trying to use it in the output channel will fail. in CompositorNodeDef::getTextureSource at ~/ogre-next/OgreMain/src/Compositor/OgreTextureDefinition.cpp (line 214)

But this works:

Code: Select all

rtv global_rt {}
target global_rt {}

rtv my_rtv
{
	colour global_rt
}

Unfortunately I'm getting another problem with global textures. A global texture and a local texture both defined with "target_width target_height" do not always have the same dimensions. When resizing, the local texture is resized first. So something like this fails:

Code: Select all

rtv my_rtv
{
	colour local_rt
	stencil global_stencil
}

Code: Select all

An exception has occured: OGRE EXCEPTION(2:InvalidParametersException): Manually specified depth buffer 'stencil[Value 0x00000000]' is incompatible with colour RTT #0'local_rt[Value 0x0000000a]
Colour: 1278x700x1 1x MSAA PFG_RGBA16_FLOAT
Depth: 1280x720x1 1x MSAA PFG_D32_FLOAT_S8X24_UINT in RenderPassDescriptor::entriesModified at ~/ogre-next/OgreMain/src/OgreRenderPassDescriptor.cpp (line 277)