forked from Maxon-Computer/Redshift-OSL-Shaders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClamp.osl
50 lines (49 loc) · 1.27 KB
/
Clamp.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
shader Clamp
(
// Inputs
color InColor = 1
[[
string label = "In Color",
string page = "Color"]],
color InColorMin = 0
[[
string label = "Minimum Color",
string page = "Color"]],
color InColorMax = 1
[[
string label = "Maximum Color",
string page = "Color"]],
float InFloat = 1
[[ string label = "Input Float",
string page = "Float",
float min = 0, float max = 1, float precision = 3]],
float InFloatMin = 0
[[ string label = "Minimum Float",
string page = "Float",
float min = 0, float max = 1, float precision = 3]],
float InFloatMax = 1
[[ string label = "Maximum Float",
string page = "Float",
float min = 0, float max = 1, float precision = 3]],
vector InVector = 1
[[
string label = "In Vector",
string page = "Vector"]],
vector InVectorMin = 0
[[
string label = "Minimum Vector",
string page = "Vector"]],
vector InVectorMax = 1
[[
string label = "Maximum Vector",
string page = "Vector"]],
// Outputs
output float ClampedFloat = 0,
output vector ClampedVector = 0,
output color ClampedColor = 0,
)
{
ClampedFloat = clamp(InFloat, InFloatMin, InFloatMax);
ClampedVector = clamp(InVector, InVectorMin, InVectorMax);
ClampedColor = clamp(InColor, InColorMin, InColorMax);
}