If a compositor node creates a local texture, how can I access that in a workspace listener callback, say passPreExecute or passPosExecute? I thought I could do it using compositorPass->getRenderPassDesc()->findAnyTexture, but It doesn't seem reliable. Maybe it works for render scene passes but not for render quad passes. In the cases where I'm not getting what I expect, the texture is there and has the expected dimensions, but is all black.
Access local texture in workspace listener? Topic is solved
-
jwwalker
- Goblin
- Posts: 297
- Joined: Thu Aug 12, 2021 10:06 pm
- Location: San Diego, CA, USA
- x 21
Access local texture in workspace listener?
-
dark_sylinc
- OGRE Team Member

- Posts: 5534
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1394
Re: Access local texture in workspace listener?
By name:
Code: Select all
pass->getParentNode()->getDefinedTexture( "texture_name" );Though your have other, more direct, non-lookup ways.
If you know in advance where the texture is in the RTV, you can just do:
Code: Select all
pass->getRenderPassDesc()->mColour[idx].textureWhere idx is a value you already know on advance (typically 0 unless you're doing MRT).
Code: Select all
pass->getRenderPassDesc()->mDepth.textureIf it's depth.
And if it's a render quad, you can down cast to CompositorPassQuad and look for the material's texture unit (mat->getTechnique()->getPass()->getTextureUnitState).
Usually if I do the direct ways, I put a few asserts to double check the script hasn't gone out of sync with the code (i.e. things are the way I expect, like number of passes, type of pass at the idx I want, etc).
-
jwwalker
- Goblin
- Posts: 297
- Joined: Thu Aug 12, 2021 10:06 pm
- Location: San Diego, CA, USA
- x 21
Re: Access local texture in workspace listener?
Thanks for providing several approaches, that's very helpful. I knew about the mColour and mDepth members of RenderPassDescriptor by looking at the source code of the findAnyTexture method that I mentioned. But the mColour array doesn't always seem to have what I want in it. In a case I was looking at in the Xcode debugger, mColour[0].texture contains a value of type Ogre::MetalTextureGpuWindow* that doesn't contain an actual texture at this point, whereas the other two approaches show a value of type Ogre::MetalTextureGpuRenderTarget* containing the expected image.
By the way, the material member of the CompositorPassQuad class is protected, with no public accessor, so I had to add my own accessor to try it.
-
dark_sylinc
- OGRE Team Member

- Posts: 5534
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1394
Re: Access local texture in workspace listener?
jwwalker wrote: Wed Jun 21, 2023 6:01 pmThanks for providing several approaches, that's very helpful. I knew about the
mColourandmDepthmembers ofRenderPassDescriptorby looking at the source code of thefindAnyTexturemethod that I mentioned. But themColourarray doesn't always seem to have what I want in it. In a case I was looking at in the Xcode debugger,mColour[0].texturecontains a value of typeOgre::MetalTextureGpuWindow*that doesn't contain an actual texture at this point, whereas the other two approaches show a value of typeOgre::MetalTextureGpuRenderTarget*containing the expected image.
I forgot to mention:
If you're using MSAA, you may have to look in RenderPassTargetBase::resolveTexture as well.
resolveTexture can be:
-
nullptr (e.g. no MSAA or no resolve step)
-
The same value as texture (IIRC, implicit resolved textures)
-
A different value (e.g. explicit MSAA resolve where the RTV was setup by hand)
jwwalker wrote: Wed Jun 21, 2023 6:01 pmBy the way, the material member of the
CompositorPassQuadclass is protected, with no public accessor, so I had to add my own accessor to try it.
You have access to CompositorPassQuad::getPass which is even better, because a Material can have multiple techniques. The returned pass is essentially the same as material->getBestTechnique()->getPass(idx).