Property Types - Change one property max value with an other property's value

Hi.
I’ve got a question but I also want to report missing info in the Shader Graph documentation.
https://docs.unity3d.com/Packages/com.unity.shadergraph@10.2/manual/Property-Types.html
This page says: “Override Property Declaration - Boolean - An advanced option to enable explicit control of the shader declaration for this property
I googled for quite a while and I found no videos on it, let alone anything that would explain the exact usage of this to me? What exactly does this let me do? How can I know when there is no further information?

Why did I look it up?
I have two properties, exposed in my Shader Graph. One of them, let me call it “prop1” got a slider definition and is set from 0 to 1. My other slider property, “prop2” has got a value from 0 to 10.
Use case: I want to set a texture fade-in by using “prop1” as an Alpha multiplier. But. “Prop2” shall define how much time it takes on top of that to reach the maximum. So sometimes it goes quickly, only takes 1 step, sometimes it takes 10 full steps until the texture is fully displayed.
Simple as that.
So what I do is use an HLSL file that goes “divide “prop1” by (“prop2”+0.0001)”. That works well, and it scales the texture Alpha accordingly.
But here goes the issue: When I have a “prop1” max of 1 and I divide it by 10 because “prop2” is set to that, then I never reach full alpha values. Reversely, if I set the “prop1” max to 10 and my “prop2” is at 1, then dragging the slider further up leads to “enhanced” Alpha which I don’t want.
So my idea went: “Can I actually set the max to be defined by the current value of “prop2”?”
But when I try to insert the name of that prop, Unity doesn’t let me type all characters, so it looks like it’s not possible.

Then there’s this ominous “Override Property Declaration” option, that I know nothing about? Is this my savior? Well, how can I know, I cannot look it up.
If anybody knows how to use this and whether it’s even a helpful way or whether there’s a whole different way I would have to go, feel free to let me know. I would have loved to pick “feedback” AND “help wanted”, but this isn’t possible in here.
Since I hope that more info will be added in the documentation, I set this to “feedback”. I really need the help, though, and both parts are closely linked together, in my pov. If a moderator sees this differently, probably make a copy and put it in “help wanted”? I have no idea.

I’m pretty sure you can’t dynamically change the maximum or minimum value of shader properties in this way.

Instead, I would suggest using shader graph nodes like Clamp, Minimum or Maximum (or their HLSL equivalents clamp, min and max) to dynamically limit the values of your properties.

Thanks for your reply. Is there any good source on the topic of min/max/clamp that I could look up? I’m not quite experienced in HLSL just yet.

Unity shader graph documentation:

HLSL documentation:

In short, min(x, y) returns the smallest of x and y, while max(x, y) returns the largest of x and y.
clamp(x, y, z) combines the two, and returns one of three things:

  • x if x is between y and z.
  • y if x is smaller than y.
  • z if x is larger than z.

Thanks for these resources. Could it be that I need a C# script and address my property in there, like in this code snippet? https://www.codegrepper.com/search.php?answer_removed=1&q=min%20max%20slider%20in%20unity

The code from there:

using UnityEngine;
using System.Collections;
using UnityEngine.UI; // Required when Using UI elements.

public class Example : MonoBehaviour
{
    public Slider mainSlider;

    void Start()
    {
        // Changes the minimum value of the slider to 10;
        mainSlider.minValue = 10;
    }
}

Or is that overkill? How do I address the max value in HLSL? Something like:
time.maxValue Does such a thing work, too?

So in theory, if it did work, I would try writing something like
time.maxValue = time_modifier
Is there a valid reason that this would not work? Should I try a C# script nevertheless?

The Slider class is a generic UI component that is unrelated to shaders. It won’t be of much use to you here.

Simply put, you cannot dynamically change the min and max values of a shader property, no matter if you’re trying to do so within Shader Graph, HLSL or through C#. They are basically constant variables.

You can only read these values using C#, through the Shader.GetPropertyRangeLimits function, but you cannot alter them in any way, as you can see on the Shader class reference page: Unity - Scripting API: Shader.

Instead, you would have to add a new float property to your shader. For example, let’s say we have a float property named “Occlusion”. Let’s also say that sometimes we want its max value to be 1, and that sometimes we want it to be 0.5.
To achieve this behavior, we’ll introduce an additional float property, named “MaxOcclusion”, which we can set to 1 or to 0.5 as we see fit, using the Material.SetFloat function from a C# script. In shader graph, you would then do something like in the picture below. Note that the Occlusion property’s max value would be unused, since we just simulate it ourselves.

7405364--905279--example.png