forked from Maxon-Computer/Redshift-OSL-Shaders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UVWTransform.osl
72 lines (61 loc) · 1.54 KB
/
UVWTransform.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// An UVW coordinate tranfrormation tool
// UVWTransform.osl by Zap Andersson
// Modified: 2019-11-27
// Copyright 2019 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license
// https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt
// Modified by Saul Espinosa for Redshift Renderer 2021-01-21 Added Extra Page Metadata
shader UVWTransform
[[
string label = "UVW Transform",
string category = "UVW Coordinates",
string version = "2.1"
]]
(
point uvwInput = point(u, v, 0)
[[
string label = "Input UVW"
]],
float Scale = 1.0
[[
string page = "Adjustments" ,
float min = 0, float max = 25
]],
vector Tiling = 1.0
[[
string page = "Adjustments"
]],
vector Offset = 0.0
[[
string page = "Adjustments"
]],
int Wrap = 0
[[
string widget = "checkBox",
string page = "Adjustments",
int connectable = 0,
]],
float Rotate = 0.0
[[
string page = "Rotation",
float min = -180, float max = 180
]],
point RotCenter = point(0.5,0.5,0)
[[
string label = "Rotation Center",
string page = "Rotation"
]],
vector RotAxis = vector(0.0,0.0,1.0)
[[
string label = "Rotation Axis",
string page = "Rotation"
]],
// UVW Output
output point UVW = 0
)
{
vector worldScale = 1.0;
point Input = select(vector(u,v,0), uvwInput, isconnected(uvwInput));
UVW = rotate(Input - Offset, radians(Rotate), RotCenter, RotCenter + RotAxis) * Tiling / worldScale / Scale;
if (Wrap)
UVW -= floor(UVW);
}