daily pastebin goal
62%
SHARE
TWEET

Untitled

a guest Aug 7th, 2011 135 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. Porting Mental Ray Shaders to MAX Plugins
  3. =========================================
  4.  
  5. General notes:
  6.  
  7. MR Shader to MAX Plugin mapping:
  8. -------------------------------
  9.  
  10. MR Shader type             MAX Plugin Type          Primary MAX plugin base class
  11. ==============             ===============          =============================
  12. Material                   Material and/or Shader   Mtl, Shader
  13. Texture                    Texmap                   Texmap
  14. Environment                (Texmap)                 Texmap
  15. Volume                     Atmospheric              Atmospheric
  16. Light                      Light Object             LightObject
  17. Shadow                     Shadow Generator         ShadowGenerator
  18. Lens                       Camera Object            CameraObject
  19. Output                     RenderEffect, BitmapIO   BitmapIO, Effect, ImageFilter
  20. Displacement               (Texmap)                 Texmap
  21. Geometry                   Procedural Object        GeomObject
  22.  
  23. For the environment, MAX allows users to associate a Texmap with
  24. the environment, which can be any Texmap plugin.
  25.  
  26. Displacement shading in MAX is done via the Displacement channel
  27. of a typical MAX material, and any Texmap plugin is allowed to
  28. be used to provide the specific displacement information.
  29.  
  30. (no real MAX equivalents for Photon shaders?)
  31.  
  32.  
  33. MR State Variable to MAX Context state mapping
  34. ----------------------------------------------
  35.  
  36. (Todo: finish, cleanup)
  37.  
  38. What follows is a rough mapping of MR shader state
  39. variables to MAX class vars, functions, etc.  In
  40. most cases, the assumption was that the behavior to
  41. MR state variables was desired (e.g. available at
  42. render-time).  In some cases, information is available
  43. in the MAX scene, available at render time, but not
  44. exactly via a "direct" path (for example: during render,
  45. some, but limited camera info is available in the
  46. ViewParams of the RenderGlobalContext, but it's also
  47. possible to iterate over the scene and find the actual
  48. Camera object for detailed information)
  49.  
  50.  
  51. MR State Variable         MAX Class or Function
  52. =================         =====================
  53.  
  54. version                  
  55. camera_inst              
  56. camera
  57. options
  58.  
  59. orthographic
  60. focal
  61. aperture
  62. aspect
  63. clip
  64. x_resolution
  65. y_resolution
  66. window.xl
  67. window.yl
  68. window.xh
  69. window.yh
  70. volume
  71. environment
  72. lens
  73. output
  74. frame
  75. frame_time
  76. x_offset
  77. y_offset
  78.  
  79. trace
  80. scanline
  81. motion
  82. shadow
  83. filter
  84. acceleration
  85. face
  86. field
  87. reflection_depth
  88. refraction_depth
  89. trace_depth
  90. photon_reflection_depth
  91. photon_refraction_depth
  92. photon_trace_depth
  93. samplelock
  94. caustic
  95. globillum
  96. finalgather
  97. image
  98.  
  99. raster_x
  100. raster_y
  101. shader
  102. global_lock
  103. thread
  104.  
  105. parent
  106. child
  107. type
  108.  
  109. (etc)
  110.  
  111.  
  112. MR Utility Function to MAX Utility fcn/class mapping
  113. ----------------------------------------------------
  114.  
  115. (todo, probably helpful to try and show rough equivalents for
  116. various mi_api/mi_xxx functions...note that these probably
  117. won't map nicely...for example, mi_img_xxx functions will
  118. map somewhat to Bitmap and GBuffer functions, but probably
  119. not exactly)
  120.  
  121.  
  122.  
  123. Shader Parameters and UI in MAX
  124. -------------------------------
  125.  
  126. MAX plugins keep all custom user-modifiable parameters
  127. in something called a ParamBlock2
  128. (see "Parameter Blocks and Maps in Release 3" in SDK documentation).  
  129. You must use a paramblock2 in your MAX plugin port if you have
  130. user parameters.  The reasons include:
  131.  
  132.   1) MAXTrans interface to MR will automatically pick up
  133.      PB2 information and output it to the MI file
  134.   2) It significantly reduces the amount of development
  135.      work for things like parameter validity checking,
  136.      and hooking up parameters to MAX plug-in user UI.
  137.   3) Will likely become required for future release of MAX.
  138.  
  139. Note that MAX doesn't have the same State information that
  140. MR passes to shaders, so you may need to replicate some information
  141. as user parameters instead.
  142.  
  143.  
  144. Typical plugin source file layout
  145. ---------------------------------
  146.  
  147. While in MR you might have had a single simple shader C source
  148. plus some includes, MAX plugins are Windows DLLs, and require some
  149. additional files, along with additional work to integrate the plugin
  150. DLL into the MAX application.
  151.  
  152. Typically, a plugin will have:
  153.  
  154.   -- plugin MSDEV project files (<plugin>.DSP, <plugin>.DSW, <plugin>.MAK)
  155.   -- plugin "def" file (<plugin>.DEF) that defines the standard DLL exports
  156.      that are needed so that MAX can load and access the plugin objects
  157.   -- Windows UI resources file (<plugin>.RC)
  158.   -- source files: usually a main header, and one or more source files,
  159.      broken-out as desired.
  160.  
  161. Suggested SDK Sections to Read:
  162.  
  163.  
  164.  
  165. Interaction with Mental Ray
  166. ---------------------------
  167.  
  168. [Norm -- this needs review]
  169.  
  170. If your plugin uses PB2, the MAX-to-MR Connection will automatically
  171. generate appropriate shader declaration, param names and calls.  Note that
  172. it will prepend a "max_" to the name of the shader/plugin.
  173.  
  174. -- Versioning
  175.  
  176. [Norm -- actually shader versioning was kinda a mystery to me.
  177. That is...miMTShader has get/setVersion, and this is used when
  178. generating the MI, but I can't tell where the translator gets
  179. the version from...or does it?
  180.  
  181. Perhaps an even better question is...where would the translator
  182. get plugin version info from...some plugin types have it builtin
  183. (e.g. Import/Export).  Most I'd think would utilize the PB2
  184. mechanisms for versioning...not sure]
RAW Paste Data
Top