![]() |
|
MATHS - DIVIDE |
| Home | Tutorial Links | My Tutorials | Sample Materials | Freebies |
MATHS - DIVIDE FUNCTIONAs you would expect, the divide function takes Value_1 and divides it by Value_2. In both cases, these values are multiplyed by the input of any shader nodes plugged into their inputs. The divide function is most useful if shader nodes are plugged into both Value_1 and Value_2. Unlike add or multiply, divide produces different results depending on which order the two nodes are plugged in (see figure 1). As can be seen here, the divide function can take two fairly dull textures and produce a much brighter result. When used with unmodified shader nodes, both inputs will be between 0 and 1. In these cases, if input_1 is higher, the result will be over 1, if input_2 is higher then the result will be under 1. As Value_2 gets lower, the potential for high results increases (1 divided by 0.1 = 10). Figure 2 shows one potential result of this. The output of this division increases in value from right to left as the u variable gets smaller. The output from this function is not clamped between 0 and 1, so the area of the shader affected by the left of the result will be very bright. Suggested UsesThe divide function is rarely of much use when used with a fix input2. In the vast majority of cases, you can use another input2 somewhere else in your shader tree to produce the same effect (this is not so true in colour maths - just as with multiply, the divide node comes into its own there). There are one or two mathamatical constants that can also be expressed as fractions. The best known of these is PI. This can be approximated as 355/113. Divide by ZeroOne potential problem that the computer programmers out there might be worried about is the 'divide by zero' error. Any number divided by zero produces an answer of 'infinity'. In most computer programming languages (and spreadsheets for that matter) this causes a 'divide by zero' error, and stops the program. This could cause great problems in Poser, where black is represented as zero. Fortunatly, Poser sidesteps this issue. As it can't return 'infinity' as a result, instead dividing by zero results in a very large number. This large number is not actually the true answer to your sum. The number produces is 10,000,000 multiplied by the first part of your division (so 1/0 = 10,000,000; 2/0 = 20,000,000 etc). This produces a number large enough to max-out just about any Poser function - displacements will disappear off screen, shader node inputs will be set to their maximum value. Best of all, your scene will not fail to render every time a divide function encounters black! How did I work this number out? By using the material room! The trick is to use the 'floor' maths function. This rounds input one down to the nearest whole number. On our preview this means that any number below 1 shows as black, 1 and above shows as white. Take the output of our divide by zero, and plug it into a divide node. Plug the output of this second divide node into the floor node. Any number divided by itself produces a result of 1 (white in our floor node). Therefore, to find out what value a dividing by zero produces, we need to find the point at which the floor node goes from white to black. That value is 10,000,001. Ten million produces white, ten million and one produces black. This means that our input must be ten million (10,000,000/10,000.000=1; 10,000,000/10,000,001=0.9999990000000 recuring) |