Hi all, is it possible to somehow procedurally add new parameters to material?
Procedurally meaning to add them without explicitly adding special parameters nodes to the graph. Parameters are still static - they’re just not defined explicitly before the compilation with nodes.
A classic example - you have a material that blends two similar subgraphs.
Each consists of a sample texture, multiplied by a parameter and then powered by another parameter.
If I would want to add a third one, I would need to copy the entire graph, change index in all parameters and keep maintaining them in the future. Graph can get a lot more complex of course, so maintaning them gets hard in the future.
A solution for growing subgraph complexity is to use functions, of course. But you still need to maintain all it’s inputs - if subgraph is rearranging input or now needs 7 of them instead of 5 - you need to go through all it’s consumers and add/move/remove parameters.
It’s very annoying and results in lots of boilerplate work. I was thinking, how can I overcome this?
I had a thought that maybe it’s possible to define parameters from custom node, but from looking at the generated HLSL code, parameters are defined in more complex way than just added to the shader code.
E.g. Param_1 shared is refferred as Material.PreshaderBuffer[0].y. So parameters relationship to material asset is too complex to just add them from custom node.
MaterialFloat2 Local0 = Parameters.TexCoords[0].xy;
MaterialFloat Local1 = MaterialStoreTexCoordScale(Parameters, DERIV_BASE_VALUE(Local0), 0);
MaterialFloat4 Local2 = ProcessMaterialLinearColorTextureLookup(Texture2DSampleBias(Material.Texture2D_0,Material.Texture2D_0Sampler,DERIV_BASE_VALUE(Local0),View.MaterialTextureMipBias));
MaterialFloat Local3 = MaterialStoreTexSample(Parameters, Local2, 0);
MaterialFloat3 Local4 = (((MaterialFloat3)Material.PreshaderBuffer[0].x) * Local2.rgb);
MaterialFloat3 Local5 = PositiveClampedPow(Local4,((MaterialFloat3)Material.PreshaderBuffer[0].y));
MaterialFloat Local6 = MaterialStoreTexCoordScale(Parameters, DERIV_BASE_VALUE(Local0), 1);
MaterialFloat4 Local7 = ProcessMaterialLinearColorTextureLookup(Texture2DSampleBias(Material.Texture2D_1,Material.Texture2D_1Sampler,DERIV_BASE_VALUE(Local0),View.MaterialTextureMipBias));
MaterialFloat Local8 = MaterialStoreTexSample(Parameters, Local7, 1);
MaterialFloat3 Local9 = (((MaterialFloat3)Material.PreshaderBuffer[0].z) * Local7.rgb);
MaterialFloat3 Local10 = PositiveClampedPow(Local9,((MaterialFloat3)Material.PreshaderBuffer[0].w));
MaterialFloat3 Local11 = lerp(Local5,Local10,Material.PreshaderBuffer[1].x);
MaterialFloat3 Local12 = lerp(Local11,Material.PreshaderBuffer[2].xyz,Material.PreshaderBuffer[1].y);
Are there any alternative solutions to this?

