I’m trying to change the SSAO radius at runtime but have come to a dead-end. This is what I got so far:
public ForwardRendererData forwardRendererData;
...
private void Awake()
{
List<ScriptableRendererFeature> feat;
feat = forwardRendererData.rendererFeatures;
for (int x = 0; x < feat.Count; x++)
{
if (feat[x].name == "ScreenSpaceAmbientOcclusion")
{
// feat[x].SetActive(false); <- This works
var t = feat[x].GetType().GetProperty("m_Settings", BindingFlags.NonPublic);
// t == null, no t.Radius etc.
}
}
}
Radius and intensity should have been stored on a volume component. The general idea is to put performance/quality options on a render feature, so they can vary per renderer or quality level. But anything that may differ per scene, should be on a volume component. Ironically, Unity didn’t follow their own design for SSAO
Your value ‘t’ is an abstract value, so you won’t be able to access properties like radius or intensity directly. Instead you have to cast it to a ScreenSpaceAmbientOcclusionSettings type. Which is internal, so you’d have to use reflection to get that first. And likely use reflection for any other properties. So the rabbit hole goes deeper still!
Thanks, yes I noticed that ScreenSpaceAmbientOcclusionSettings is internal. I was hoping for a more future-safe way of doing this stuff but I guess I’m out of luck.
I’m having trouble getting to the internal class using reflection. Any pointers? =)