UVWTransform - 图1

    1. // An UVW coordinate tranfrormation tool
    2. // UVWTransform.osl by Zap Andersson
    3. // Modified: 2019-11-27
    4. // Copyright 2019 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license
    5. // https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt
    6. // Modified by Saul Espinosa for Redshift Renderer 2021-01-21 Added Extra Page Metadata
    7. shader UVWTransform
    8. [[
    9. string label = "UVW Transform",
    10. string category = "UVW Coordinates",
    11. string version = "2.1"
    12. ]]
    13. (
    14. point uvwInput = point(u, v, 0)
    15. [[
    16. string label = "Input UVW"
    17. ]],
    18. float Scale = 1.0
    19. [[
    20. string page = "Adjustments" ,
    21. float min = 0, float max = 25
    22. ]],
    23. vector Tiling = 1.0
    24. [[
    25. string page = "Adjustments"
    26. ]],
    27. vector Offset = 0.0
    28. [[
    29. string page = "Adjustments"
    30. ]],
    31. int Wrap = 0
    32. [[
    33. string widget = "checkBox",
    34. string page = "Adjustments",
    35. int connectable = 0,
    36. ]],
    37. float Rotate = 0.0
    38. [[
    39. string page = "Rotation",
    40. float min = -180, float max = 180
    41. ]],
    42. point RotCenter = point(0.5,0.5,0)
    43. [[
    44. string label = "Rotation Center",
    45. string page = "Rotation"
    46. ]],
    47. vector RotAxis = vector(0.0,0.0,1.0)
    48. [[
    49. string label = "Rotation Axis",
    50. string page = "Rotation"
    51. ]],
    52. // UVW Output
    53. output point UVW = 0
    54. )
    55. {
    56. vector worldScale = 1.0;
    57. point Input = select(vector(u,v,0), uvwInput, isconnected(uvwInput));
    58. UVW = rotate(Input - Offset, radians(Rotate), RotCenter, RotCenter + RotAxis) * Tiling / worldScale / Scale;
    59. if (Wrap)
    60. UVW -= floor(UVW);
    61. }