-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHashNoise.osl
32 lines (32 loc) · 1.03 KB
/
HashNoise.osl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
shader HashNoise(
string Dimensions = "4D"
[[ string widget = "mapper",
string options = "1D (X):1D|2D (X, Y):2D|3D (X, Y, Z):3D|4D (X, Y, Z, W):4D" ]],
float Minimum = 0.0,
float Maximum = 1.0,
point Position_XYZ = P
[[ string label = "Position XYZ" ]],
float Position_W = 0.0
[[ string label = "Position W" ]],
vector Scale_XYZ = 1.0
[[ string label = "Scale XYZ" ]],
float Scale_W = 1.0
[[ string label = "Scale W" ]],
output color Color = 0.0,
output float Float = 0.0
) {
point pos = Position_XYZ * Scale_XYZ;
float w = Position_W * Scale_W;
color result;
if (Dimensions == "1D") {
result = noise("hash", pos[0]);
} else if (Dimensions == "2D") {
result = noise("hash", pos[0], pos[1]);
} else if (Dimensions == "3D") {
result = noise("hash", pos);
} else {
result = noise("hash", pos, w);
}
Color = mix(vector(Minimum), vector(Maximum), result);
Float = mix(Minimum, Maximum, result[0]);
}