Hello!
I’m currently working on a project that would really benefit from a more modular volume override parameter strategy. In particular, I’m working on a volumetric sky with up to 8 optional volumetric atmosphere layers.
My current strategy is to create a class for the atmosphere layer settings with all the volume parameters that I need:
[Serializable]
public class AtmosphereLayerSettings {
public BoolParameter enabled = new BoolParameter(false);
public Vector3Parameter extinctionCoefficients = new Vector3Parameter(new Vector3(0.0000058f, 0.0000135f, 0.0000331f));
... etc ...
And then store a few object parameters with the type of this class in the main SkySettings class.
public ObjectParameter<AtmosphereLayerSettings> atmosphereLayer0,
atmosphereLayer1,
atmosphereLayer2,
atmosphereLayer3,
... etc ...
Then, in the sky renderer, I’m passed the BuiltinSkyParameters object, which stores an instance of SkySettings. To access the extinctionCoefficients parameter value in, for instance, layer 1, I would write
Vector3 extinction = skySettings.atmosphereLayer1.value.extinctionCoefficients.value;
This seems to work fine, except this value doesn’t update when I change it in the GUI—it just stays at the default value its initialized to in the constructor.
Digging in a little more, I noticed the ObjectParameter class has a member variable which stores all the parameters.
internal ReadOnlyCollection<VolumeParameter> parameters { get; private set; }
If I modify the source and make this public, and then access the parameters that way, they update correctly with the GUI! So, programmatically, the access pattern would look like:
skySettings.atmosphereLayer1.parameters[1].value
So now I’m stuck. The internally stored references to the parameters are being updated by ObjectParameter, but not the copies that I’m being passed through BuiltinSkySettings.
I had considered rolling my own ObjectParameter lookalike class, but to get this to work correctly I need to be able to override the internal Interp(VolumeParameter, VolumeParameter) function. The only one that’s exposed for overriding is the value-to-value interp function, which won’t let me access the parameters data structure.
Am I using ObjectParameter completely wrong? It’s sparsely documented and extremely frustrating to figure out. I hope someone can provide some clarity.