OCTANE-OSL 随机UV

贴出····
本地:
shader OSL_UV_Randomizer(
/* Random U */
float U_Offset_From = -1
[[string label = "U_Offset_From",
float min=-10, float max=10]],
float U_Offset_To = 1
[[string label = "U_Offset_To",
float min=-10, float max=10]],
color RND_U = 0
[[string label = "RND_U_Coord",
float min=0, float max=1]],
/* Random V */
float V_Offset_From = -1
[[string label = "V_Offset_From",
float min=-10, float max=10]],
float V_Offset_To = 1
[[string label = "V_Offset_To",
float min=-10, float max=10]],
color RND_V = 0
[[string label = "RND_V_Coord",
float min=0, float max=1]],
/* Random Scale */
float Scale_From = 0.5
[[string label = "RND_Texture",
float min=0, float max=10]],
float Scale_To = 1
[[string label = "Scale_To",
float min=0, float max=10]],
color RND_Scale = 0
[[string label = "Scale_From",
float min=0, float max=1]],
/* Random Rotation */
float Angle_From = 0
[[string label = "Angle_From",
float min=-360, float max=360,
float slidermin=0.0, float slidermax=360]],
float Angle_To = 360
[[string label = "Angle_To",
float min=-360, float max=360,
float slidermin=0, float slidermax=360]],
color RND_Rotate = 0
[[string label = "RND_Rotate",
float min=0, float max=1]],
output vector Out = 0
)
{
float OffsetU = (RND_U[0]) / (1-0) * (U_Offset_To - U_Offset_From) + U_Offset_From;
float OffsetV = (RND_V[0]) / (1-0) * (V_Offset_To - V_Offset_From) + V_Offset_From;
float Scale = (RND_Scale[0]) / (1-0) * (Scale_To - Scale_From) + Scale_From;
float RemapAngle = (RND_Rotate[0]*360) / (360-0) * (Angle_To - Angle_From) + Angle_From;
point UVs = point(u, v, 0);
vector axis0 = point(0.5,0.5,0);
vector axis1 = point(0.5,0.5,1);
float Angrmp = (RemapAngle);
float rads = radians(Angrmp);
point UVoffset = rotate(UVs, rads, axis0, axis1);
point UVscale = point( (UVoffset[0] + OffsetU), (UVoffset[1] + OffsetV), 0);
point UVout = vector( (UVscale[0] / Scale), (UVscale[1] / Scale), 0);
Out = UVout;
}