TurbulentColor - 图1

    1. /*
    2. * TurbulentColor.osl by elbrujodelatribu (c)2013
    3. * from https://github.com/sambler/osl-shaders
    4. * Modified 04.02.2021 by Saul Espinosa for Redshift 3d
    5. * original script from -
    6. * http://elbrujodelatribu.blogspot.com.au/2013/05/blender-cycles-osl-color-turbulence.html
    7. * based on work from
    8. * http://glsl.heroku.com/e#8664.0
    9. * This file is licensed under Apache 2.0 license
    10. */
    11. shader TurbulentColor
    12. [[ string help = "Turbulent Color Noise",
    13. string label = "Turbulent Color" ]]
    14. (
    15. vector Vector = P,
    16. float Scale = 5
    17. [[
    18. float min = 0, float max = 25
    19. ]],
    20. float Time = 1.0
    21. [[
    22. float min = 0, float max = 100
    23. ]],
    24. int MaxIterations = 64
    25. [[
    26. int min = 1, int max = 100
    27. ]],
    28. output color Color = 0.8)
    29. {
    30. vector p = Vector * Scale;//surfacePosition;
    31. for(int i=1; i < MaxIterations; i++)
    32. {
    33. vector newp = p;
    34. newp[0]+=0.6/float(i)*sin(float(i)*p[1]+Time/20.0+0.3*float(i))+20.0;
    35. newp[1]+=0.6/float(i)*sin(float(i)*p[0]+Time/20.0+0.3*float(i+10))-5.0;
    36. p=newp;
    37. }
    38. Color = color(sin(Time+p[1]+p[0]-M_PI*color(0,2,4)/(4.0+sin(Time)))*0.3+0.5);
    39. }