NoiseColor - 图1

    1. // OSL Shader by Tomás Atria based on http://glslsandbox.com/ examples
    2. // Modified by Saul Espinosa 7/15/2021 for Redshift 3d
    3. shader noise_colors
    4. [[ string help = "Swirling Color Noise",
    5. string label = "Noise Colors" ]]
    6. (
    7. point Po = point(u,v,0)
    8. [[ string label = "Position" ]],
    9. float Time = 1.0
    10. [[ string label = "Time", float min = 0.0, float max = 1000.0]],
    11. int aces = 0
    12. [[ string widget = "checkBox",
    13. string label = "ACES",
    14. int connectable = 0 ]],
    15. output color outColor = 0,
    16. )
    17. {
    18. float Pi = 10.;
    19. int complexity = 30; // More points of color.
    20. float fluid_speed = 600.0; // Drives speed, higher number will make it slower.
    21. float color_intensity = 0.5;
    22. point p = Po;
    23. p *= 2;
    24. for(int i=1;i<complexity;i++)
    25. {
    26. point newp=p + Time*0.001;
    27. newp[0]+=0.6/float(i)*sin(float(i)*p[1]+Time/fluid_speed+20.3*float(i)) + 0.5; // + mouse.y/mouse_factor+mouse_offset;
    28. newp[1]+=0.6/float(i)*sin(float(i)*p[0]+Time/fluid_speed+0.3*float(i+10)) - 0.5; // - mouse.x/mouse_factor+mouse_offset;
    29. p=newp;
    30. }
    31. // ACES sRGB Transform
    32. matrix aces_tm = matrix(
    33. 0.6131, 0.0701, 0.0206, 0,
    34. 0.3395, 0.9164, 0.1096, 0,
    35. 0.0474, 0.0135, 0.8698, 0,
    36. 0, 0, 0, 1);
    37. color Out= color(color_intensity*sin(5.0*p[0])+color_intensity,color_intensity*sin(3.0*p[1])+color_intensity,color_intensity*sin(p[0]+p[1])+color_intensity);
    38. float r = Out[0], g = Out[1], b = Out[2];
    39. // ACES Output
    40. if (aces == 0)
    41. outColor = linearstep (0, 2, Out);
    42. else
    43. {
    44. outColor = linearstep (0, 2, (transform(aces_tm, vector(r,g,b))));
    45. }
    46. }