rsl.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. Language: RenderMan RSL
  3. Author: Konstantin Evdokimenko <qewerty@gmail.com>
  4. Contributors: Shuen-Huei Guan <drake.guan@gmail.com>
  5. Website: https://renderman.pixar.com/resources/RenderMan_20/shadingLanguage.html
  6. Category: graphics
  7. */
  8. function rsl(hljs) {
  9. const BUILT_INS = [
  10. "abs",
  11. "acos",
  12. "ambient",
  13. "area",
  14. "asin",
  15. "atan",
  16. "atmosphere",
  17. "attribute",
  18. "calculatenormal",
  19. "ceil",
  20. "cellnoise",
  21. "clamp",
  22. "comp",
  23. "concat",
  24. "cos",
  25. "degrees",
  26. "depth",
  27. "Deriv",
  28. "diffuse",
  29. "distance",
  30. "Du",
  31. "Dv",
  32. "environment",
  33. "exp",
  34. "faceforward",
  35. "filterstep",
  36. "floor",
  37. "format",
  38. "fresnel",
  39. "incident",
  40. "length",
  41. "lightsource",
  42. "log",
  43. "match",
  44. "max",
  45. "min",
  46. "mod",
  47. "noise",
  48. "normalize",
  49. "ntransform",
  50. "opposite",
  51. "option",
  52. "phong",
  53. "pnoise",
  54. "pow",
  55. "printf",
  56. "ptlined",
  57. "radians",
  58. "random",
  59. "reflect",
  60. "refract",
  61. "renderinfo",
  62. "round",
  63. "setcomp",
  64. "setxcomp",
  65. "setycomp",
  66. "setzcomp",
  67. "shadow",
  68. "sign",
  69. "sin",
  70. "smoothstep",
  71. "specular",
  72. "specularbrdf",
  73. "spline",
  74. "sqrt",
  75. "step",
  76. "tan",
  77. "texture",
  78. "textureinfo",
  79. "trace",
  80. "transform",
  81. "vtransform",
  82. "xcomp",
  83. "ycomp",
  84. "zcomp"
  85. ];
  86. const TYPES = [
  87. "matrix",
  88. "float",
  89. "color",
  90. "point",
  91. "normal",
  92. "vector"
  93. ];
  94. const KEYWORDS = [
  95. "while",
  96. "for",
  97. "if",
  98. "do",
  99. "return",
  100. "else",
  101. "break",
  102. "extern",
  103. "continue"
  104. ];
  105. const CLASS_DEFINITION = {
  106. match: [
  107. /(surface|displacement|light|volume|imager)/,
  108. /\s+/,
  109. hljs.IDENT_RE,
  110. ],
  111. scope: {
  112. 1: "keyword",
  113. 3: "title.class",
  114. }
  115. };
  116. return {
  117. name: 'RenderMan RSL',
  118. keywords: {
  119. keyword: KEYWORDS,
  120. built_in: BUILT_INS,
  121. type: TYPES
  122. },
  123. illegal: '</',
  124. contains: [
  125. hljs.C_LINE_COMMENT_MODE,
  126. hljs.C_BLOCK_COMMENT_MODE,
  127. hljs.QUOTE_STRING_MODE,
  128. hljs.APOS_STRING_MODE,
  129. hljs.C_NUMBER_MODE,
  130. {
  131. className: 'meta',
  132. begin: '#',
  133. end: '$'
  134. },
  135. CLASS_DEFINITION,
  136. {
  137. beginKeywords: 'illuminate illuminance gather',
  138. end: '\\('
  139. }
  140. ]
  141. };
  142. }
  143. export { rsl as default };