Blackbody - 图1

    1. // Blackbody Color Shader
    2. // Blackbody.osl, by Zap Andersson
    3. // Modified: 2021-03-17 by Saul Espinosa for Redshift 3D
    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. shader Blackbody
    7. [[ string help = "Modulates a color between two Kelvin temperatures",
    8. string category = "Utility",
    9. string label = "Blackbody Emission"
    10. ]]
    11. (
    12. float Input = 1.0 [[string page = "1 : Input", float min = 0, float max = 5]],
    13. float Min = 0.0 [[ float min = 0.0, float max = 10000.0, string page = "1 : Input" ]],
    14. float Max = 5000.0 [[ float min = 0.0, float max = 10000.0, string page = "1 : Input" ]],
    15. float Intensity = 1.0 [[ float min = 0, float max = 100, string page = "1 : Input" ]],
    16. int aces = 0
    17. [[ string widget = "checkBox",
    18. string page = "2 : Extra",
    19. string label = "ACES",
    20. int connectable = 0 ]],
    21. output color outColor = 0.0,
    22. )
    23. {
    24. // ACES sRGB Transform
    25. matrix aces_tm = matrix(
    26. 0.6131, 0.0701, 0.0206, 0,
    27. 0.3395, 0.9164, 0.1096, 0,
    28. 0.0474, 0.0135, 0.8698, 0,
    29. 0, 0, 0, 1);
    30. color Col = blackbody(mix(Min, Max, Input));
    31. color Out = Col * Intensity;
    32. float r = Out[0], g = Out[1], b = Out[2];
    33. // ACES Output
    34. if (aces == 0)
    35. outColor = Out;
    36. else
    37. {
    38. outColor = transform(aces_tm, vector(r,g,b));
    39. }
    40. }