Hello,
I have a UWP project that is using the “RenderObjects” render pass to draw an overlay grid on the scene with some feedback data. That works great so far.
However, I need to access this RenderObjects pass through code, in this case to set the override material from code. I can’t seem to figure out how to get to this through the api. Here’s the closest I’ve come:
UniversalRenderPipelineAsset urpAsset = (UniversalRenderPipelineAsset)GraphicsSettings.renderPipelineAsset;
ScriptableRenderer render = urpAsset.scriptableRenderer;
ScriptableRendererData rendererData = render.???;
List<ScriptableRendererFeature> rendererFeatures = rendererData.rendererFeatures;
foreach (ScriptableRendererFeature feature in rendererFeatures)
{
RenderObjects objectPass = feature as RenderObjects;
if (objectPass != null)
{
// do something with objectPass
Debug.LogFormat("Override material is {0}", objectPass.settings.overrideMaterial.name );
}
}
Right now I’m working around this by just keeping a reference to the material somewhere else, but this is not idea for a few reasons – I would like to be able to enable/disable the overrideMaterial at runtime (right now I’m just setting and unsetting the layer for things so it’s always running the renderObjects pass even when it doesn’t need it, and also this modifies the .mat file in the scene which is just annoying.
Am I missing something to get access to the objectPass asset at runtime?
We’re using 2019.1.7f1 with LWRP 5.16.1, but I’ve also tried this with 2019.3.0b11 and UWP 7.1.5 since we’re considering upgrading and didn’t see any difference.
Thanks!
Joel