forked from Maxon-Computer/Redshift-OSL-Shaders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TurbulentColor.osl
44 lines (39 loc) · 1.14 KB
/
TurbulentColor.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
/*
* TurbulentColor.osl by elbrujodelatribu (c)2013
* from https://github.com/sambler/osl-shaders
* Modified 04.02.2021 by Saul Espinosa for Redshift 3d
* original script from -
* http://elbrujodelatribu.blogspot.com.au/2013/05/blender-cycles-osl-color-turbulence.html
* based on work from
* http://glsl.heroku.com/e#8664.0
* This file is licensed under Apache 2.0 license
*/
shader TurbulentColor
[[ string help = "Turbulent Color Noise",
string label = "Turbulent Color" ]]
(
vector Vector = P,
float Scale = 5
[[
float min = 0, float max = 25
]],
float Time = 1.0
[[
float min = 0, float max = 100
]],
int MaxIterations = 64
[[
int min = 1, int max = 100
]],
output color Color = 0.8)
{
vector p = Vector * Scale;//surfacePosition;
for(int i=1; i < MaxIterations; i++)
{
vector newp = p;
newp[0]+=0.6/float(i)*sin(float(i)*p[1]+Time/20.0+0.3*float(i))+20.0;
newp[1]+=0.6/float(i)*sin(float(i)*p[0]+Time/20.0+0.3*float(i+10))-5.0;
p=newp;
}
Color = color(sin(Time+p[1]+p[0]-M_PI*color(0,2,4)/(4.0+sin(Time)))*0.3+0.5);
}