Starfield - 图1

    1. /*
    2. * StarField.osl by Thomas Dinges
    3. * from https://github.com/sambler/osl-shaders
    4. *
    5. * original script from -
    6. * http://www.renderman.org/RMR/RMRShaders.html
    7. *
    8. * Starfield.sl -- Surface shader for a star field.
    9. *
    10. * DESCRIPTION:
    11. * Makes a star field. Best when used as a surface shader for the inside
    12. * of a large sphere.
    13. *
    14. * PARAMETERS:
    15. * frequency frequency of the stars
    16. * intensity how bright are the stars?
    17. * Width how wide is the point spread function? i.e. larger
    18. * values make "wider" stars, but the look less round.
    19. *
    20. * AUTHOR: written by Larry Gritz, 1992
    21. *
    22. * HISTORY:
    23. * 28 Dec 1992 -- written by lg for the "Timbre Trees" video (saucer)
    24. * 12 Jan 1994 -- recoded by lg in correct shading language.
    25. *
    26. * modified 12 Jan 1994 by Larry Gritz
    27. * converted to OSL by Thomas Dinges Dec 2012
    28. * modified 1/4/2020 by Saul Espinosa for Redshift
    29. * This file is licensed under Apache 2.0 license
    30. */
    31. shader StarField
    32. [[ string help = "Generates procedural stars",
    33. string label = "Starfield" ]]
    34. (
    35. float Intensity = 0.5
    36. [[
    37. float min = 0,
    38. float max = 100
    39. ]],
    40. float Frequency = 100.0
    41. [[
    42. float min = 0,
    43. float max = 500
    44. ]],
    45. float Width = 0.2
    46. [[
    47. float min = 0,
    48. float max = 1
    49. ]],
    50. output float Fac = 1.0 )
    51. {
    52. point PP;
    53. float val;
    54. PP = Frequency * P;
    55. /* Use a noise value, but only keep the "tips" of the blotches */
    56. val = smoothstep (1 - Width, 1, noise(PP));
    57. /* scale it by the intensity and sharpen it by squaring */
    58. Fac = Intensity * val*val;
    59. }