kobaltkween opened this issue on Nov 29, 2009 · 10 posts
bagginsbill posted Sun, 29 November 2009 at 7:26 PM
It is not possible to write a shader that determines the min or max of a result.
It is possible to write a function, or more specifically a computer program could be written to sample the results of a function well enough to determine the min and max of a given result set. But there is the key - one must evaluate the entire result set, or close to it. A shader can only evaluate one point - the point it is being asked to shade. While the same shader seems to produce all possible values, in fact it is only producing one value and that is for the currently shaded point. To find the maximum of a million points, one must evaluate the shader at a million points. See the problem?
We could write a crapload of nodes that would allow a shader to evaluate something like fBm at points other than its own, but not enough to determine a global maximum and minimum.
However, when we are able to reason about a result set, then we can also reason about any manipulation of that result set that is deterministic. For example, if I happen to know that the max of a result set is .4, then I'm certain that 2 times that result set has a maximum of .8. This is no problem. Even more complicated things like Bias, Gain, all of these have easy ways to calculate the outcome for the domain of its input, and give us the range of its output.
But anything where we don't have a deterministic result, we cannot predict the value. For example, suppose we were to make two different Noise nodes and add them together. In theory, the maximum of the sum would be 1.0. But in fact, that would only happen if both nodes happened to produce a 1 at the same point. Suppose they never did? Suppose that behind the scenes there is some hidden coupling that means that this never actually happens? Then assuming the max is 2 would be incorrect. There's not a lot we can do about this, except to avoid using the non-deterministic nodes altogether.
Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)