forked from Maxon-Computer/Redshift-OSL-Shaders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColorJitter.osl
52 lines (48 loc) · 2.98 KB
/
ColorJitter.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
// Index based Randomizer created Joseph Nickson
// Recreation of Arnold's alJitter for redshift, built off Saul Espinosa's shader
// This file is licensed under Apache 2.0 license
// Modified 06.13.2022 to add page data by Saul Espinosa.
shader rsInputJitter
[[ string help = "Randomizes an inputs colour using UserData.",
string label = "ColorJitter" ]]
(
// Defube Inputs
color Input = 0 [[string page = "Input"]],
int Data = 0 [[string label = "UserData", string page = "Input"]],
float ValMin = 0.0 [[string label = "Value Min", float min = -1, float max = 1, string page = "Value"]],
float ValMax = 0.0 [[string label = "Value Max", float min = -1, float max = 1, string page = "Value"]],
float HueMin = 0.0 [[string label = "Hue Min", float min = -1, float max = 1, string page = "Hue"]],
float HueMax = 0.0 [[string label = "Hue Max", float min = -1, float max = 1, string page = "Hue"]],
float SatMin = 0.0[[string label = "Saturation Min", float min = -1, float max = 1, string page = "Saturation"]],
float SatMax = 0.0[[string label = "Saturation Max", float min = -1, float max = 1, string page = "Saturation"]],
float TempMin = 0.0[[string label = "Temperature Min", float min = -.5, float max = .5, string page = "Temperature"]],
float TempMax = 0.0[[string label = "Temperature Max", float min = -.5, float max = .5, string page = "Temperature"]],
float TintMin = 0.0[[string label = "Tint Min", float min = -.5, float max = .5, string page = "Tint"]],
float TintMax = 0.0[[string label = "Tint Max", float min = -.5, float max = .5, string page = "Tint"]],
int Seed = 1[[int min = 0,int max = 100,string page = "Seed"]],
/// Define Outputs
output color ColorOut = Input,
)
{
// Output Values
float ratio1 = noise("cell", vector(abs(Data), abs(Seed), 10));
float ratio2 = noise("cell", vector(abs(Data), abs(Seed), 11));
float ratio3 = noise("cell", vector(abs(Data), abs(Seed), 12));
float ratio4 = noise("cell", vector(abs(Data), abs(Seed), 13));
float ratio5 = noise("cell", vector(abs(Data), abs(Seed), 14));
float HueShift = mix(HueMin, HueMax, ratio1);
float SatShift = mix(SatMin, SatMax, ratio2);
float ValShift = mix(ValMin, ValMax, ratio3);
float TempShift = mix(TempMin, TempMax, ratio4);
float TintShift = mix(TintMin, TintMax, ratio5);
color Out = transformc("rgb", "hsv", Input);
Out[0] += HueShift;
Out[1] += SatShift;
Out[2] += ValShift;
Out = transformc("hsv", "rgb", Out);
// Temp & Tint Shifts
Out[0] += TempShift;
Out[1] += TintShift;
Out[2] -= TempShift;
ColorOut = Out;
}